PHP - MySql Function Problems

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Colin
-


Joined: 18 Mar 2003
Posts: 2
Location: England

PostPosted: Tue Mar 18, 2003 1:46 am    Post subject: PHP - MySql Function Problems Reply with quote

I'm getting an erro when trying to count the number of records obtained from a mysql db. the error states:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Abyss Web Server\htdocs\login.php on line 6

the code is:

$db = mysql_connect("localhost", "root");
mysql_select_db("itjobhunt", $db);
$sql = "Select * FROM agency WHERE agy_ID = '" + $agy_Account + "'";
$result = mysql_query($sql);
$results = mysql_num_rows($result);
echo "<br>$results<br>";

I have an idea that this may be to do with the setup of PHP but may be completely wrong. Any idea's??
Back to top View user's profile Send private message Send e-mail
rIkLuNd
-


Joined: 15 Jan 2003
Posts: 25
Location: Örebro, Sweden

PostPosted: Tue Mar 18, 2003 6:46 am    Post subject: Reply with quote

Try changing your query:

$sql = "Select * FROM agency WHERE agy_ID = '" . $agy_Account . "'";

--------------------------------------------------------^----------------^
This is what I changed.
Back to top View user's profile Send private message Send e-mail MSN Messenger ICQ Number
Colin
-


Joined: 18 Mar 2003
Posts: 2
Location: England

PostPosted: Tue Mar 18, 2003 9:42 am    Post subject: Reply with quote

Didn't seem to make any difference.
Back to top View user's profile Send private message Send e-mail
rIkLuNd
-


Joined: 15 Jan 2003
Posts: 25
Location: Örebro, Sweden

PostPosted: Tue Mar 18, 2003 9:43 am    Post subject: Reply with quote

try adding some debug code:
$result = mysql_query($sql) or die(mysql_error());
By doing this, you may find out about errors that you might miss now...
Back to top View user's profile Send private message Send e-mail MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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


Powered by phpBB phpBB Group