|
-
May 16th, 2003, 06:09 AM
#1
More mySQL Problems [Resolved]
I have mySQL running on my computer here, and all works fine: using PHP I can enter data, and view it.
However, on the server, it just won't work.
I keep getting this error:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/mendhak/public_html/slambook/view.php on line 23
The code I'm using is
PHP Code:
$dbh=mysql_connect("localhost", "mendhak_hello", "zzz") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("slambook");
$abcquery = "SELECT * FROM slambook;";
$result = mysql_query($abcquery);
echo $result;
$rowsonthispage = mysql_numrows($result); //this is line 23, where the error is occuring
echo "There are $rowsonthispage rows in total";
mysql_close();
I've also tried using mysql_num_rows, and I still get the same error. Now, it's obvious there's a problem with what $result is retrieving, but why is that? The query is perfectly fine. The database name is slambook, and the table name is also slambook... is that causing problems?
What can I do to resolve this problem?
Last edited by mendhak; May 17th, 2003 at 05:43 AM.
-
May 16th, 2003, 10:47 AM
#2
Stuck in the 80s
Code:
'...
mysql_select_db("slambook") or die(mysql_error());
$abcquery = "SELECT * FROM slambook;";
$result = mysql_query($abcquery) or die(mysql_error());
echo $result;
'...
Do that and see if it produces a different error.
Also, a few things:
[list=1][*]You don't need to put a ; at the end of your MySQL queries.[*]You don't need to use mysql_close(), as this is done automatically when the script finishes executing.[/list=1]
-
May 16th, 2003, 11:03 AM
#3
Frenzied Member
yes, that semi-colon is the problem
$abcquery = "SELECT * FROM slambook;";
also it is good practice to make your names different than you db name.
-
May 17th, 2003, 05:36 AM
#4
Resolved! The die(mysql_error()) thing really helped: I saw that I had to select the db "mendhak_slambook" instead of just "slambook"
Thanks a lot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|