Hi All
I'm trying to create a form that allows a user to input information into a table in my database. However, the insert keeps failing and I get the message 'Error Insert Failed.'. Can anyone help me understand what's gone wrong. Also I'm not sure if this is a php problem or a MYSQL problem.
Thanks for your help.
This is my html form....
<html>
<head>
</head>
<body>
<form method="post" action="upload.php">
Place Name:
<input type="text" name="name"/>
<input type="submit"/>
</form>
</body>
</html>
and this is my php code...
<?php
$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
$selected = mysql_select_db("MyWebsite",$dbhandle)
or die("Could not select examples");
$result = mysql_query("SELECT * FROM place ORDER BY ID desc limit 1") or die(mysql_error());
$row = mysql_fetch_array($result);
$newID = $row['ID'] + 1;
mysql_query("INSERT INTO place (ID, Name) VALUES ($newID, $_POST[name]") or die("Error, Insert Failed.");
?>