Jump to content


Photo

See if you can debug this query


  • Please log in to reply
2 replies to this topic

#1 insaynewrapper

insaynewrapper
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 June 2006 - 09:16 AM

doQuery(sprintf("UPDATE `forum_threads` SET `subject`='%s' AND `text`='%s' WHERE `id`='%s' LIMIT 1", $threadSubject, $threadText, $threadid));

It looks fine to me. When I insert something with that it inserts fine, and everything is fine. But when I go to edit it, it changes the subject to '0' no matter what you try to set it as. I've determined that it is something in this line that does it..

The code to doQuery is
function doQuery($query)
{
    $query = mysql_query($query .';') or die($dieMessage . "\n<br />". mysql_errno() .': '. mysql_error() .'</p>');
    return $query;
}


#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 18 June 2006 - 02:31 PM

When in doubt, echo out your query.

function doQuery($query)
{
    $query = mysql_query($query .';') or die($dieMessage . "\n<br />". mysql_errno() .': '. mysql_error() .'</p>');
   echo 'Query:' . $query;
    return $query;
}

If it is right, maybe 'subject' is using the wrong data type (MySQL) - like INT instead of VARCHAR or whatever

If it already prints the wrong query, check what is in $threadSubject
~ D Kuang

#3 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 18 June 2006 - 02:40 PM

I'd also like to point out that in that function, $dieMessage is not declared so you get nothing. Either make it a global/constant or pass it to the function.
[table]



Don't worry, the printer fairies will sort it out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users