I'm stuck here for almost 4 hrs can't find what's the error in variable here although I declare correctly the variable.
The error prompt like this :
Notice: Undefined variable: last_id in C:\xampp\htdocs\CIS\addSubscriber.php on line 87
Here is the code:
 if(mysql_query("INSERT INTO subscribers(fName, mName, lName, suffix, globeNumber, emailAddress, contactNumber, 
    address, state, country, virtualNumber, agentCode, ipAddress, dateRegistration, dateStarted, dateExpired, time, 
    transaction_id, accountStatus, subscriptionStatus, status, remarks)
  VALUES ('$fName' , '$mName', '$lName', '$sName', '$globe', '$emailAdd', '$contactNo', '$address', '$state', '$country', 
  '$virtualNum', '$cAgentCode', '$ipAddress', '$dateRegistration', '$dateStarted', '$dateExpired', '$time', 
  '$transaction', '$accStatus', '$subsStatus', '$status', '$remarks' )"))
{ 
    $last_id = mysql_insert_id(); 
}
**//this is line 87** 
$query =  "INSERT INTO `transactions` (`transactionNumber`, `subscriptionStart`, `subscriptionEnd`, `subsStatus`, `cus_id`)
VALUES ('".$transaction."', , '".$dateStarted."', '".$dateExpired."', '".$subsStatus."', '".$last_id."');"; 
  if($query_run = mysql_query($query)){
 ?>
  <script> alert('<?php echo $last_id; ?>'); 
 </script>
    <?php
} else {
    ?>
    <script>alert('Agent Code is not available!');</script>
    <?php
}
}
 echo mysql_error();
I tried this using in other file but it was working I can't find the trigger of error.
Different from basic Undefined Variable error:
 
     
    