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
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());
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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