I try to write a variable into the field in MySQL. But i dont have result.
This is my code. Who can help me?
This is my code. Who can help me?
$current_time = & JFactory::getDate();
$time = $current_time->toMySql();
echo $time; //give correct result
$db =& JFactory::getDBO();
$query = "
UPDATE ".$db->nameQuote('jos_chronoforms_newdata')."
SET ".$db->nameQuote('approvaltime')." = $time
//it's OK if ---- SET ".$db->nameQuote('approvaltime')." = '123456789'
WHERE ".$db->nameQuote('cf_id')." =$index
";
$db->setQuery($query);
$db->query();
Hi trancompany,
You've quoted all the names but not the value - it needs to be $db->quote($time)
But actually it's simpler to use the MySQL NOW() function
Bob
PS $index is OK as it is an integer, strings like '09-09-2009 09:09' need single quotes.
You've quoted all the names but not the value - it needs to be $db->quote($time)
But actually it's simpler to use the MySQL NOW() function
$db =& JFactory::getDBO();
$query = "
UPDATE ".$db->nameQuote('jos_chronoforms_newdata')."
SET ".$db->nameQuote('approvaltime')." = NOW()
WHERE ".$db->nameQuote('cf_id')." = $index
";
Bob
PS $index is OK as it is an integer, strings like '09-09-2009 09:09' need single quotes.
Thank you so much.😀
This topic is locked and no more replies can be posted.