Connect to a MySQL database and count the number of rows.

Posted by Hugo on Stack Overflow See other posts from Stack Overflow or by Hugo
Published on 2010-06-17T13:12:54Z Indexed on 2010/06/17 13:23 UTC
Read the original article Hit count: 243

Filed under:
|
|
|
|

Hi there!

I need to connect to a MySQL database and then show the number of rows. This is what I've got so far;

    <?php

include "connect.php";


db_connect(); 

$result = mysql_query("SELECT * FROM hacker"); 
$num_rows = mysql_num_rows($result); 


echo $num_rows; 

?>

When I use that code I end up with this error;

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Documents and Settings\username\Desktop\xammp\htdocs\news2\results.php on line 10

Thanks in advance :D

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database