Jump to content



  • Please log in to reply
2 replies to this topic

#1 tomfmason

  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 12 July 2006 - 12:19 PM

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 $message_check messages. I am using this in the html
<p><?php echo $text; ?></p>
to display $text.

Any suggestions on how to accomplish this would be great.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux

#2 OOP

  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts
  • LocationSaudi Arabia

Posted 12 July 2006 - 12:26 PM

Hi there;

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

<?php echo'The man who makes no mistakes does not usually make anything'; ?>

#3 brown2005

  • Members
  • PipPipPip
  • Advanced Member
  • 943 posts

Posted 12 July 2006 - 12:41 PM

yeah $text = "You have <b>$message_check</b> new messages";

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users