Jump to content

Queries don't seem to work


3raser

Recommended Posts

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);
				}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.