Jump to content

Recommended Posts

Hi,

 

As youve probably notice im not that good with php however i know a bit.

 

mysql_select_db("wowbasec_class", $connection);

$result = mysql_query("SELECT * FROM location");
$result1 = mysql_query("SELECT * FROM char");

$rows = mysql_num_rows($result);

 

I have this at the moment but if i want to put in another count for another table in the same database how do i do that without any errors?

Link to comment
https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/
Share on other sites

$rows1 = mysql_num_rows($result1);

 

And if you just need to count the rows without actually retrieving them use something like this

 

$result = mysql_query("SELECT COUNT(*) AS locationCount FROM location");
$row = mysql_fetch_array($result);
$locationCount = $row['locationCount'];

$result1 = mysql_query("SELECT COUNT(*) AS charCount FROM char");
$row1 = mysql_fetch_array($result);
$charCount = $row['charCount'];

What i want is i want to display...

 

#Locations #Characters etc.

 

But whenever i put in

 

$result2 = mysql_query("SELECT * FROM char");

$rows2 = mysql_num_rows($result2);

 

Extra i get this error...

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wowbasec/public_html/index.php on line 10

 

char is MySQL reserved word. You shouldn't call your table like that... but if you did, use backticks around it's name

$result2 = mysql_query("SELECT * FROM `char`");

 

Here's full list of reserved words

http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.