Jump to content

mysql_numrows()


Sooth

Recommended Posts

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

dbba3.png

 

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

  • 3 weeks later...

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.