Passing a timestamp to mysql as a variable not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pwoodson
    New Member
    • Apr 2010
    • 1

    Passing a timestamp to mysql as a variable not working

    I have queried a mysql database and stored a timestamp that is a primary key for a record in a php variable called $tsdate. I then want to use that php variable when I generate a subsequent query to my mysql database. Unfortunately, this does not seem to work. If I hard code a value of the timestamp into the php sql select statement, it works fine. If I try to replace the hardcoded timestamp value with $tsdate, it fails. Do I need do something special to $tsdate, such as set the variable type, convert to a date, etc.?

    Here is an example of the php select statement that works...

    $query =mysql_query("S ELECT * FROM ColumnA WHERE TimeStamp = \"2010-04-06 23:26:38\"");

    Here is an example of the php select statement that does not work...

    $tsdate = "2010-04-06 23:26:38"

    $query =mysql_query("S ELECT * FROM ColumnA WHERE TimeStamp = $tsdate");
  • chathura86
    New Member
    • May 2007
    • 227

    #2
    $query =mysql_query("S ELECT * FROM ColumnA WHERE TimeStamp = '$tsdate'");

    try this one

    Regards

    Comment

    Working...