Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJames Lambert
Courses Plus Student 14,477 PointsWhy would my INSERT INTO not work on my php when SELECT does?
I am working on using PHP with mySql.
The mySql is running. My try/catch is working. I have enabled error to show up. I am not running a bad query, because I can enter it into my mysql workbench and it does what I want.
SELECT queries work fine. Why worn't INSERT INTO?
What could possibly be the problem.
2 Answers
shezazr
8,275 Pointsshow us your code... we are not psychic.. normally if select works then insert should also work.. providing the query doesnt have any errors.. just echo it out on a page and run it directly on MySQL to see what happens..
James Lambert
Courses Plus Student 14,477 PointsI narrowed it down. In the database I was querying, the ID int is not auto incrementing. Got a duplicate entry '0' for Primary Key.