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 trial

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?