|
Author |
Message |
Kdawg
Senior WebHelper
Joined: 21 Apr 2003
Posts: 153
|
Posted:
Sun Feb 08, 2004 5:11 pm (20 years, 2 months ago) |
|
How can I use text in the where clause in php, like
Code: | SELECT state FROM people WHERE name = $name |
and $name would be joe?
I allways get this error when I do this
Code: | Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/stingbas/public_html/webtech/pagecreator/disp.php on line 6 |
I think it means it didnt find anything but I dont know how to get it to work. |
|
|
|
|
adam
Forum Moderator & Developer
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Sun Feb 08, 2004 7:30 pm (20 years, 2 months ago) |
|
after the call to mysql_query(), add:
Code: | print mysql_error(); |
so you can see why the query failed...if it simply hadn't found anything, it wouldn't produce that error. |
________________________________ It's turtles all the way down... |
|
|
|
OllieMaitland
Junior WebHelper
Joined: 06 Dec 2003
Posts: 25
|
Posted:
Mon Feb 09, 2004 12:17 am (20 years, 2 months ago) |
|
Have you tried running the query through phpmyadmin? I normally do this to test queries then when you put it in the code it works straight off...
Also on another note you should really have unenclosed query strings because if you have spaces or ' in the string the query will fail...
so it probably should be:
Code: |
SELECT state FROM people WHERE name = ' ".$name." '
|
..also if $name is a variable from a form you should use:
Code: |
SELECT state FROM people WHERE name = ' ".$_POST['name']." '
|
other things to watch out for is whether the field names are the same case as in the table.
hope you get it working |
|
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.12003 seconds :: 19 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |