RaythMistwalker Posted January 4, 2010 Share Posted January 4, 2010 I am attempting to create my own PM system for members of my website. This is my current Inbox code (i already know sending works) <?php ini_set('display_errors', 'on'); error_reporting(E_ALL); //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $id=$_SESSION['SESS_MEMBER_ID']; //Create query $qry="SELECT * FROM messages WHERE to_id='$id'"; $result=mysql_query($qry) or trigger_error('Query error! Query: <pre>'.$qry.'</pre>Reason: ' . mysql_error()); $num=mysql_numrows($result); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Profile</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body text="#0000ff" link="#00a5e9" vlink="#00a5e9" alink="#00a5e9" leftmargin="2" topmargin="2" marginwidth="2" marginheight="0"> <center><h1>Member List</h1></center> <table border="1" cellspacing="2" cellpadding="2" class='tableborder'> <tr> <th><font face="Arial, Helvetica, sans-serif">From</font></th> <th><font face="Arial, Helvetica, sans-serif">Subject</font></th> <th><font face="Arial, Helvetica, sans-serif">Read</font></th> <th><font face="Arial, Helvetica, sans-serif">Delete</font></th> </tr> <? $i=0; while ($i < $num) { //Get Message Details $msg_id=mysql_result($result,$i,"msg_id"); $from_id=mysql_result($result,$i,"sender_id"); $subject=mysql_result($result,$i,"subject"); $viewed=mysql_result($result,$i,"viewed"); $qry2="SELECT * FROM members WHERE member_id='$from_id'"; $result2=mysql_query($qry2) or trigger_error('Query error! Query: <pre>'.$qry2.'</pre>Reason: ' . mysql_error()); $num2=mysql_numrows($result2); //Get Sender Information $sender_firstname=mysql_result($result2,$i,"firstname"); $sender_lastname=mysql_result($result2,$i,"lastname"; ?> //Display Message List <tr> <td><font face="Arial, Helvetica, sans-serif"><?php if ($viewed == '0') { echo "<b>"; } echo $sender_firstname." ".$sender_lastname; if ($viewed == '0') { echo "</b>"; }?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php if ($viewed == '0') { echo "<b>"; } echo $subject; if ($viewed == '0') { echo "</b>"; } ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="view-message.php?mid=<?php echo $msg_id; ?>"></font></td> <td><font face="Arial, Helvetica, sans-serif"><a href="del-message.php?mid=<?php echo $msg_id; ?>"></font></td> </tr> <?php ++$i; } echo "</table>"; ?> </body> </html> Atm i can't seem to find an arror message but it is showing up white screen. Config.php contains database details Link to comment https://forums.phpfreaks.com/topic/187111-pm-inbox-system/ Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 Line 195 is $sender_lastname=mysql_result($result2,$i,"lastname"; It should be $sender_lastname=mysql_result($result2,$i,"lastname"); (You were missing the closing brace) Link to comment https://forums.phpfreaks.com/topic/187111-pm-inbox-system/#findComment-988132 Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Author Share Posted January 4, 2010 thanks it always helps to have someone check for random errors like that. Link to comment https://forums.phpfreaks.com/topic/187111-pm-inbox-system/#findComment-988138 Share on other sites More sharing options...
RaythMistwalker Posted January 4, 2010 Author Share Posted January 4, 2010 Ok this is the code for viewing a message (view-message.php?mid=#) <?php session_start(); require_once('auth.php'); ini_set('display_errors', 'on'); error_reporting(E_ALL); $id=$_SESSION['SESS_MEMBER_ID']; $mid=$_GET['mid']; include("config.php"); mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); @mysql_select_db(DB_DATABASE) or die( "Unable to select database"); $query="SELECT * FROM messages WHERE msg_id='$mid'"; $result=mysql_query($query) or trigger_error('Query error! Query: <pre>'.$query.'</pre>Reason: ' . mysql_error()); $num=mysql_numrows($result); mysql_close(); $readqry="UPDATE messages SET viewed='1' WHERE msg_id='$mid'"; $markasread=mysql_query($readqry); $i=0; while ($i < $num) { $from_id=mysql_result($result,$i,"sender_id"); $to_id=mysql_result($result,$i,"to_id"); $subject=mysql_result($result,$i,"subject"); $message=mysql_result($result,$i,"message"); if ($to_id != $id) { echo "<h1>This isn't Your Message!</h1>"; header("location: message-inbox.php"); exit(); } $query2="SELECT * FROM members WHERE member_id='$from_id'"; $result2=mysql_query($query2) or trigger_error('Query error! Query: <pre>'.$query2.'</pre>Reason: ' . mysql_error()); $sender_firstname=mysql_result($result2,$i,"firstname"); $sender_lastname=mysql_result($result2,$i,"lastname"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>My Profile</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body text="#0000ff" link="#00a5e9" vlink="#00a5e9" alink="#00a5e9" leftmargin="2" topmargin="2" marginwidth="2" marginheight="0"> <table width=100% class=tableborder> <tr><td><b>From:</b></td><td><? echo $sender_firstname." ".$sender_lastname; ?></td></tr> <tr><td><b>Subject:</b></td><td><? echo $subject; ?></td></tr> <tr><td><B>Message:</b></td><td><? echo $message; ?></td></tr> <tr><td><form action="send-message.php?subject=<? echo $subject; ?>&sendto=<? echo $from_id; ?>" <input type"submit" value="reply"></form></td></tr></table> <?php ++$i; } </body></html> Again i've prov missed something but i'm seriously failing at finding anything. Link to comment https://forums.phpfreaks.com/topic/187111-pm-inbox-system/#findComment-988143 Share on other sites More sharing options...
JAY6390 Posted January 4, 2010 Share Posted January 4, 2010 At the end you have <?php ++$i; } </body></html> it should be <?php ++$i; } ?> </body></html> (you didn't close the php with ?> before the </body></html>) Link to comment https://forums.phpfreaks.com/topic/187111-pm-inbox-system/#findComment-988145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.