Jump to content

See if you can debug this query


insaynewrapper

Recommended Posts

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

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
[code]function doQuery($query)
{
    $query = mysql_query($query .';') or die($dieMessage . "\n<br />". mysql_errno() .': '. mysql_error() .'</p>');
    return $query;
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/12290-see-if-you-can-debug-this-query/
Share on other sites

When in doubt, echo out your query.

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.