开发者

How can I use a MySQL function in my PHP query code?

I'm trying to convert a string "date" value from a submitted form into an actual date while doing my insert query. I thought I could use the MySQL function str_to_date, but I'm getting an error message.

Here's my code; this is a Joomla site, so the JRequest::getVar calls are joomla's way of getting submitted _post variables.

$query = "insert into jos_customers_addresses (customer_id,nickname,birthdate)
values ("
    开发者_开发问答    .$db->quote($userAcctID).","
        .$db->quote($nickname).","
        .$db->quote(STR_TO_DATE(JRequest::getVar('birthdate'),'%m/%d/%Y'))
.")";

I've also tried the birthdate line without the $db->quote, but got the same error. The error message is:

Fatal error: Call to undefined function STR_TO_DATE() in /var/www/html/mysite.com/components/com_arrcard/models/checkoutpay.php on line 156

where line 156 is the line containing the str_to_date call. Any ideas?


Put it in the query, not the code.

."STR_TO_DATE(".$db->quote(JRequest::getVar('birthdate')).",'%m/%d/%Y')"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