zenix Posted June 5, 2009 Share Posted June 5, 2009 Hi, I am new to php and have been learning right along when suddenly my form pages don't display. All the other php pages display just fine. All I get is a 500 error in IE and a blank page in Firefox. If someone could lend some assistance I would really appreciate it. If the HTML is alone it displays perfectly. Here is the code: <head> <title>Entry 2</title> </head> <body> <?php //Didn't show anything //ini_set('display_errors', 1); //error_reporting(E_ALL); if(isset($_POST['submit'])) { //connect and select if($dbc = mysql_connect ('localhost', 'root')) { if(!@mysql_select_db ('myblog')) { dir('<p>Could not select database because <b>' . mysql_error() . '</b></p>'; } } else { print "<p>Could not connect to database because <b>" . mysql_error() . "</b></p>"; } //define query $query = "INSERT INTO blog_entries (bog_id, title, entry, date_entered) VALUES(0, '{$_POST['title']}', '{$POST['entry']}', NOW())"; //execute query if(@mysql_query($query)) { print '<p>The blog entry has been added</p>'; } else { "<p>Could not add entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>" } mysql_close(); ?> <form action ="add_entry.php" method ="post"> <p>Entry title: <input type ="text" name ="title" size ="40" maxsize ="100"/></p> <p>Entry text: <text area name="entry" cols ="40" rows ="5"/></p> <br/> <input type ="submit" name ="submit" value ="Add my entry!"/> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/161046-form-issues/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2009 Share Posted June 5, 2009 The posted code contains two (or more) fatal parse errors. One on line 19 due to a missing ) and one on line 38 due to a missing ; on line 37. Line 37 also does not have any php statement, it is only a quoted string. Edit: There is also a missing closing } that goes with the if(isset($_POST['submit'])) statement. You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini. For fatal parse errors, you cannot set those two settings in your code because your code is never executed when there are parse errors. Link to comment https://forums.phpfreaks.com/topic/161046-form-issues/#findComment-849887 Share on other sites More sharing options...
liamthebof Posted June 5, 2009 Share Posted June 5, 2009 Also, it sounds as though you are using a basic php editor. I would recommend using Dreamweaver or phpDesigner as they would pick simple faults up in an instant. Up to you though, I do become lazy using phpD. Link to comment https://forums.phpfreaks.com/topic/161046-form-issues/#findComment-849892 Share on other sites More sharing options...
zenix Posted June 5, 2009 Author Share Posted June 5, 2009 Thanks a lot for your help! Apparently I am blind to my own mistakes....NOW I understand better where my wife is coming from. I used to use phpD but recently switched to Dreamweaver CS4. I appreciate your advice! Link to comment https://forums.phpfreaks.com/topic/161046-form-issues/#findComment-849943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.