Error insert mysqli [closed]

-1

How to do the INSERT correctly? You are not inserting!

 $id =  $_GET['id'];
 $queryrun=mysqli_query($conn,"SELECT image_path FROM tbl_image WHERE 
 id='$id' ");
 $row=mysqli_fetch_object($queryrun);
if($row->image_path!== $document)
 {
 unlink("upload/".$row->image_path);
 }
 $query = " UPDATE tbl_image SET image_album,image_text = 
'$img_album','$img_text',image_path = '$document' where id = '$id' ";
 $queryrun = mysqli_query($conn,$query);
 $_SESSION['msg'] = "Your Data Updated Successfully";   
}

If you are not sure,

$query = " UPDATE tbl_image SET image_album,image_text = 
'$img_album','$img_text',image_path = '$document' where id = '$id' ";

Attempt to specify for each value? same error

$query = "INSERT INTO tbl_image SET image_album,SET image_text = 
'$img_album','$img_text',image_path = '$document'  ";

Solved this way

 $query = "INSERT INTO tbl_image SET image_album = '$img_album', image_text = '$img_text', image_path = '$document'  ";
    
asked by anonymous 20.11.2017 / 18:53

2 answers

2

If you want to include a new record with MySQL's alternative syntax you must specify the column and its value, according to the code below.

$query = "INSERT INTO tbl_image SET 
                      image_album = '$img_album' ,
                      image_text = '$img_text',
                      image_path = '$document'";

Or in classic syntax:

$query = "INSERT INTO tbl_image (image_album, image_text, image_path) 
          VALUES ('$img_album', '$img_text', '$document')";
    
20.11.2017 / 19:29
1

Try this:

$query = " UPDATE tbl_image SET image_album='$img_album',image_text = 
'$img_text',image_path = '$document' where id = '$id' ";

Correct syntax:

  

UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;

    
20.11.2017 / 19:13