Jump to content

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

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.