Jump to content


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



Recommended Posts

This should be a rather simple fix. I am trying to put the number of matches from a search into a variable
like this

$sql= sprintf("SELECT COUNT(*) AS message_check FROM `messages` WHERE `status` ='new'");
$res= mysql_query($sql) or die(mysql_error());
$message_check= mysql_result($res, 0, 'message_check');

if ( $message_check == 0 ) {
    $text ='You have no new messages';
}elseif ( $message_check == 1) {
      $text ='You have <b>1</b> new message';
      $text ='You have <b>$message_check</b> new messages';    

The only problem is, in the html, it just displays the $text like this: You have [b]$message_check[/b] messages. I am using this in the html [code=php:0]<p><?php echo $text; ?></p>[/code] to display $text.

Any suggestions on how to accomplish this would be great.

Share this post

Link to post
Share on other sites
Hi there;

use double quotes instead of the single quotes that your are currently using. It should look like:
[code]$text ="You have <b>$message_check</b> new messages";[/code]

Share this post

Link to post
Share on other sites


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.