ShawnCplus 456 Code Monkey Team Colleague
$search = join('%', explode(' ', $search));
/*
 For Example:
   search = 'John Smith';
   search = join('%', explode(' ', search));
   search now = John%Smith
*/
ShawnCplus 456 Code Monkey Team Colleague

You should still make your checks for length before this but this will check for numbers like 1111111 and 999999

var phone_number = "9999999";
if (!/^(\d)\1{6}$/.test(phone_number)) {
  alert('Good phone number');
} else {
  alert('Bad phone number');
}
ShawnCplus 456 Code Monkey Team Colleague

PHP5+, you can also use the stream functions.
http://www.php.net/manual/en/book.stream.php
http://www.php.net/manual/en/function.stream-socket-client.php

or the similar fsockopen() in PHP4:
http://www.php.net/fsockopen

With both of these you will create the raw HTTP request to send over TCP. However, if you need something more abstracted like cURL, you can use fopen(), with stream_context_create() in PHP5:
http://www.php.net/manual/en/function.fopen.php
http://www.php.net/manual/en/function.stream-context-create.php

There are also many HTTP libraries based on fsockopen and stream_socket_client. You can use these or follow their examples.
http://pear.php.net/package/HTTP

Those are all pretty much WAY overkill for what he needs. He's just trying to hit an API but the API writers evidently like their job too much and wrote the description in an extremely overtechnical way.

ShawnCplus 456 Code Monkey Team Colleague

You have C = document.frmOne.txtThirdNumber.value *1 in your function so if that field doesn't exist and you try to perform an action on it ( *1 in this case) the function will die.

ShawnCplus 456 Code Monkey Team Colleague

http://php.net/curl Google is your friend.

ShawnCplus 456 Code Monkey Team Colleague

no i did i dont understand what to look for

Thinks you can do to try and help yourself:

  • Search the Daniweb forums for the 8000 other posts asking what AJAX is
  • Google for "AJAX"
  • Google for "AJAX tutorial"
ShawnCplus 456 Code Monkey Team Colleague

that link is bad. no text. anyways how do i do it?

Neither of those links are bad, read them.

ShawnCplus 456 Code Monkey Team Colleague

Usually if you want something like that you'll have an ORM handle it for you transparently. Take a look at Doctrine (http://www.doctrine-project.org/)

ShawnCplus 456 Code Monkey Team Colleague

There really is no "best" with IDEs. Try a few out for a week or so (enough to get to know the IDE) then try another one. At the end figure out which one you like the best and stick with it.

Some popular ones:

ShawnCplus 456 Code Monkey Team Colleague

What language are you using the for backend? (PHP, ASP, whatever)

ShawnCplus 456 Code Monkey Team Colleague

A) Why is your ID field TEXT?
B)

SELECT MAX(CAST(id AS DECIMAL)) as id FROM object
iamthwee commented: sounds good to me. +24
ShawnCplus 456 Code Monkey Team Colleague

Use <pre></pre> or <code></code> tags around it like:

<pre>
#include &lt;iostream&gt;
int main(int argc, char** argv)
{
  std::cout &lt;&lt; "Hello World!\n";
  return 0;
}
</pre>

Note the &lt; . Make sure you encode any HTML entities (<, >, &, etc.) so they don't get mixed in with the markup

ShawnCplus 456 Code Monkey Team Colleague

Nice
I'm puzzled though, why is that code using same id on multiple elements?

And I have another puzzle somebody could answer to me: whose responsibility is to mark threads as solved, :: the thread starter or admins? (!please, I really don't know the answer to this, just curious!)

The poster marks the thread solved though admins probably have the ability it's not really their job to do so.

ShawnCplus 456 Code Monkey Team Colleague

It does save newlines, but my guess is that on output you're not using nl2br. The browser ignores newlines when rendering text unless it is in a <pre>, <code> or tag with white-space:pre applied. So yeah, use nl2br or get a rich-text editor

ShawnCplus 456 Code Monkey Team Colleague
Ezzaral commented: Exactly what I was thinking too :) +25
ShawnCplus 456 Code Monkey Team Colleague

A) Don't use ereg anything.

B) http://php.net/filter_input

ShawnCplus 456 Code Monkey Team Colleague

../images/ The .. means up one directory, so ../images/ really says htdocs/mysite/images/ . It would probably be better to use the absolute path but you haven't posted one so I don't know you're directory structure :)

ShawnCplus 456 Code Monkey Team Colleague

How about:

