A blank row is being inserted before, and along with the actual data row, in my MySQL database. Why is this?
Here is my code:
<?php
define('DB_NAME','my_db_name');
define('DB_USER','my_db_user');
define('DB_PASSWORD','my_db_pass');
define('DB_HOST','localhost');
$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if (!$link){
die('Could no connect'.mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if(!$db_selected){
die('Can\'t no connect'. DB_NAME .':'.mysql_error());
}
$name = $_POST['name'];
$sql ="INSERT INTO demo (name) VALUES ('$name')";
if(!mysql_query($sql)){
die('Error:'.mysql_error());
}
mysql_close();
?>
<html>
<body>
<form action="demo2.php" method="post">
<input id="name" name="name" type="text" placeholder="" class="form-control input-md" required="">
<input type="submit" class="btn btn-success" value="Add Client">
</form>
</body>
</html>
Here is my MySQL database structure:
Here is the table with a blank entry before the "gunk" name data entry:
I have taken the time to isolate this issue down to one form input with a successful database connection and my data is added, just with blank row before it.
Why am I getting a blank row inserted before new data row in my database?