Hey, im having a problem getting this email check to work it basicly prints out in a very origional way how manny eails you have...
Check Inbox (3)

Heres the code:

$find_content = "SELECT * FROM email WHERE email_too_id = '$userid' OR all = 'true'";
$content_sql = mysql_query($find_content) or die ("Couldnt send sql for email content".mysql_error());
$email_ammount = mysql_num_rows($content_sql);
if ($email_ammount == 0) {
$num = 0;
}
else {
$num = $email_ammount;
}

However i am getting the following error message :

Couldnt send sql for email contentYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all = ''' at line 1

The check for all just checks weither someones sent an email in which all people will receive on my website.

Please help, its really annoying me :D

Chears

all is a reserve word. It is not a good practive to use reserve words in query. If it is required to use such words, then simply use back ticks (`) around them as I did in the below query.

$find_content = "SELECT COUNT(*) AS total_mails FROM email WHERE email_too_id = '$userid' OR `all` = 'true'";
$content_sql = mysql_query($find_content) or die ("Couldnt send sql for email content".mysql_error());
$email_ammount = mysql_fetch_array($content_sql);
$num = intval($email_ammount["total_mails"]);

I have rewritten the code for you to work efficiently. There is no need to use mysql_num_rows(). This takes much more time and resources when you run it on a large result set.

ahhh!!!
reserved words, i didnt even consider that
thankyou so much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.