speedy_rudolf Posted September 24, 2010 Share Posted September 24, 2010 Hi. I think you all know me by now so I'll cut to the chase. <?php $host="edited"; $username="edited"; $password="edited"; $db_name="edited"; $tbl_name="topic"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $name=$_POST['name']; $detail=$_POST['details']; $sql="INSERT INTO $tbl_name(topic, detail, datetime)VALUES('$name', '$detail', NOW())"; $result=mysql_query($sql); if($result){ header("location:site.html");} else{ echo("I have failed you master.");} ?> Displayed error: "I have failed you master." Anyone know a possible cause? Thanks. Bye. Quote Link to comment https://forums.phpfreaks.com/topic/214288-mysql-insert-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2010 Share Posted September 24, 2010 If you echo mysql_error(); it will tell you why the query failed. Quote Link to comment https://forums.phpfreaks.com/topic/214288-mysql-insert-error/#findComment-1115076 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.