My script stores client registration into a mySQL database. All works fine but I then need to retrieve the last record stored so that I can get the 'Application ID', which is generated by mySQL as it's an auto incrementing field.
The code that does this is:
//Connect to database
$db = mysql_connect("localhost","tourists_devuser","aaliyah");
mysql_select_db("tourists_touristdb",$db);
$sql = "INSERT INTO pending (business_name,address,district,town,county,postcode, telephone,fax,email,contact,password)
VALUES('$businessName','$address','$district','$town','$county','$postcode','$telephone','$fax','$email','$contactName','$password')";
$result = mysql_query($sql);
//Now find the record in the table and extract the application_id
//Use telephone number as it SHOULD be unique.
$sql = "SELECT * FROM pending WHERE telephone = ".$telephone;
$result = mysql_query($sql);
$app_id = $row["app_id"];
Unfortunately, when I check the value of $app_id, it's empty. I suspect a problem with the $sql string.