ryanwood4 Posted November 23, 2009 Share Posted November 23, 2009 Im trying to submit a form using this script, however nothing shows up on the page, does anyone know why it's not working? Thanks <?php // Connects to your Database mysql_connect("localhost","xxxx","xxxx") or die(mysql_error()); //CHANGE ME BACK!!!!! mysql_select_db("xxxx") or die(mysql_error()); //This code runs if the form has been submitted if (isset($_POST['submit'])) { $date = date("y-m-d H:i:s"); $insert = sprintf("INSERT INTO members set title = '%s' , body = '%s', image = '%s', category = '%s', date = '%s' ", mysql_real_escape_string($_POST['title']), mysql_real_escape_string($_POST['body']), mysql_real_escape_string($_POST['image']), mysql_real_escape_string($_POST['category']), mysql_real_escape_string($date]) ); $add_member = mysql_query($insert) or die(mysql_error()); ?> <p>Article posted</p> <?php } else { ?> Quote Link to comment https://forums.phpfreaks.com/topic/182634-php-submit-form-script-causing-blank-page/ Share on other sites More sharing options...
trq Posted November 23, 2009 Share Posted November 23, 2009 Is $_POST['submit'] set? Also, whats the else for? Quote Link to comment https://forums.phpfreaks.com/topic/182634-php-submit-form-script-causing-blank-page/#findComment-963899 Share on other sites More sharing options...
ryanwood4 Posted November 23, 2009 Author Share Posted November 23, 2009 Yeah Is $_POST['submit'] is set, and the else is for when the page is submitted, the message: 'Article Posted' comes up. Would it help if I posted the entire html script? Quote Link to comment https://forums.phpfreaks.com/topic/182634-php-submit-form-script-causing-blank-page/#findComment-963910 Share on other sites More sharing options...
Anzeo Posted November 23, 2009 Share Posted November 23, 2009 Yeah Is $_POST['submit'] is set, and the else is for when the page is submitted, the message: 'Article Posted' comes up. Would it help if I posted the entire html script? The way I see it, "article posted comes up" when $_POST['submit'] is set. Also close your else block (I don't know if you have done it in your code) Quote Link to comment https://forums.phpfreaks.com/topic/182634-php-submit-form-script-causing-blank-page/#findComment-963941 Share on other sites More sharing options...
PFMaBiSmAd Posted November 23, 2009 Share Posted November 23, 2009 Blank pages are either caused by code that contains a fatal parse error (a parse error will prevent the code on the page from being executed) or by code that does not output anything on the page. If both your if(){} and else{} statements output something, it is likely you are getting a fatal parse error. Are you developing and debugging your php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (and you have verified these settings using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using) so that php would display all the errors it detects? Quote Link to comment https://forums.phpfreaks.com/topic/182634-php-submit-form-script-causing-blank-page/#findComment-963951 Share on other sites More sharing options...
ryanwood4 Posted November 23, 2009 Author Share Posted November 23, 2009 Solved it, there was an elusive ']' in the date string. Thanks to everyone who helped. Quote Link to comment https://forums.phpfreaks.com/topic/182634-php-submit-form-script-causing-blank-page/#findComment-964123 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.