I have a database named \'mysqlproject\' that contains two tables. One of the tables that i am interesting in is named markers and declared in database like this :
If you want to do an INSERT, then your VALUES
is misplaced.
Do:
$results = mysql_query("INSERT INTO markers (PhotosEvent) VALUES ('$dataURL')...
Also make sure session_start();
is loaded, since you are using sessions.
After seeing the comments in your question, then if
UPDATE markers SET PhotosEvent = '$dataUrl' WHERE id = $_SESSION['id']
or
UPDATE markers SET PhotosEvent = '$dataUrl' WHERE id = '".$_SESSION['id']."'
did not work, then that could be the reason.
Add error reporting to the top of your file(s) which will help during production testing.
error_reporting(E_ALL);
ini_set('display_errors', 1);
and mysql_error()
Using those error reporting methods will help find errors found in your code.
Found it!
define('UPLOAD_DIR', 'EventImages/');
$img = $_POST['imgBase64'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
$success = file_put_contents($file, $data);
print $success ? $file : 'Unable to save the file.';
$result=mysql_query("SELECT id FROM markers ORDER BY id DESC LIMIT 1");
while ($row = mysql_fetch_array($result)){
$LastInsertID=$row['id'];
}
$results = mysql_query("UPDATE markers SET PhotosEvent='".$file."' WHERE id = '".$LastInsertID."'");
now it works ok.. I am fetcing the last known id that is in table Markers and i save the image's url that is stored in variable $file in the database!! I also save the image to folder EventImages as i did before!!