elviapw Posted February 9, 2009 Share Posted February 9, 2009 I'm new to PHP and i'm creating a password-protected blog. the only page that isn't working is the "posted.php" page, which posts the information after a user has logged in. the problem with the code is in query2, because the echo "yes", which I'm using to test the query, does not print. The page should print YES, YES, and then VIEW POST; it should also add the "post" and "title" to the archive (archive.php). I don't think I'm using the right function to add the information to the database. Help! here's the code: <html> <head> <title>posted</title> </head> <body> <table> <thead>YES</thead> <tbody> <?php $title = $_REQUEST["title"]; $post = $_REQUEST["post"]; $dbh = mysqli_connect("--", "--", "--", "--"); $sql = "INSERT INTO Posts (Number,Title,Content) VALUES(null,'$title', '$post');"; $query = mysqli_query($dbh,$sql); $newpost = "SELECT Number,Title,Content FROM Posts ORDER BY Number DESC"; $query2 = mysqli_query($dbh,$newpost); if($query2) { echo "YES"; $feed = mysqli_fetch_assoc($query2); $number = $feed['Number']; $title = $feed['Title']; $post = $feed['Content']; echo"VIEW POST\n"; echo "</tbody>"; } ?> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
mike12255 Posted February 9, 2009 Share Posted February 9, 2009 connect before this peice of code: $title = $_REQUEST["title"]; $post = $_REQUEST["post"]; its not a long peice of code, but please remember to put it in code tags, ill display below ** actually tags do not include the "." [code.][./code] html> <head> <title>posted</title> </head> <body> <table> <thead>YES</thead> <tbody> <?php $title = $_REQUEST["title"]; $post = $_REQUEST["post"]; $dbh = mysqli_connect("--", "--", "--", "--"); $sql = "INSERT INTO Posts (Number,Title,Content) VALUES(null,'$title', '$post');"; $query = mysqli_query($dbh,$sql); $newpost = "SELECT Number,Title,Content FROM Posts ORDER BY Number DESC"; $query2 = mysqli_query($dbh,$newpost); if($query2) { echo "YES"; $feed = mysqli_fetch_assoc($query2); $number = $feed['Number']; $title = $feed['Title']; $post = $feed['Content']; echo"VIEW POST\n"; echo "</tbody>"; } ?> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
elviapw Posted February 9, 2009 Author Share Posted February 9, 2009 I'm sorry. I'll re-post. 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.