php - mysql_insert_id function is returning 0 -
i have been trying figure out why function working on chrome, not on firefox.
i have auto increment field primary key id from. here code.
if (isset($_get['id'])) { $id = $_get['id']; } else { $id = mysql_insert_id(); echo $id; }
i've tried putting connection in function follows, still not work. pointers appreciated. also, know of mysqli functions, using these functions because user's setup quite old.
$id = mysql_insert_id($conn);
here code doing insert.
sprintf("insert `trade_show_orders` (`setupdate`,`setupenddate`,`showname`,`location`,`literature`,`startdate`,`enddate`,`attendees`,`projected`,`file`,`giveaways`,`addressbox`,`locationtype`,`title`,`firstname`,`lastname`,`email`,`addressone`,`addresstwo`,`zip`,`special`,`orderdate`,`shippinglocation`,`shippingaddressone`,`shippingaddresstwo`,`shippingzip`,`shippingspecial`) values ('$setupdate','$endsetup','%s','%s','$values','$eventstart','$eventend','%d','%d','".basename($_files['fileupload']['name'])."', '%s','off','%s','%s','%s','%s','%s','%s','%s','%d','%s',now(),'%s','%s','%s','%d','%s')", mysql_real_escape_string($_post['showname']), mysql_real_escape_string($_post['location']), $_post['numberattendees'], $_post['visitors'], mysql_real_escape_string($_post['giveaways']), mysql_real_escape_string($_post['locationtype']), mysql_real_escape_string($_post['personaltitle']), mysql_real_escape_string($_post['personalfirstname']), mysql_real_escape_string($_post['personallastname']), mysql_real_escape_string($_post['personalemail']), mysql_real_escape_string($_post['personaladdressone']), mysql_real_escape_string($_post['personaladdresstwo']), $_post['personalzip'], mysql_real_escape_string($_post['personalspecial']), mysql_real_escape_string($_post['shippinglocation']), mysql_real_escape_string($_post['shippingaddressone']), mysql_real_escape_string($_post['shippingaddresstwo']), $_post['shippingzip'], mysql_real_escape_string($_post['shippingspecial']));
mysql_insert_id()
return id if you've done insert
query current connection. means not return id page request "three clicks" ago. not return id done other script that's executing @ same, because that's done using different connection mysql.
so show rest of code insert. php shouldn't care @ browser's running on remote it. it's http request data far php concerned. if there browser-specific issue, it'll in client-side code that's blowing up, e.g. bad javascript doing ajax request , not filling out field properly.
Comments
Post a Comment