Jump to content

Weird Query


atholon

Recommended Posts

Hey guys, dunno if I am posting this in the right spot but I have a question...

do you see anything wrong with the following query?

 

    mysql_query("UPDATE tutorials SET title='$title', description='$description', date='$date', category1='$category1', approved='yes' WHERE stepnumber='$stepnumber' AND tutorialnumber='$tutorialid'") or die ("<br /><br />Mysql Error: ".mysql_error());
    mysql_query("UPDATE tutorials SET title='$title', description='$description', approved='$approved', date='$date', category='$category1', user='$currentuser' WHERE stepnumber='$stepnumber' AND `tutorialnumber`='$tutorialid'") or die ("<br /><br />Mysql Error: ".mysql_error());
    

 

It is giving me a WHERE error Mysql Error: Unknown field “stepnumber” in where clause

Link to comment
https://forums.phpfreaks.com/topic/71847-weird-query/
Share on other sites

Also Watch your escaping of variables.  This is just my preference, but I like doing queries like

</php
$q =  "UPDATE `tutorials` SET title='".$title."', description='".$description."', date='".$date."', category1='".$category1."', approved='yes' WHERE stepnumber='".$stepnumber."' AND tutorialnumber='".$tutorialid."'";
$r = mysql_query($q) or die(mysql_error());
?>

That way I can quote out all my variables so no worry about escaping, and also I can tell issues very easily.  Just a thought.

Link to comment
https://forums.phpfreaks.com/topic/71847-weird-query/#findComment-361904
Share on other sites

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.