Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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??

share|improve this question
5  
Your database table doesn't have a column named photo0 –  developerwjk 2 days ago
 
Does the column photo0 exist in the table? –  trogdor 2 days ago
 
To avoid serious SQL injection bugs use bind_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
 
Yes the column 'photo0' exists. That's why I don't get it –  Deben Oldert 2 days ago
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.