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 Help

The Database is Users The table im working with is fourm_post And the information im updating is the post_body

UPDATE forum_post 
SET post_body = '$edit_post_body' 
WHERE id = '$post_id'
AND post_author = '$post_author'
AND type = '$post_type'

3 Answers

Gregory Serfaty
Gregory Serfaty
37,140 Points

Delete the simple quote between all yours variables

You mean remove the ' ' - Dont you need those if you are using php var

Gregory Serfaty
Gregory Serfaty
37,140 Points

You need to do like this the single quote does not interpret php if you do this '$var' for php you write a string $var

"UPDATE forum_post SET post_body = '".$edit_post_body."' WHERE id = '".$post_id."' AND post_author = '".$post_author."' AND type = '".$post_type."'"

I have a website, and every query I have use '$post_body' so that cant be the problem

Gregory Serfaty
Gregory Serfaty
37,140 Points

after that maybe you have a quote in your variable so you need to escape your variable (addslashes etc...) what is the content of yours variables you use mysql_query? look PDO