Jump to content

Recommended Posts

I am trying to get a count of how many messages a user has in the database this is the code I have:

 

$mail = mysql_query("select count(*) from mail where to='$username'");
$inbox = mysql_result($mail);
echo("View Inbox ($inbox)<br/>");

 

I get an error with this Warning: Wrong parameter count for mysql_result() what am I doing wrong?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/167939-solved-output-count/
Share on other sites

see what error you get

$SQL = "select count(*) from mail where to='$username'";
$mail = mysql_query($SQL) or die(mysql_error().$SQL);
$inbox = mysql_result($mail, 0)
echo("View Inbox ($inbox)<br/>");

 

remember TO check for reserved words, these can be resolved via back ticks (`) but its better to change the field name

 

EDIT: MySQL 5.1 section 8.3. Reserved Words

Link to comment
https://forums.phpfreaks.com/topic/167939-solved-output-count/#findComment-885747
Share on other sites

Welcome, this problem can be common hence the reason I pointed to the link, i think its better to learn then just giving the solution.

 

Light a man a fire your keep him warm for a night, light a man on fire your keep him for for the rest of his life!

Link to comment
https://forums.phpfreaks.com/topic/167939-solved-output-count/#findComment-885758
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.