DJTim666 Posted August 8, 2007 Share Posted August 8, 2007 When I try to run the following code, I either get MySQL errors, or nothing shows... <?php if($act == 'view') { if (!$topic_id){ echo "<b><i><a href='$PHP_SELF?act=view&forum=$id&topic=create'>Create Topic</a></i></b><br><br>"; echo "<table border=1><tr> <td><b><center>Topic Name:</center></b></td> <td><b><center>Posted By:</center></b></td> <td><b><center>Quick Desc:</center></b></td> <td><b><center>Posted On:</center></b></td> <td><b><center>Last Poster:</center></b></td> </tr>"; $topic_sql = mysql_query("SELECT * FROM forum_topics WHERE f_id=$id"); while($row2=mysql_fetch_array($topic_sql)) { echo "<tr><td><font size=2><b><a href='$PHP_SELF?act=view&forums=$id&topic=$row2[iD]'>$row2[t_name]</font></b></font></td> <td><font size=2><u>$row2[posted_by]</u></font></td> <td><font size=1><i>$row2[t_desc]</i></font></td> <td><font size=2>$row2[time_posted]</font></td> <td><font size=2>last poster</font></td> </tr>"; } echo"</table>"; } if (isset($topic_id)){ if ($topic_id == 'create'){ $topic_name = $_POST['topic_name']; $message = $_POST['message']; if (!isset($topic_name)){ echo "<form action='$PHP_SELF?act=view&forum=$id&topic=create' method='post'> Topic Name:<br /><input type='text' name='topic_name' /><br /> Message:<br /><textarea rows='4' cols='40' name='message'></textarea><br /> <input type='submit' value='Create Topic' /> </form>"; } if (isset($topic_name)){ if (empty($topic_name) || empty($message)){ showerror("You left one of the fields blank."); } else { //this mysql query wont run V mysql_query("INSERT INTO forum_topics (f_id, t_name, t_desc, t_msg, time_posted, posted_by, last_poster) VALUES('$id', '$topic_name', 'eee', '$message', 'time()', '$Yourname', 'IDK'") or die(mysql_error()); echo "You have created the topic <b>$topic_name</b>"; } } } else { global $id, $row2; $p_message = $_POST['p_message']; $sql = "SELECT * FROM forum_posts WHERE top_id=$topic_id"; $result10 = mysql_query($sql); if (!isset($p_message)){ global $id, $row2; echo "<table border='1'>//This code won't show results V <tr><td><a href='profiles.php?user=$row2[posted_by] f'>$row2[posted_by] f</a></td><td>$row2[t_name] c</td></tr> <tr><td>Avatar</td><td>$row2[t_msg] asdfgsdfgfdgsfgfgfs</td></tr></table><br /><br />"; if (mysql_num_rows($result10) == 0){ echo "This topic has no reply's yet."; } while ($row4 = mysql_fetch_array($result10)){ echo "<table border='1' width=70%> <tr><td width='20%'><a href='profiles.php?user=$row4[post_name]'>$row4[post_name]</a></td><td>RE: HAVE TO FIX THIS...$row4[t_name]</td></tr> <tr><td>Avatar</td><td>$row4[post_msg]</td></tr></table><br /><br />"; } echo "<form action='$PHP_SELF?act=view&forum=$id&topic=$topic_id' method='post'> <br /><br />Message: <textarea cols='40' rows='4' name='p_message'></textarea><br /> <input type='submit' value='Post Message' /> </form>"; } if (isset($p_message)){ if (strlen($p_message) > 5000){ showerror("<br />Your post was more then 5000 characters."); } if (empty($p_message)){ showerror("<br />You left the message field blank."); } else { mysql_query("INSERT INTO forum_posts (post_name, post_msg, time_posted, top_id) VALUES('$Yourname', '$p_message', 'time()', '$topic_id')"); echo "You have just posted a reply. Go back and refresh to see it."; } } } } } ?> Help is appreciated. -- DJ Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/ Share on other sites More sharing options...
pranav_kavi Posted August 8, 2007 Share Posted August 8, 2007 what SQL error r u getting?? Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318381 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Author Share Posted August 8, 2007 It says that I have an error in my syntax near " at line one, check manuel blahblahblah ??? Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318383 Share on other sites More sharing options...
flappy_warbucks Posted August 8, 2007 Share Posted August 8, 2007 When I try to run the following code, I either get MySQL errors, or nothing shows... <?php if($act == 'view') { if (!$topic_id){ echo "<b><i><a href='$PHP_SELF?act=view&forum=$id&topic=create'>Create Topic</a></i></b><br><br>"; echo "<table border=1><tr> <td><b><center>Topic Name:</center></b></td> <td><b><center>Posted By:</center></b></td> <td><b><center>Quick Desc:</center></b></td> <td><b><center>Posted On:</center></b></td> <td><b><center>Last Poster:</center></b></td> </tr>"; $topic_sql = mysql_query("SELECT * FROM forum_topics WHERE f_id=$id"); while($row2=mysql_fetch_array($topic_sql)) { echo "<tr><td><font size=2><b><a href='$PHP_SELF?act=view&forums=$id&topic=$row2[iD]'>$row2[t_name]</font></b></font></td> <td><font size=2><u>$row2[posted_by]</u></font></td> <td><font size=1><i>$row2[t_desc]</i></font></td> <td><font size=2>$row2[time_posted]</font></td> <td><font size=2>last poster</font></td> </tr>"; } echo"</table>"; } if (isset($topic_id)){ if ($topic_id == 'create'){ $topic_name = $_POST['topic_name']; $message = $_POST['message']; if (!isset($topic_name)){ echo "<form action='$PHP_SELF?act=view&forum=$id&topic=create' method='post'> Topic Name:<br /><input type='text' name='topic_name' /><br /> Message:<br /><textarea rows='4' cols='40' name='message'></textarea><br /> <input type='submit' value='Create Topic' /> </form>"; } if (isset($topic_name)){ if (empty($topic_name) || empty($message)){ showerror("You left one of the fields blank."); } else { //this mysql query wont run V mysql_query("INSERT INTO forum_topics (f_id, t_name, t_desc, t_msg, time_posted, posted_by, last_poster) VALUES('$id', '$topic_name', 'eee', '$message', 'time()', '$Yourname', 'IDK')") or die(mysql_error()); // <- problem here echo "You have created the topic <b>$topic_name</b>"; } } } else { global $id, $row2; $p_message = $_POST['p_message']; $sql = "SELECT * FROM forum_posts WHERE top_id=$topic_id"; $result10 = mysql_query($sql); if (!isset($p_message)){ global $id, $row2; echo "<table border='1'>//This code won't show results V <tr><td><a href='profiles.php?user=$row2[posted_by] f'>$row2[posted_by] f</a></td><td>$row2[t_name] c</td></tr> <tr><td>Avatar</td><td>$row2[t_msg] asdfgsdfgfdgsfgfgfs</td></tr></table><br /><br />"; if (mysql_num_rows($result10) == 0){ echo "This topic has no reply's yet."; } while ($row4 = mysql_fetch_array($result10)){ echo "<table border='1' width=70%> <tr><td width='20%'><a href='profiles.php?user=$row4[post_name]'>$row4[post_name]</a></td><td>RE: HAVE TO FIX THIS...$row4[t_name]</td></tr> <tr><td>Avatar</td><td>$row4[post_msg]</td></tr></table><br /><br />"; } echo "<form action='$PHP_SELF?act=view&forum=$id&topic=$topic_id' method='post'> <br /><br />Message: <textarea cols='40' rows='4' name='p_message'></textarea><br /> <input type='submit' value='Post Message' /> </form>"; } if (isset($p_message)){ if (strlen($p_message) > 5000){ showerror("<br />Your post was more then 5000 characters."); } if (empty($p_message)){ showerror("<br />You left the message field blank."); } else { mysql_query("INSERT INTO forum_posts (post_name, post_msg, time_posted, top_id) VALUES('$Yourname', '$p_message', 'time()', '$topic_id')"); echo "You have just posted a reply. Go back and refresh to see it."; } } } } } ?> Help is appreciated. -- DJ mysql_query("INSERT INTO forum_topics (f_id, t_name, t_desc, t_msg, time_posted, posted_by, last_poster) VALUES('$id', '$topic_name', 'eee', '$message', 'time()', '$Yourname', 'IDK'") <-- there is your problem mysql_query("INSERT INTO forum_topics (f_id, t_name, t_desc, t_msg, time_posted, posted_by, last_poster) VALUES('$id', '$topic_name', 'eee', '$message', 'time()', '$Yourname', 'IDK')") Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318384 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Author Share Posted August 8, 2007 GAHH . Lol. Thnx for that fix, now read further down. It won't display the results from rows statement. Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318386 Share on other sites More sharing options...
flappy_warbucks Posted August 8, 2007 Share Posted August 8, 2007 GAHH . Lol. Thnx for that fix, now read further down. It won't display the results from rows statement. what reply (i.e. SQL Error thingie) are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318389 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Author Share Posted August 8, 2007 I'm not getting an error, it just won't show the results from the database. Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318399 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Author Share Posted August 8, 2007 hoolllaaa any help? Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318417 Share on other sites More sharing options...
DJTim666 Posted August 8, 2007 Author Share Posted August 8, 2007 Still looking for a solution... Quote Link to comment https://forums.phpfreaks.com/topic/63875-solved-problems-with-my-code/#findComment-318567 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.