kiana Posted May 9, 2007 Share Posted May 9, 2007 ive just started learning php and mysql ive got most of this script running fine but i cant figure out how to put the poster after the message and then have a line break any help please mysql_select_db("message1") or die(mysql_error()); if (isset($_POST['mess'])) { $message = $_POST['mess']; $poster = $_POST['poster']; $sql = "insert into message set mess='$message', poster='$poster', date=CURDATE()"; if(@mysql_query($sql)) { echo '<p>'; } else { echo '<font face="verdana" size="1">error adding message: ' . mysql_error() . ''; } } $result = @mysql_query('SELECT mess FROM message'); if (!$result) { exit('error performing query:' . mysql_error(). ' '); } while ($row = mysql_fetch_array($result)) { echo '<font face="verdana" size="1"> ' . $row['mess'] .' - '; } $result = @mysql_query('SELECT poster FROM message'); if (!$result) { exit('error performing query:' . mysql_error(). ' '); } while ($row = mysql_fetch_array($result)) { echo '<font face="verdana" size="1"> ' . $row['poster'] .' - '; } echo '<center><a href="'. $_SERVER['PHP_SELF'] . '?addmessage=1">add a message</a>'; endif; ?> Quote Link to comment https://forums.phpfreaks.com/topic/50702-solved-help-with-a-comment-system/ Share on other sites More sharing options...
only one Posted May 9, 2007 Share Posted May 9, 2007 $sql = "insert into message set mess='$message', poster='$poster', date=CURDATE()"; does this work?? try this, your probobally not seeing an error because your @ infront of the mysql_query $sql = "INSERT INTO clan_apps (`mess`, `poster`, `date`)VALUES('$message','$poster', 'CURDATE()')"; Quote Link to comment https://forums.phpfreaks.com/topic/50702-solved-help-with-a-comment-system/#findComment-249233 Share on other sites More sharing options...
paul2463 Posted May 9, 2007 Share Posted May 9, 2007 you are running two queries from the same table to get two different things, run one query $result = mysql_query("select mess, poster FROM message"); then one while loop will work while ($row = mysql_fetch_array($result)) { echo '<font face="verdana" size="1"> '' . $row['mess'] .' - ' . $row['poster']; } Quote Link to comment https://forums.phpfreaks.com/topic/50702-solved-help-with-a-comment-system/#findComment-249237 Share on other sites More sharing options...
kiana Posted May 9, 2007 Author Share Posted May 9, 2007 cheers the last one worked a treat Quote Link to comment https://forums.phpfreaks.com/topic/50702-solved-help-with-a-comment-system/#findComment-249265 Share on other sites More sharing options...
kiana Posted May 9, 2007 Author Share Posted May 9, 2007 another small problem <?Php $result = @mysql_query("select news, poster, newsdate FROM message ORDER BY date DESC LIMIT 5"); while ($row = mysql_fetch_array($result)) { echo '<b>' . $row['poster'] .' - '. $row['date']. '<br></b>' . $row['News'] . '<p>'; } ?> thats using the same code you gave me before but come up with an error on the mysql_fetch_array line any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/50702-solved-help-with-a-comment-system/#findComment-249297 Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 Seriously stop surpressing errors it does no good (the @ sign) $result = mysql_query("select news, poster, newsdate FROM message ORDER BY `newsdate` DESC LIMIT 5") or DIE(mysql_error()); // the or die gives you a helpful error if one occurs. Date is a reservered word that and since you were pulling it out by "newsdate" in the select portion I assumed you mean that. If you did not and you did mean date enclose it in the tick marks ` ` which will override the reserved word portion Quote Link to comment https://forums.phpfreaks.com/topic/50702-solved-help-with-a-comment-system/#findComment-249311 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.