<?PHP
while($row=(mysql_fetch_array(result)) {

   echo "       
   <td>$row['photo']</td><td>$row['info']</td>
         ";
   if ($row=(mysql_fetch_array(result)) {
      echo "
      <td>$row['photo']</td><td>$row['info']</td>
      ";
   }

   echo "</tr>";
}

?>

I find it messy to go in and out of PHP so I modified it to make it all PHP.

Just no. For two reasons: Reason 1) You're duplicating code, if he wants to change the td's to dd's or something like that he has to change it in two places, Reason 2) I'm not even going to begin with how much more ugly that looks when compared to exiting PHP


The best way to go about it is to keep a counter and whenever it's divisible by 2 you've looped twice so end the row and start another one.

<tr>
<?php $i = 1; while($row=mysql_fetch_array(result)): ?>
  <?php if (!($i++ % 2) ): ?>
    </tr><tr>
  <?php endif ?>
    <td><?php echo $row['photo'] ?></td>
    <td><?php echo $row['info'] ?></td>
<?php endwhile ?>
</tr>
diafol commented: nice and succinct - wish I could see it - class +4
ShawnCplus 456 Code Monkey Team Colleague

The server it is working on probably has notices turned off. You should have an if (isset($_POST['username'])) block around that anyway.

ShawnCplus 456 Code Monkey Team Colleague

You would setup a server-side script (using PHP or ASP or whatever your language is) that uses cURL or whatever your language uses to make and output the response. Then your AJAX call just points to your script.

RemoteServer
-------------------
somefile.php

MyServer
-----------------
myapifile.php
`- Make request to RemoteServer.com/somefile.php
`- Output response from the request

myawesomeajax.js
`- Make request to myapifile.php
ShawnCplus 456 Code Monkey Team Colleague

Dear codeLion,

u gave me the solution thanks. But i might need such things regularly. I had shown u a link in which all this was there but i could not understand.Can u tell me how generally i can master such usernames and other queries.Tell me how u manipulated the string(the condition).so that i can explain it to her(her name is pooja she is from india..me too) and so that she too can get a grip and score good for a better college ..your help will be great!

i hope i am clear, thanks.

with love,
nikhil

They're called regular expressions and they're the best thing since sliced bread. http://www.regular-expressions.info/

ShawnCplus 456 Code Monkey Team Colleague

i tried the program using this

<html>
<body>

<script type="text/javascript">
var patt1=new RegExp("@","!");// or even just @


document.write(patt1.test("nik@123l#!"));
}

</script>

</body>
</html>

i do not get an output ..help.... how to i check for all special characters

var somestring = "Hello!@World, I have ^Spe_cial[ Chars";
if (!/^\w+$/.test(somestring)) {
  alert('Bad Username');
} else {
  alert('Good Username');
}
ShawnCplus 456 Code Monkey Team Colleague

w3schools.com is your friend

ShawnCplus 456 Code Monkey Team Colleague

Show all steps and derivations to receive full credit.

Sounds like you better get going. You could start by showing us some of what you've tried already or by explaining bits you don't understand. After all, this is your first post so maybe you missed the GIGANTIC text at the top of every forum that says we only give homework help to those who show effort.

ShawnCplus 456 Code Monkey Team Colleague

A) Use <script type="text/javascript> , not <Script language="JavaScript"> , it's old and the language attribute is deprecated
B) Your code doesn't actually do anything since it's never called (or at least, it'll always fail as soon as the page loads
C)

<head>
<script type="text/javascript">
var validateUsername = function ()
{
  var element = document.getElementById('username');
  if (element.value.length < 3) {
    alert('Invalid Username');
    return false;
  } else {
    alert('Acceptable');
    return true;
  }
};
</script>
</head>
<body>
<form name="f1" method="post" onsubmit="return validateUsername();">
  Username: <input type="text" id="username" name="user" />
  <input type="submit" value="submit" />
</form>
</body>
</html>
ShawnCplus 456 Code Monkey Team Colleague

They do look good; however, I need one that's going to offer unlimited space and bandwidth.

I have found two I do like, is there anyway to do a test (maybe through ping) or something to check out the reliability of the server and make sure they have good load balancing?

heh, you can't exactly test load balancing with a ping and I can say without a doubt that if you DoS a hosting company to "test their load balancing" they'll be very quick to send a nicely formatted letterhead containing their lawyer's phone number.

ShawnCplus 456 Code Monkey Team Colleague

You can get it done with just CSS

#some_id {
  position: fixed;
}
ShawnCplus 456 Code Monkey Team Colleague

Just do it inside the constructor, that's what it is there for.

ShawnCplus 456 Code Monkey Team Colleague

Or you could just do

<script type="text/javascript">
var somejsarray = <?php echo json_encode($somephparray) ?>;
</script>
ShawnCplus 456 Code Monkey Team Colleague

Show us your current code, we don't know you database schema or what to change if you don't

ShawnCplus 456 Code Monkey Team Colleague

None that I know of. That's a very strange question for a programming language. It's not like using PHP kills babies or something. The only thing that could even be remotely construed as an ethically related issue is the decision between open/closed source which I'll let you search for on your own.

ShawnCplus 456 Code Monkey Team Colleague

_ is usually associated with gettext with deals with text localization.

edgar5 commented: That makes some sense to me. +1
ShawnCplus 456 Code Monkey Team Colleague

It's syntactically correct and there's really no harm in it except for the fact that its a complete waste since the reason you have a function returning a value is because you want to use it. If you don't want to return a value then a function returns void.

#include <stdio.h>

int add(int x, int y)
{
  return x + y;
}

void print_add (int x, int y)
{
  printf("%d\n", add(x, y));
}

int main()
{
  add(5, 10); // does nothing
  print_add(5, 10); // outputs 15
  return 0;
}
ShawnCplus 456 Code Monkey Team Colleague

It isn't a Netbeans project but it is a JSP AJAX primer (found by searching AJAX JSP on google...) http://www.ics.uci.edu/~cs122b/projects/project5/AJAX-JSPExample.html

It should also be noted that while it is very important that you are familiar with your IDE it's just as important to not become absolutely dependent upon it.

ShawnCplus 456 Code Monkey Team Colleague

Don't be silly... you know very well that it could be done with Ajax.

Sure, it COULD be done with AJAX but there is absolutely no reason to. The term/acronym AJAX describes making a request to the server then receiving and parsing XML. There is absolutely, positively no reason to do something so complex for validation.

ShawnCplus 456 Code Monkey Team Colleague

The example you described isn't AJAX, that's just standard Javascript validation. AJAX would be, for example, as the user types display a list of possible selections underneath the box.

http://w3schools.com/ajax/ajax_intro.asp

ShawnCplus 456 Code Monkey Team Colleague
$row=mysql_fetch_array($result);
$vValue = $row['vValue'];

You're fetching one row before your while loop so its essentially doing nothing with the first row

ShawnCplus 456 Code Monkey Team Colleague

Looks like $filename is an array of arrays, try

foreach ($files as $file_list) {
  foreach ($file_list as $file) {
    var_dump($file); echo "\n";
  }
}
ShawnCplus 456 Code Monkey Team Colleague

var_dump($filename); inside the foreach loop and post the output

ShawnCplus 456 Code Monkey Team Colleague

Explode on spaces and use ORs for the extra terms. http://php.net/explode

ShawnCplus 456 Code Monkey Team Colleague

Make sure you're never trying to call the method before you actually define the prototype. Grab Firebug if you don't already and then do some breakpoint debugging to find exactly where the error is coming from.

ShawnCplus 456 Code Monkey Team Colleague

A) Don't bump like that, its annoying. B) Try Element.prototype. If that doesn't work I have no idea since both Object.proto... and Element.proto... worked for me.

ShawnCplus 456 Code Monkey Team Colleague

Then you move onto the next step of debugging. Remove stuff you just added until it stops breaking. Then re-add the code and figure out why it broke. Really, these are basic debugging steps to follow. If it's just utterly dying (I'm not sure what IDE/compiler you're using) then compile with debugging info and gdb the crap out of it.

ShawnCplus 456 Code Monkey Team Colleague

If you want to do it correctly its not going to be one class. It's probably going to be upwards of 4 or 5 classes. The database connection, the database interaction, the request handler, the authentication, the user, and probably a user class extending the base user for every level of privilege. Here's a start since you haven't actually posted any of your code yet.

class User
{
}
ShawnCplus 456 Code Monkey Team Colleague

Added some code but nope. nothing- If I add cout statements inside to track the error how can I see them if I have graphical form?

I was using couts as an example, the method you want to use to display the message is up to you

ShawnCplus 456 Code Monkey Team Colleague

Try actually putting something in your catch statement. And if you're not getting anything there then take the old-fashioned approach and just put asserts/couts along your code to see where it dies

catch (sql::SQLException &e)
{
}
ShawnCplus 456 Code Monkey Team Colleague

Show your current query and we can walk you through what to fix.

ShawnCplus 456 Code Monkey Team Colleague

You might want to try compiling and working your way through the errors. These two lines will definitely cause issues.

// call function calcAverage
int calcAverage(int score1, int score2, int score3);

// call function printStars
void printStars(int avg, int id);
ShawnCplus 456 Code Monkey Team Colleague

Thanks, I assumed <char> but now its outputting the list unsorted.

Is there something that needs to be put it front of ch.sort(); because its inside of a function?

Thanks.

My guess is that it's not being passed by reference :)

ShawnCplus 456 Code Monkey Team Colleague

You create your list as list <char> but your function prototype never defines a template type, you just have list . So you could either make the function templated or you can always assume <char>

template <typename T>
void sort(list<T> ch)
{
  ch.sort();
}

sort<char>(ch);

// or

void sort (list <char> ch)
{
  ch.sort();
}