Jump to content

[SOLVED] MYSQL syntax error


MDanz

Recommended Posts

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '12:36:06 WHERE name=Debate' at line 1

 

 

the variable $stackname comes from a while loop..  $stackname = $runrows['name'];

 

i'm using it to update another table.. but it isn't updating?

 

$query5= mysql_query("UPDATE castack SET recent=$time2 WHERE name='$stackname'")or die (mysql_error());

 

 

$time2 = $time['posted'];

 

i don't see where i've gone wrong.. $time2 isn't a string so it should update

 

 

heres the relevant part of code..

 

   
$construct = "SELECT * FROM `castack` WHERE $construct ORDER by recent DESC";
$stackname = $runrows['name'];

$time = mysql_fetch_assoc($result);
    $time2 = $time['posted'];
    $timesince = strtotime($time['posted']);
    $posted = TimeSince::since($timesince);

}

  $query5= mysql_query("UPDATE castack SET recent=$time2 WHERE name=$stackname")or die (mysql_error());

 

i've left out the for each loop, thats not the problem any help?

 

 

Link to comment
https://forums.phpfreaks.com/topic/176047-solved-mysql-syntax-error/
Share on other sites

If $time2 is not an integer (which it isn't looking at your error message) then it should have single quotes around it.

 

<?php
$query5= mysql_query("UPDATE castack SET recent='$time2' WHERE name='$stackname'")or die (mysql_error());
?>

thx...ok i've changed some stuff around and got it displaying but not as i want itto?

 

is there anything wrong with the last part of this..

 

 $construct = "SELECT * FROM `castack` WHERE $construct ORDER by recent DESC";

 

it should display in order by most recent.  The 'recent' column in mysql they all have type DATETIME and now i've gotten it to update .. this part of the code should make my results display according to that column.. but it's not.. any ideas?

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.