![]() |
Simple PHP Search Script
I put this all on index.php:
:
Notice: Undefined variable: searching in /home/arnackco/public_html/index.php on line 20 Any help please? :( |
Re: Simple PHP Search Script
The problem is your not pulling the searching variable out of the POST data.
What you need to do first is this: :
Put that above the if statement and it will work. |
Re: Simple PHP Search Script
Im no PHP expert but, im guessing that when the user submits the form it reloads to its own page then checks what the user entered based on the code provided.
You are trying to acces a variable $searching, which doesn't exist this is because you want the result from the previous page when it was submitted no? So since you are using the post method for the form you need to use this :
or just directly link it in instead of assigning it to the variable searching. Chris o Big K beat me, o well lol |
Re: Simple PHP Search Script
Okay, thanks... and I tried that. Now it's bringing the error that I forgot to type something in the search for some reason.. (when I am typing in the search is still does the same thing..).
EDIT: nevermind, I saw that 'find' variable was not defined either. Now I have this code: :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/arnackco/public_html/index.php on line 46 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/arnackco/public_html/index.php on line 58 Sorry, but we can not find an entry to match your query |
Re: Simple PHP Search Script
:
Give this a try, I didn't test it though. All I did was add an if statement to check the $data variable before going through the results. I think you could also try changing this line $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); to $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'") or die("Query Error"); |
Re: Simple PHP Search Script
Alright it does print out Query Error.. :(
|
Re: Simple PHP Search Script
Ok, so atleast now you know there is a problem when sending your query. might want to check your SQL statement.
Change this: :
:
This way you can see exactly what is being sent to the database. |
Re: Simple PHP Search Script
Try printing out the variables and the query before sending them off. Verify that the query and related variables are sound and correct.
Also, I'm not sure but it could matter that you had an apostraphe directly after the word 'LIKE'. Then finally, add a mysql_error() command to see what happened. :
|
Re: Simple PHP Search Script
Okay. Here is my MySQL code:
:
:
error: (i typed in testsearch in the search) SELECT * FROM users WHERE upper() LIKE'%TESTSEARCH%'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') LIKE'%TESTSEARCH%'' at line 1 |
Re: Simple PHP Search Script
The problem is in your select statement. You don't have a column name after the WHERE in your select statement. Probably should look like this
:
so in your php it should be: :
|
| All times are GMT -5. The time now is 2:30 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC