When I try to insert some values from an array in my database. I get this error:
Error: Unknown column 'photo0' in 'field list'
my sql php script is:
mysqli_query($con,"INSERT INTO paintings (name, description, photo0, photo1, photo2, photo3, photo4, photo5, photo6, photo7, photo8, photo9, date)
VALUES ('$title', '$desc', '$array[0]', '$array[1]', '$array[2]', '$array[3]', '$array[4]', '$array[5]', '$array[6]', '$array[7]', '$array[8]', '$array[9]', CURRENT_TIMESTAMP)");
The print_r($array); shows all the values. Why do I get the error??
photo0
– developerwjk 2 days agophoto0
exist in the table? – trogdor 2 days agobind_param
to add data to your queries. Do not use string interpolation or concatenation or you will end up in trouble. A guide like PHP The Right Way helps to avoid pitfalls like this. – tadman 2 days ago