3raser Posted February 18, 2012 Share Posted February 18, 2012 UPDATE: If I remove lastedit = NOW() from the query, and just leave SET content = $var, it works. :/ If already double checked to see if a user would make it to this point in the code, and they do. And the variable $pid IS assigned a value. I've also done a quick check and changed the UPDATE queries to SELECT queries, and then echoed out the number of rows and it returned a successful result. Yet, people still can't seem to have their posts updated...why? My code: //if it's a thread, update the thread, if it's a post, update the post if($type == 2) { //update thread mysql_query("UPDATE threads SET lastedit = NOW() AND content = '{$content}' WHERE id = {$id}") or die(mysql_error()); //send them to their post redirect('viewthread.php?forum='. $forum_id .'&id='. $id .'&page='. $page); } else { //update post mysql_query("UPDATE posts SET lastedit = NOW() AND content = '{$content}' WHERE id = {$pid}") or die(mysql_error()); //send them to their post redirect('viewthread.php?forum='. $forum_id .'&id='. $id .'&page='. $page .'&post='. $post); } Quote Link to comment https://forums.phpfreaks.com/topic/257229-queries-dont-seem-to-work/ Share on other sites More sharing options...
dazman Posted February 18, 2012 Share Posted February 18, 2012 your SQL is not quite correct. When you use update, you specify the fields you wish to update, then the values. The use of "AND" is generally used in the "WHERE" condition, and not when you are specifying what you wish to update. perhaps try this instead: mysql_query("UPDATE threads SET lastedit = NOW() , content = '{$content}' WHERE id = {$id}") or die(mysql_error()); Also I hope you are escaping your queries. They best way to do this is to wrap the mysql_query() function with your own function which includes a call to mysql_real_escape_string( if you dont do this, it is extremely easy to get your page hacked or mutilated. Quote Link to comment https://forums.phpfreaks.com/topic/257229-queries-dont-seem-to-work/#findComment-1318550 Share on other sites More sharing options...
PFMaBiSmAd Posted February 18, 2012 Share Posted February 18, 2012 AND is a logical operator that logically and's the left and right operands together to produce a value. A comma , separates items in a list. Quote Link to comment https://forums.phpfreaks.com/topic/257229-queries-dont-seem-to-work/#findComment-1318609 Share on other sites More sharing options...
3raser Posted February 18, 2012 Author Share Posted February 18, 2012 Thank you for that bit of information. Solved Quote Link to comment https://forums.phpfreaks.com/topic/257229-queries-dont-seem-to-work/#findComment-1318672 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.