Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

SQL Query not working

This isnt throwing an error, or putting anything in the database. Anybody see anything wrong??

$sql = "INSERT INTO forum_post (post_author, post_author_id, otid, date_time, type, section_title, section_id, thread_title, post_body) VALUES ('$post_author', '$member_id', $tid , CURRENT_TIMESTAMP, 'b', '$forum_section_title', '$forum_section_id', '$post_title', '$post_body')";
$query = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli));

1 Answer

I am guessing that each values the columns need to be enclosed with parentheses

See the MySQL docs here http://dev.mysql.com/doc/refman/5.6/en/insert.html

Edit: Scratch that, the SQL looks good.

Edit2: Ok so, reading up on it, maybe you can replace the php die method, that will completely stop the process. You can replace it with other error triggers and I found a great answer on Stackoverflow that goes over this issue http://stackoverflow.com/questions/15318368/mysqli-or-die-does-it-have-to-die . That way you might find the error that you are getting?