PHP - Include Results Of Function In Email Message
Hi all,
I am just starting out in the world of php and have got this far with a lot of googling. But I'm really stuck with this part now. I have a function that works perfectly for display on a page, eg <?php echo quickquote(); ?> function quickquote() { global $db; global $cart; $cart = $_SESSION['cart']; if ($cart) { $items = explode(',',$cart); $contents = array(); foreach ($items as $item) { $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1; } $quickquote[] = 'Quote Required:<br />'; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM products WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $quickquote[] = ''.$qty.''; $quickquote[] = ' x '; $quickquote[] = '' . $model . ''; $quickquote[] = ' (' . $type . '- '; $quickquote[] = ''. $basin . '- '; $quickquote[] = ''. $top . ')'; $quickquote[] = '<br />'; } $quickquote[] = 'End of Quick Quote Request'; } else { $quickquote[] = 'The quote cart is empty.'; } return join('',$quickquote); } However, i am trying to include this in an email message: if(!$error) { $messages="From: $email <br>"; $messages.="Name: $name <br>"; $messages.="Email: $email <br>"; $messages.="Phone: $phone <br>"; $messages.="Message: $message <br>"; $messages.="Quick Quote Request: $quickquote <br>"; $mail = mail($to,$subject,$messages,$headers); The email also works perfectly with the exception that the data is not there from $quickquote. I've tried all sorts of variations and suggested solutions from the web but nothing I've tried has been successful so far. It's amazing that I've got this far so I don't want to give up on it, but I'm just completely stumped ... All information and help very much appreciated. Cheers K Similar TutorialsHi I have a problem with parsing a query into the email message. Where messege shuld be a complete resoult of a query. Please take a look on code below: Code: [Select] $message = "\r\n" . 'Order details:' . '<br><br><table><tr><td>Name</td><td>Amount</td><td>Unit</td><td>Price</td><td>Total</td></tr>' . "\r\n"; /// till here is fine $result2 = mysql_query("SELECT * FROM orderslist WHERE supplier='$supplier'") or die(mysql_error()); $data = array(); $data['' . $row2['id']] = $_POST['' . $row2['id']]; $value = $_POST['' . $row2['id']]; while($row2=mysql_fetch_array($result2)) { $value = $_POST['' . $row2['id']]; if ( $value == ""){ } else { $total = $value * $row2['price']; /// this part below i have a problem with do not now how to join this part with the top part ($message) echo " <tr> <td class='H4'><strong>$row2[name]</strong></td> <td class='H4' align='center'>$value</td> <td class='H4'>$row2[unit]</td> <td class='H4'>$row2[price]</td> <td class='H4'>$total</td></tr>"; } } echo "</table>"; I think that has something to do with "\r\n" and dots, but i do not get that fully. If someone could help me on this one will be gratefull. Thank you very much in advance. Everything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); Hello. I am having some trouble with an include line. At the very top of my .php page I have the following Code: [Select] <?php include ('/IUS/Login/form_process.php'); ?> When I open the page using - localhost/IUS the rest of the page seems to load fine but at the very top I have this error message Quote Warning: include(/IUS/Login/form_process.php) [function.include]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\IUS\Index.php on line 1 Warning: include() [function.include]: Failed opening '/IUS/Login/form_process.php' for inclusion (include_path='.;C:\php5\pear') in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\IUS\Index.php on line 1 My file structure is as follows Inside my apache2.2 there is the htdocs folder inside that there is a folder called IUS IUS has the index.php file in it as well as a css style sheet and two folders. 1. folder called 'images' 2.folder called Login Login has the file 'form_process.php' so the structure looks something like this - Apache2.2 htfocs IUS - Index.php, style.css Images - BackgroundRep.png etc... Login - form_process.php, Config.php (red = folder) Where am I going wrong? I can tell that its unable to find the form_process.php file in the path that I am specifying but I am unsure why? Thank you in advance for any help. this is my code but i want to have a pice so if their is no results the it will put in a message like "No Results" but i cant figger it out <?php $host="localhost"; $username="xxxxx"; $password="xxxxxx"; $db_name="xxxxxxx"; $tbl_name="Shows"; // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name WHERE Month='April'and Year='2011' order by Day asc "; $result=mysql_query($sql); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td> <table width="400" border="1" cellspacing="0" cellpadding="3"> <?php while($rows=mysql_fetch_array($result)){ ?> <span class="elevenbold"><? echo $rows['Day']; ?> <? echo $rows['Month']; ?> <br><strong class="elevenboldblue"><? echo $rows['Song']; ?></strong><br><? echo $rows['Data']; ?></span><br><br> <?php } ?> </table> </td> </tr> </table> <?php mysql_close(); ?> Hi all I have a script that creates an email message, but I want to add a link to it to take the user to PayPal. Here's my code: $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=utf-8\n"; $headers .= "From: '".$_SERVER['HTTP_HOST']." Booking System' <info@".$_SERVER['HTTP_HOST']."> \n"; $subject = "Booking Confirmed!"; $message = "Dear ".$name.",<br /> <br /> This is confirmation of your booking. <br />"; $message .= "<table cellspacing=0 cellpadding=4 border=0>"; $message .= "<tr><td>Date</td><td>Time From</td><td>Time To</td></tr>"; $message .= $tempVar; $message .= "</table>"; $message .="<br />Reservation Status: Confirmed<br/>"; $message .="<br /><br />Kind Regards, <br /> ".$_SERVER['HTTP_HOST']." Team"; mail($email,$subject,$message,$headers); Can anyone help me add a line to the above to add the link in? Many thanks Pete I have a page which contains php scripts for the values that will be send through email. my problem is when i send it, it doesn't read the php script. The body only read plain html text. how can I output my php script values through html Trying to use an include() in a script to send an email, not working out. Basically I have a pretty drastic page I've formatted out and I want it to be shipped out in an email in that format. I thought it would be simple to get an include in a php code to email but the email works.. and doesn't have anything in it. I've tried with and without quotes, any help appreciated. Code: [Select] <html> <body> <? //change this to your email. $to = "me@me.com"; $from = "me@me.com"; $subject = "stuff"; $message="<?php include("another.php"); ?>" $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; //options to send to cc+bcc //$headers .= "Cc: [email]maa@p-i-s.cXom[/email]"; //$headers .= "Bcc: [email]email@maaking.cXom[/email]"; // now lets send the email. mail($to, $subject, $message, $headers); echo "Message has been sent....!"; ?> </html> </body> Hi I built a really simple customer review form https://kickasssoftwear.uk/dev/reviews.html (it's only been optimised for mobile view so far) and it works using the php mail script on this page https://kickasssoftwear.uk/dev/empty2.php - the emails are being sent to me and the format of the emails is OK, and the form redirects to the empty2 page with a mailsent message in the address bar. I know I can leave that page as is and write a nice thank you message in the html - but what I really want to do is have the customers name there too, Thanks 'name' your review has been sent, but I can't get it to work - it's been 4 whole days now and I really need to eat & sleep! Please if anyone has suggestions or advice for a noob, please help. Thanks I have a bit of php code to send me an email when someone logs in to my site. I want to include the person's name and two other bits from my database, but I can't get the formatting correct. I keep getting errors when I try to load the page. Here's the code which obviously has mistakes. The first code works, it's the second one that does not work for the $message line .
if (mysql_num_rows($exe) == 1) { $message_m = "Someone with RefCode ".$RefC." has viewed the homepage for the first time."; mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m); setcookie("has_entered_correct_refcode", "true", time()+27000000, "/"); setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/"); header("Location: /index.php"); die(); if (mysql_num_rows($exe) == 1) { $message_m =" "'.$_POST['fname'].'," with RefCode "'.$RefC.'," and refund amount of "'.$_POST['refvalact'].'," has viewed the homepage."; mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m); setcookie("has_entered_correct_refcode", "true", time()+27000000, "/"); setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/"); header("Location: /index.php"); die(); }Thanks for any help to resolve this. Hi there, I have created a simple php email form, which works just fine, but now I have been asked to include an image of the company logoat the top of the email the user receives. I am new to php, so my first thought was that I could just add a line that had the path to the image on the server like so: $mailimg = 'http://domain.ca/images/image.gif'; and then call it in the $message: $headers = "From: $email\r\n\r\n"; $subject = "Cancellation Request Form from Website"; $message .= "$mailimg"; $message = "Notice Date: $ndate\r Brokerage: $brokerage\r but that doesnt seem to be working for me. I get the email message, but with no image attached. Any ideas on how I can simply do this. Again I am new to php, so the easier the better Here is my code Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF']; ?> <form name="form1" method="post" action="<?php echo $me;?>"> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="../images/dot_trans.gif" width="2" height="2" /><br /> <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><img src="../images/dot_trans.gif" width="10" height="10" /><br /> <table width="100%" height="183" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td width="147"><strong>Notice Date</strong></td> <td width="263"><span id="sprytextfield1"> <label> <input name="ndate" type="text" id="ndate" size="40" /> </label> <span class="textfieldRequiredMsg">Please Enter Notice Date.</span></span></td> <td width="127"><strong>Broker Name</strong></td> <td width="271"><span id="sprytextfield7"> <input name="brokername" type="text" id="brokername" size="40" /> <span class="textfieldRequiredMsg">Please Enter Broker Name.</span></span></td> </tr> <tr> <td><strong>Brokerage</strong></td> <td><span id="sprytextfield2"> <label> <input name="brokerage" type="text" id="brokerage" size="40" /> </label> <span class="textfieldRequiredMsg">Please Enter Brokerage</span></span></td> <td><strong>Phone Number</strong></td> <td><span id="sprytextfield8"> <input name="pnum" type="text" id="pnum" size="40" /> <span class="textfieldRequiredMsg">Please Enter A Phone Number.</span></span></td> </tr> <tr> <td><strong>RJFC Contract #</strong></td> <td><span id="sprytextfield3"> <input name="rjfccon" type="text" id="rjfccon" size="40" /> <span class="textfieldRequiredMsg">Please Enter A Contact Number</span></span></td> <td><strong>E Mail</strong></td> <td><span id="sprytextfield9"> <input name="email" type="text" id="email" size="40" /> <span class="textfieldRequiredMsg">Please Enter A E Mail Address.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td> </tr> <tr> <td height="28"><strong>Insured</strong></td> <td><span id="sprytextfield4"> <input name="insured" type="text" id="insured" size="40" /> <span class="textfieldRequiredMsg">Please Enter Name of Insured</span></span></td> <td rowspan="3" valign="top"><strong>Reason for cancellation</strong></td> <td rowspan="3"><label for="cancel"></label> <span id="sprytextarea1"> <textarea name="cancel" id="cancel" cols="30" rows="5"></textarea> <span class="textareaRequiredMsg">Please enter a reason for cancellation.</span></span></td> </tr> <tr> <td height="28"><strong>Policy #</strong></td> <td><span id="sprytextfield5"> <input name="polnum" type="text" id="polnum" size="40" /> <span class="textfieldRequiredMsg">Please Enter A Policy Number.</span></span></td> </tr> <tr> <td height="22"> </td> <td> </td> </tr> </table> <br /> <br /> <table width="822" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="569"><div align="left">RJFC will process the Cancellation Request upon receipt. All documents will be sent to the Insured by registered mail. A fax or e-mail copy of the documents will be sent to the Broker and Insurer. </div> <p> </p></td> </tr> </table> <table width="97%" border="0" align="center" cellpadding="3" cellspacing="3"> <tr> <td width="801"><div align="center"> <label> <input name="Submit" type="submit" value="Submit" /> </label> <label> <input name="reset" type="reset" id="reset" value="Reset" /> </label> </div></td> </tr> </table> <img src="../images/dot_trans.gif" width="10" height="10" /></td> </tr> </table> <img src="../images/dot_trans.gif" width="2" height="2" /></td> </tr> </table> </form> <?php } else { error_reporting(0); $recipient = 'contact@justspiffy.ca'; $ndate = stripslashes($_POST['ndate']); $brokerage = stripslashes($_POST['brokerage']); $rjfccon = stripslashes($_POST['rjfccon']); $insured = stripslashes($_POST['insured']); $polnum = stripslashes($_POST['polnum']); $brokername = stripslashes($_POST['brokername']); $pnum = stripslashes($_POST['pnum']); $email = stripslashes($_POST['email']); $cancel = stripslashes($_POST['cancel']); $mailimg = 'http://rjfc.ca/new/images/quote.gif'; putenv ("QMAILUSER=contact"); putenv ("QMAILNAME=contact@justspiffy.ca"); putenv ("QMAILHOST=justspiffy.ca"); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: multipart/mixed;charset=us-ascii\r\n"; $headers .= "From: contact@justspiffy.ca"; $headers = "From: $email\r\n\r\n"; $subject = "Cancellation Request Form from Website"; $message .= "$mailimg"; $message = "Notice Date: $ndate\r Brokerage: $brokerage\r RJFC Contact Number: $rjfccon\r Insured: $insured\r Policy Number: $polnum\r Broker Name: $brokername\r Phone Number: $pnum\r Email: $email\r Reason for cancellation: $cancel\r "; mail($recipient, $subject, $message, $headers); if (!mail) { echo "Message failed to send"; } else { echo nl2br ("<center><br><br><br><br><br><br><br><br><br><br>Thank you. Your request has been sent. A representative from RJFC will contact you shortly.<br><br><br><br><br><br><br><br><br><br></center>"); } } ?> Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); I have an auto responder in a php order form with the phrase "Our web sites uses a secure order form for customers to purchase products, and services..." When the message is sent, the word 'services' comes out like this: "...products, and 1s." Each instance of the word 'services' is changed to '1s'. Any ideas?
Hi, I got this script which I would like to send a message to all email addresses in the database or send to approved members only. Once I got the first part of this script working I can get the rest to work when sending to approved members. Here is the form which passes the message to the script. Code: [Select] <?php include_once("data/server.php"); $all = 'unchecked'; $approved = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['Mailto']; if ($selected_radio == 'all') { $all = 'checked'; } else if ($selected_radio == 'approved') { $approved = 'checked'; } } ?> <div id="pageNav"> <div id="sectionLinks"> <a href="admin.php?cmd=database&username=admin">Database</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=editTemplate&username=admin">Templates </a> <a href="admin.php?cmd=email&username=admin">Email</a> <a href="admin.php?cmd=messaging&username=admin">Messaging</a> <a href="admin.php?cmd=protected&username=admin">Protected Directory</a> <a href="admin.php?cmd=filesanddir&username=admin">Files and Directories</a> <a href="admin.php?cmd=usertracking&username=admin">User Tracking</a> <a href="admin.php?cmd=advanced&username=admin">Advanced</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=subscriptions&username=admin">Subscriptions</a> <a href="admin.php?cmd=applications&username=admin">Applications</a> <a href="admin.php?cmd=searchForms&username=admin">Search Form Builder</a> <a href="admin.php?cmd=categories&username=admin">Categories</a> <a href="admin.php?cmd=phpBB&username=admin">phpBB</a> <a href="admin.php?cmd=mySQL&username=admin">MySQL</a></div> </div> <div id="content"> <div class="page"> <form action=templates/admin/msgtest.php method=POST> <table> <tr> <td>Your Message:</td> <tr><td> </td><td> </td></tr> <tr><td><TEXTAREA NAME="message" COLS=40 ROWS=6></TEXTAREA></td></tr> </table> <table> <tr> <td><input type = 'Radio' Name ='Mailto' value= 'yes' <?PHP print $all; ?> </td> <td>Send Message to all members</td> </tr> <tr> <td><input type = 'Radio' Name ='Mailto' value= 'yes' <?PHP print $approved; ?> </td> <td>Send Message to Approved members only</td> </tr> <tr><td colspan=2><input type=submit name=submit value=Submit></td></tr> </table> </form> </table> </div> </div> </div> And here is the code I have got so far but it doesnt work Code: [Select] <?php include_once("../../data/server.php"); include("../../data/mysql.php"); if (isset($_POST['Submit1'])) { $selected_radio = $_POST['Mailto']; if ($selected_radio == 'all') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $q2 = "select * from games_newsletter "; $result = mysql_query("SELECT email FROM profiles"); while ($email = mysql_fetch_assoc($result)) { $to = $email; $subject = "Test Message"; $body = "This is a test message"; $headers = "From: payments@tropicsbay.co.uk\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { // Redirect back to manage page header("Location: admin.php?cmd=messaging"); } else { echo "Approval Message Failed"; } } mysql_close($con); } } ?> As always, any help is much appreciated Paul Hi all I have a script that I have patched together and got to work in pieces. I'm up to the last part. I have the form working and emailing. It also will upload an image by itself and put it in a folder. Now i just need to tie those together and have the image put in the email as an attachment then deleted from server. I have it at a stage where it sends me the users details.. and it tries to send the photo but it comes through as junk txt. I think its the MIME encoding stuff that I have wrong.. not sure? Here's what I have so far. Code: [Select] $attachment = $path_of_uploaded_file; $fileatt = $attachment; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $start= strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1; $fileatt_name = substr($attachment, $start, strlen($attachment)); // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; // create email headers $headers .= 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); Thanks Wolfsta Hello Guys,
I need your help as many PHPers here is more experienced in PHP coding than me. I have specific project I am working on and need a piece of code that can send an email from HTML form using PHP to the email address that is entered manually on the form, instead of standard sent to PHP code that is fixed within PHP script and executed during submission. I want sth that can grab manually enetered recipient's e-mail address, paste it to the PHP code and then use it to send the email to the recipient, instead of fixed sent to code. Something would say dynamically changed during the entry that can inject into PHP code the new address email entered on the form and then submit to it. Any ideas will be great.
Thanks.
Edited March 27, 2019 by slawotrend I am trying to eliminate this issue but I have had no luck here is my current code: Code: [Select] $from = 'help@my.com'; $body = "<html>\n"; $body .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif;\">\n"; $body .= $message; $body .= "</body>\n"; $body .= "</html>\n"; $boundary = uniqid('np'); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: $from"; $headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/alternative;\n" ." boundary=\"{$mime_boundary}\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; \n" . "Content-Transfer-Encoding: 7bit\n\n" . $body . "\n\n" . "--{$mime_boundary}--\n"; mail($to, $subject, $message, $headers, '-f'.$from); I have tried adding the plain text part but nothing has worked, could someone else look at this and show me what I need to add so that it has the text/plain MIME part as well? Hey, im trying to create a little function that displays how many unread messages a user has this is my function Code: [Select] function unread() { $sql_pm_r = mysql_query("SELECT COUNT(*) FROM messages WHERE reciever=" . $user . " AND recieved='0'"); $num_rows = mysql_num_rows($sql_pm_r); $sql_pm_check = mysql_query("SELECT id FROM messages WHERE reciever=" . $user . " AND recieved='0' LIMIT 1"); $num_new_pm = mysql_num_rows($sql_pm_check); if ($num_new_pm > 0) { $pms = '<a href="inbox.php" >('.$num_rows.')</a>'; } else { $pms = '<a href="inbox.php" >(0)</a>'; } echo $pms; }and i'm calling it on the index page as normal like Code: [Select] unread(); However not matter how many unread messages i have, i always get (0), this is how my sql table looks id reciever sender subject message recieved Hi everyone, |