Jump to content

Archived

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

insaynewrapper

See if you can debug this query

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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.