![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jul 2005
Posts: 66
Rep Power: 4
![]() |
Simple PHP Search Script
I put this all on index.php:
PHP Syntax (Toggle Plain Text)
Notice: Undefined variable: searching in /home/arnackco/public_html/index.php on line 20 Any help please? ![]() Last edited by big_k105; Mar 26th, 2008 at 1:23 PM. Reason: changed ICODE tag to CODE=PHP tag |
|
|
|
|
|
#2 |
|
PFO Founder
![]() ![]() |
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: php Syntax (Toggle Plain Text)
Put that above the if statement and it will work.
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
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 php Syntax (Toggle Plain Text)
or just directly link it in instead of assigning it to the variable searching. Chris o Big K beat me, o well lol |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jul 2005
Posts: 66
Rep Power: 4
![]() |
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: PHP Syntax (Toggle Plain Text)
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 |
|
|
|
|
|
#5 |
|
PFO Founder
![]() ![]() |
Re: Simple PHP Search Script
php Syntax (Toggle Plain Text)
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");
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Jul 2005
Posts: 66
Rep Power: 4
![]() |
Re: Simple PHP Search Script
Alright it does print out Query Error..
![]() |
|
|
|
|
|
#7 |
|
PFO Founder
![]() ![]() |
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: php Syntax (Toggle Plain Text)
php Syntax (Toggle Plain Text)
This way you can see exactly what is being sent to the database.
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#8 |
|
Programming Guru
![]() |
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. php Syntax (Toggle Plain Text)
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: Jul 2005
Posts: 66
Rep Power: 4
![]() |
Re: Simple PHP Search Script
Okay. Here is my MySQL code:
MYSQL Syntax (Toggle Plain Text)
php Syntax (Toggle Plain Text)
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 |
|
|
|
|
|
#10 |
|
PFO Founder
![]() ![]() |
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
sql Syntax (Toggle Plain Text)
so in your php it should be: php Syntax (Toggle Plain Text)
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|