0

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?

1 Answer 1

3

Put it in the query, not the code.

."STR_TO_DATE(".$db->quote(JRequest::getVar('birthdate')).",'%m/%d/%Y')"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.