View Single Post
Old 10-05-2007, 08:21 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,380
Thanks: 5
Salathe is on a distinguished road
Default

Code:
// JavaScript line 15
var url = url+"?keyword="+str

// PHP line 4
$get = $_GET["keywords"];
For starters, the two keys are different (keyword/keywords) which really won't help at all.

Also, why do you keep putting %$search% (I've noticed this in other topics)? That'll produce a syntax error because the percent symbols just aren't allowed to be used like that.

Since you're using sprintf anyway, why not put the table name as an argument? (e.g, SELECT * FROM %2$s...)

Depending on your php.ini settings, if you don't pass along the keywords in the query string then the PHP engine will raise a Notice error ("Undefined index") -- it's trivial to check if the key exists before trying to assign it's value to a variable.

In your JavaScript, with regards to the multiple "var url", you only need to use var the first time to declare url as a variable local to that function. On line 15, quoted at the top of this post, you make reference to a str variable but the function argument is called string. I'd love to see you using semi-colons at the end of the lines but that's just a personal preference.

That's it for starters, I haven't even looked at the code in more than a brief manner but the above should get you moving along a bit.
Salathe is offline  
Reply With Quote