php - Insert Values in Database with id auto increment -
i want upload image database , add values id, markerid (string, not unique), imagename (text), note (text) , likes (int) table pinboard.
this php scirpt:
if (isset($_post["image"]) && isset($_post["markerid"])) { $data = $_post["image"]; $markerid = $_post["markerid"]; $imagename = $id.".png"; $filepath = "ceimages/".$imagename; echo "file ".$filepath; if (file_exists($filepath)) { unlink($filepath); //delete old file } $myfile = fopen($filepath, "w") or die("unable open file!"); file_put_contents($filepath, base64_decode($data)); //id, markerid, image, note, likes mysql_query("insert pinboard values ('', '{$markerid}', '{$imagename}', '', '')") or die ('could not save entry: '.mysql_error()); }
the problem set $imagename. want imagename equal id uniqe. id set later, when add values (id auto increment). how can set imagename id, if row insertet in same script?
first insert record out image name after update image path
get last id mysql_insert_id();
Comments
Post a Comment