JayCee Posted June 17, 2009 Share Posted June 17, 2009 I'm running XAMPP and I have created a form using HTML, I have written the following code in PHP in order to store the data into my DB: <?php $Name = $_Post['Name']; $Surname = $_Post['Surname']; $Comment = $_Post['Comment']; mysql_connect ("localhost","root","test") or die ('Error: ' . mysql_error()); mysql_select_db ("results"); $query="INSERT INTO entries (Name, Surname, Comments)VALUES ('".$Name."','".$Surname."','".$Comment."')"; mysql_query($query) or die ('Error updating database'); ECHO "UPDATED"; ?> I keep getting the message Error updating database and obviously no data in my DB, anyone help me with what I'm doing wrong? Thanks in advance!!!!! JC Link to comment https://forums.phpfreaks.com/topic/162553-solved-what-am-i-doing-wrong/ Share on other sites More sharing options...
trq Posted June 17, 2009 Share Posted June 17, 2009 Its $_POST not $_Post. Link to comment https://forums.phpfreaks.com/topic/162553-solved-what-am-i-doing-wrong/#findComment-857914 Share on other sites More sharing options...
JayCee Posted June 17, 2009 Author Share Posted June 17, 2009 Thanks for swift response Thorpe, I've changed it to $_POST but I'm still getting the same error?? Link to comment https://forums.phpfreaks.com/topic/162553-solved-what-am-i-doing-wrong/#findComment-857922 Share on other sites More sharing options...
Mark Baker Posted June 17, 2009 Share Posted June 17, 2009 $query="INSERT INTO entries (Name, Surname, Comments)VALUES ('".$Name."','".$Surname."','".$Comment."')"; echo $query.'<br />'; mysql_query($query) or die ('Error updating database: '.mysql_error()); Link to comment https://forums.phpfreaks.com/topic/162553-solved-what-am-i-doing-wrong/#findComment-857923 Share on other sites More sharing options...
trq Posted June 17, 2009 Share Posted June 17, 2009 Generally its best to avoid die(), but if you going to use it, at least make it throw you a decent error message. mysql_query($query) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/162553-solved-what-am-i-doing-wrong/#findComment-857924 Share on other sites More sharing options...
JayCee Posted June 17, 2009 Author Share Posted June 17, 2009 Thorpe!!!! Thanks! I changed die to show me an error and it highlighted my ridiculous poor spelling, the field is comment not comments!!! D'OH!!! Thanks Again!! Link to comment https://forums.phpfreaks.com/topic/162553-solved-what-am-i-doing-wrong/#findComment-857935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.