Sooth Posted November 4, 2007 Share Posted November 4, 2007 Hi! I'm making a PMs script for an website and I get an error regarding mysql_numrows. I dont know if the error is in the database or in the script, so I'm showing them both. Here is the database table <i>pms</i>: Here is the script: <?php mysql_connect($db_hostname,$db_username,$db_password); @mysql_select_db($db_database)or die($db_error); $query="SELECT * FROM pms WHERE to='$_SESSION[username]'"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> This is the error: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/a3033866/public_html/myprofile_messages.php on line 14 Line 14 is the one where mysql_numrows is called. Link to comment https://forums.phpfreaks.com/topic/75993-mysql_numrows/ Share on other sites More sharing options...
victor_ar Posted November 21, 2007 Share Posted November 21, 2007 hello, try this: <?php $connection = mysql_connect($db_hostname,$db_username,$db_password); @mysql_select_db($db_database, $connection)or die($db_error); $query="SELECT * FROM pms WHERE to = '" . $_SESSION["username"] . "'"; $result=mysql_query($query, $connection); $num=mysql_numrows($result); mysql_close($connection); ?> Link to comment https://forums.phpfreaks.com/topic/75993-mysql_numrows/#findComment-395902 Share on other sites More sharing options...
victor_ar Posted November 21, 2007 Share Posted November 21, 2007 sorry, also use mysql_num_rows instead mysl_numrows Link to comment https://forums.phpfreaks.com/topic/75993-mysql_numrows/#findComment-395905 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.