rofl90 Posted March 7, 2008 Share Posted March 7, 2008 Eell here the details: it just doesn't display none come up, it gives me the tr, tds above th while though and the rest. also i echoed my id and it defintelely is 1. heres my table; id title message from to time email extra 1 lol loooooltest 2 1 1204917710 and heres my code: <?php session_start(); header("Cache-control: private"); if ($_SESSION["access"] != "granted") { header("Location: index.php"); } else { $dbhost = 'x'; $dbuser = 'x'; $dbpass = 'x'; $dbname = 'x'; mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname); $action = $_GET['action']; if(isset($action)) { if($action == 'send') { $title = $_POST['title']; $to = $_POST['to']; $from = $_SESSION["user"]; $message = $_POST['message']; $time = time(); $queryid = "SELECT id from users where user=$from"; $resultastic = mysql_query($queryid) or die(mysql_error()); $queryid2 = "SELECT id from users where user=$to"; $resultasticar = mysql_query($queryid2) or die(mysql_error()); $querymessage = "insert into messages (title, message, from, to, time) VALUES ('$title', '$message', '$resultastic', '$resultasticar', '$time'"; if(mysql_query($querymessage)) { echo "Message sent!"; } } if($action == 'delete') { $title = $_GET['title']; $querydel = "delete from messages where title='$title'"; $resultdel = mysql_query($querydel) or die(mysql_error()); echo "Message deleted!"; } } ?> <!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" /> <meta http-equiv="description" name="description" content="<?php $result = mysql_query("SELECT * FROM settings") or die(mysql_error()); $row = mysql_fetch_array($result);echo $row['description'];?>" /> <meta http-equiv="keywords" name="keywords" content="<?php $result = mysql_query("SELECT * FROM settings") or die(mysql_error()); $row = mysql_fetch_array($result);echo $row['keywords'];?>" /> <title><?php $result = mysql_query("SELECT * FROM settings") or die(mysql_error()); $row = mysql_fetch_array($result);echo $row['sitetitle'];?> » Private Messages</title> <link href="http://www.codeetech.com/backend/css/style.css" rel="stylesheet" type="text/css" /> <link href="http://www.codeetech.com/backend/js.php" type="text/javascript"/> </head> <body> <div class="container"> <!-- container START --> <div class="innercontainer"> <!-- innercontainer START --> <div class="toppart"> <!-- toppart START --> <div class="innertoppart"> <!-- innertoppart START --> <div class="logo"> <!-- logo START --> <img src="../go/images/headerimg.gif" alt="Codeetech" width="200" height="69" /> </div> <!-- logo END --> <div class="myslogan"> <!-- myslogan START --> <div class="innermyslogan"> <!-- innermyslogan START --> Welcome, <?php echo $_SESSION['user']; ?>. </div> <!-- innermyslogan END --> </div> <!-- myslogan END --> </div> <!-- innertoppart END --> </div> <!-- toppart END --> <div class="backlinker"> <!-- backlinker START -->Backend Home </div> <!-- backlinker END --> <div class="stuff"> <!-- stuff START --> <div class="leftmargin"> <!-- leftmargin START --> <div class="indentmebitch"> <!-- indentmebitch START --> <table border="0" cellpadding="2" cellspacing="4"> <?php $toid = $_SESSION["id"]; echo "<tr> <th bgcolor='#F9F9F9'>Title</th> <th bgcolor='#F5F5F5'>From</th><th bgcolor='#F1F1F1'>Time</th></tr>"; echo $toid; $querya = "SELECT * FROM messages where to='$toid'"; $resulta = mysql_query($querya); while($row = mysql_fetch_array($resulta)) { echo "<tr><td bgcolor='#E5E5E5'><div align='center'><a href='readmessage.php?title="; echo $row['title']; echo "&to="; echo $row['to']; echo "'>"; echo $row['title']; echo "</a>"; echo "</div></td><td bgcolor='#EBEBEB'><div align='center'>"; echo $row['from']; echo "</div></td><td bgcolor='#ECECEC'><div align='center'>"; echo date('l, jS \of F Y \a\t g:iA',$row['time']); echo "</div></td></tr>"; } ?> </table> </div> <!-- indentmebitch END --> </div> <!-- leftmargin END --> <div class="right"> <!-- right START --> <div class="navigation"> <!-- nav START --> Backend: </div> <div class="nav-link"><a href="http://www.codeetech.com/backend/">Backend Home</a></div> <div class="nav-link"><a href="http://www.codeetech.com/">View site</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/pagemanager.php">Page Manager</div> <div class="nav-link"><a href="http://www.codeetech.com/backend/clientmanager.php">Client Manager</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/newsmanager.php">News Manager</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/uploadfile.php">Upload File</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/settings.php">Settings</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/profile.php">My Profile</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/usermanagement.php">User Management</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/privatemessages.php">Private Messages</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/sitenavigation.php">Site Navigation</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/testimonials.php">Testimonials</a></div> <div class="nav-link"><a href="http://www.codeetech.com/backend/logout.php">Logout</a></div> </div> <!-- nav END --> <!-- right END --> </div> <!-- stuff END --> </div> <div class="footer"> <?php $result = mysql_query("SELECT * FROM settings") or die(mysql_error()); $row = mysql_fetch_array($result); echo $row['footer']; ?> <!-- innercontainer END --> </div> <!-- container END --> </body> </html> <?php } ?> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 7, 2008 Author Share Posted March 7, 2008 bump Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 7, 2008 Author Share Posted March 7, 2008 Its saying You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to='1'' at line 1 theres a few up and down: <?php $toid = $_SESSION["id"]; echo "<tr> <th bgcolor='#F9F9F9'>Title</th> <th bgcolor='#F5F5F5'>From</th><th bgcolor='#F1F1F1'>Time</th></tr>"; echo $toid; $querya = "SELECT * FROM messages where to='$toid'"; $resulta = mysql_query($querya) or die(mysql_error()); while($row = mysql_fetch_array($resulta)) { echo "<tr><td bgcolor='#E5E5E5'><div align='center'><a href='readmessage.php?title="; echo $row['title']; echo "&to="; echo $row['to']; echo "'>"; echo $row['title']; echo "</a>"; echo "</div></td><td bgcolor='#EBEBEB'><div align='center'>"; echo $row['from']; echo "</div></td><td bgcolor='#ECECEC'><div align='center'>"; echo date('l, jS \of F Y \a\t g:iA',$row['time']); echo "</div></td></tr>"; } ?> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 7, 2008 Author Share Posted March 7, 2008 bumpp Quote Link to comment Share on other sites More sharing options...
revraz Posted March 7, 2008 Share Posted March 7, 2008 TO is a mysql reserved word, either use `backticks` around it or change the field name. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 7, 2008 Author Share Posted March 7, 2008 ahh, omg all that and that happens.. lol kk. is FROM a reserved word? Quote Link to comment Share on other sites More sharing options...
rofl90 Posted March 7, 2008 Author Share Posted March 7, 2008 i mean in my context saying where from='x' would that not work? Quote Link to comment Share on other sites More sharing options...
revraz Posted March 7, 2008 Share Posted March 7, 2008 Yep http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.