garcon Posted March 16, 2008 Share Posted March 16, 2008 Hi, just started learning php and I've created a little practice website which has 5 "venues" you can post reviews for. You need to sign up to post a review but you don't need to login (so no sessions etc.). There's fields for email/password on the add review form. This is the last script I need to get working then my little site is finished.... When I try to post a review the server returns nothing for this page not even the HTML, previously this has been because I've done something like miss a semi-colon, but I've scoured this script and can't see anything like that. So I guess my questions.. 1. Is there a simple and comprehensive guide out there for installing php/mysql on my home machine 2. Will the above allow me to step through the php line by line so I can debug? 3. Is it just an idiotic mistake like a missing semi-colon in the code below that I can't see? <?php //connection include("connect.php"); //create header escape string thing $returntoform = "Location: add_review.php?id=" . $_POST["venue_id"]; if(isset($_POST["submit"]) { if(empty($_POST["email"]) || empty($_POST["password"]) || empty($_POST["title"]) || empty($_POST["body"])) { echo "Form not completed."; header($returntoform); exit; } //check user details $email = $_POST["email"]; $password = $_POST["password"]; $sql = "SELECT user_id, password FROM user WHERE email='$email'"; $result = mysql_query($sql); if(!$result) { echo "email address not found!"; header($returntoform); exit; } $user = mysql_fetch_object($result); if($user->password != $password) { echo "Password incorrect!"; header($returntoform); exit; } $user_id = $user->user_id; $title = $_POST["title"]; $body = $_POST["body"]; $venue_id = $_POST["venue_id"]; //email and password, OK. Insert review $sql = "INSERT INTO `review` (venue_id, post_date, title, body, user_id) VALUES ('$venue_id', CURRENT_TIMESTAMP, '$title', '$body', '$user_id')"; $result = mysql_query($sql); if(!$result) { echo "Failed to add review!"; } else { echo "Thankyou for your review. Please click <a href=\"venue.php?id="; echo $venue_id; echo "\">here</a> to return to the venue's page and see your review."; } } ?> Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/ Share on other sites More sharing options...
garcon Posted March 16, 2008 Author Share Posted March 16, 2008 Why could I only see the missing closed-bracket seconds after posting? The first two questions still stand... Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/#findComment-493404 Share on other sites More sharing options...
BlueSkyIS Posted March 16, 2008 Share Posted March 16, 2008 "1. Is there a simple and comprehensive guide out there for installing php/mysql on my home machine" what operating system? many people have good luck with XAMP on Windows, MAMP on Macs. You probably don't want to compile Apache, PHP and MySQL yourself unless you have to. "2. Will the above allow me to step through the php line by line so I can debug?" No. Most people use a PHP-friendly text editor. I use BBEdit on Mac, don't know what they use on Windows. There may be some IDE's out there that will allow you to step through/execute PHP line-by-line, but I'm not familiar with them. "3. Is it just an idiotic mistake like a missing semi-colon in the code below that I can't see?" No errors displayed? Just a blank page? Turn on error_reporting before anything else in the script: error_reporting(E_ERROR | E_WARNING | E_PARSE); Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/#findComment-493411 Share on other sites More sharing options...
lordfrikk Posted March 16, 2008 Share Posted March 16, 2008 1. Manual Install: http://www.reaper-x.com/2007/09/24/installing-and-setting-up-apache-22-series-with-php-5-on-windows/ or you can get simple installer package like XAMPP (I use it as well): http://www.apachefriends.org/en/xampp.html Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/#findComment-493413 Share on other sites More sharing options...
l0ve2hat3 Posted March 16, 2008 Share Posted March 16, 2008 wrong post Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/#findComment-493419 Share on other sites More sharing options...
tendrousbeastie Posted March 16, 2008 Share Posted March 16, 2008 You're going to have problems with the code you posted, because it is outputing text to the screen before the header function is called. If you have error reporting on this will show an error, and it will stop the header from working. Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/#findComment-493429 Share on other sites More sharing options...
redarrow Posted March 16, 2008 Share Posted March 16, 2008 You're going to have problems with the code you posted, because it is outputing text to the screen before the header function is called. If you have error reporting on this will show an error, and it will stop the header from working. yep i agree can use the ob_start() and end page ob_flush() but really shouldnt unless really need to.... Link to comment https://forums.phpfreaks.com/topic/96410-another-noob-anothe-problem/#findComment-493456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.