I have spot_information in my table set to auto_increment. So when I use mysql_insert_id() after the query i was expecting it to return the value that was generated by the auto increment.
Instead it just returns 0.
Please can somone help me out. Here is the code I am using
<?php
include "connect.php";
include "header.php";
print_r($_POST);
$spot_name = $POST['spot_name'];
$address = $POST['address'];
$suburb = $POST['suburb'];
$town = $POST['town'];
$county = $POST['county'];
$country = $POST['country'];
//$image1 = $_POST[''];
$insert = "INSERT INTO spot_information ( name , address , suburb , town , county , country)
VALUES (
'$spot_name', '$address', '$suburb', '$town', '$county', '$country'
)";
$spot_id = mysql_insert_id();
echo "Spot id is $spot_id";
$insert_result = mysql_query($insert) or die (mysql_error());
?>
<html>
<head>
<title>Thanks for adding <?php echo $spot_name; ?> to the list.</title>
</head>
<body>
Thanks for adding <?php echo $spot_name; ?> to the list.
<br>
<a href='index.php'>Click here to go back to the home page</a>
</body>
</html>
Thanks for any help