|
Author |
Message |
Kdawg
Senior WebHelper
![Senior WebHelper Senior WebHelper](images/rank_3.gif)
![](images/avatars/gallery/computers/php.gif)
Joined: 21 Apr 2003
Posts: 153
|
Posted:
Sun Feb 08, 2004 5:11 pm (20 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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. |
|
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by Kdawg Find all posts by Kdawg](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) |
![](images/spacer.gif) |
adam
Forum Moderator & Developer
![](images/rank_6.gif)
Joined: 26 Jul 2002
Posts: 704
Location: UK
|
Posted:
Sun Feb 08, 2004 7:30 pm (20 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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... |
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by adam Find all posts by adam](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) ![Visit Poster's Website Visit Poster's Website](templates/4WebHelp2/images/lang_english/icon_www.gif) |
![](images/spacer.gif) |
OllieMaitland
Junior WebHelper
![Junior WebHelper Junior WebHelper](images/rank_1.gif)
Joined: 06 Dec 2003
Posts: 25
|
Posted:
Mon Feb 09, 2004 12:17 am (20 years, 2 months ago) |
![Reply with Quote Reply with Quote](templates/4WebHelp2/images/lang_english/icon_quote.gif) ![Back to Top Back to Top](templates/4WebHelp2/images/icon_up.gif) |
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 ![Wink](/forums/images/smilies/icon_wink.gif) |
|
|
![Offline](templates/4WebHelp2/images/offline.gif) ![View User's Profile View User's Profile](templates/4WebHelp2/images/lang_english/icon_profile.gif) ![Find all posts by OllieMaitland Find all posts by OllieMaitland](templates/4WebHelp2/images/lang_english/icon_search.gif) ![Send Personal Message Send Personal Message](templates/4WebHelp2/images/lang_english/icon_pm.gif) ![Send email Send email](templates/4WebHelp2/images/lang_english/icon_email.gif) |
![](images/spacer.gif) |
|
|
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.147381 seconds :: 19 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |