Re: [PHP-DB] Converting Date for mysql
See below: --- John Holmes [EMAIL PROTECTED] wrote: Are you sure it's the date that's causing the rejection? What does mysql_error() say? No, I'm not sure. At first the date was being accepted but wrong in the database. It was setting it to 1/1/2000. Someone suggested I add '' around the value. Apparently it didn't like that and started saying I had a SQL error. I've tried a number of things, so far without success. This is the current error: 0: 1064: 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 '', 1, 1, 24, 25, 10/28/2004)' at line 5 While this is probably a waste of bandwidth here is my statement: $query = INSERT INTO CorrectTableName(RecordID,UserID,ProfileName, Edu, WorkAuth, WorkExp, CarLev, Secu, Confi, Relo, Telecomu, City1, State1, City2, State2, TravelPref, SalaryAnnual, SalaryHourly, Available) VALUES (null, null, '$f1a', $f2a, $f2c, $f2d, $f2e, $f2g, '$f5b', '$f3m', '$f3n', '$f3e', $f3f, $f3g', $f3h, $f3i, $f3j, $f3k, $f3l); Outside of the date I don't see where the error could be coming from. Fields with quotes are string values. I have no idea. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Converting Date for mysql
On Fri, 15 Oct 2004 17:26, Stuart Felenstein wrote: See below: --- John Holmes [EMAIL PROTECTED] wrote: Are you sure it's the date that's causing the rejection? What does mysql_error() say? No, I'm not sure. At first the date was being accepted but wrong in the database. It was setting it to 1/1/2000. Someone suggested I add '' around the value. Apparently it didn't like that and started saying I had a SQL error. I've tried a number of things, so far without success. This is the current error: 0: 1064: 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 '', 1, 1, 24, 25, 10/28/2004)' at line 5 While this is probably a waste of bandwidth here is my statement: $query = INSERT INTO CorrectTableName(RecordID,UserID,ProfileName, Edu, WorkAuth, WorkExp, CarLev, Secu, Confi, Relo, Telecomu, City1, State1, City2, State2, TravelPref, SalaryAnnual, SalaryHourly, Available) VALUES (null, null, '$f1a', $f2a, $f2c, $f2d, $f2e, $f2g, '$f5b', '$f3m', '$f3n', '$f3e', $f3f, $f3g', $f3h, $f3i, $f3j, $f3k, $f3l); Outside of the date I don't see where the error could be coming from. Fields with quotes are string values. I have no idea. You seem to be missing a single quote at the beginning of $f3g May I suggest that as well as echoing mysql_error() you also echo your query; that way you can see _exactly_ what is being passed to mysql and you can resolve problems like this simply and without resorting to the mailing list. -- David Robley Terminal glare: A look that kills... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Converting Date for mysql
Yes, my apologies to the list! Stuart --- David Robley [EMAIL PROTECTED] wrote: May I suggest that as well as echoing mysql_error() you also echo your query; that way you can see _exactly_ what is being passed to mysql and you can resolve problems like this simply and without resorting to the mailing list. -- David Robley -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Converting Date for mysql
I have one of those widget calendars. Mysql keeps throwing back the date regardless of the way I format it. I'm passing session variables over to the database and have tried quotes ' around the date as well. Now I went ahead and changed this line: $_SESSION['f3k'] = $_POST['DateAvailable']; to $_SESSION['f3k'] = date('Y-m-d', mktime(0,0,0,substr(3,5,$_POST['newdate']), substr(0,2,$_POST['newdate']), substr(6,10,$_POST['newdate']))); I now tried to pass 'newdate' into the database and still rejected. Any ideas ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Converting Date for mysql
did you look to see what the data format was? many of these calendars fill in american dates (mm-dd-) and mysql prefers (-mm-dd)check to see what the format is before you assign it to the session id... bastien From: Stuart Felenstein [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] Converting Date for mysql Date: Thu, 14 Oct 2004 12:14:57 -0700 (PDT) I have one of those widget calendars. Mysql keeps throwing back the date regardless of the way I format it. I'm passing session variables over to the database and have tried quotes ' around the date as well. Now I went ahead and changed this line: $_SESSION['f3k'] = $_POST['DateAvailable']; to $_SESSION['f3k'] = date('Y-m-d', mktime(0,0,0,substr(3,5,$_POST['newdate']), substr(0,2,$_POST['newdate']), substr(6,10,$_POST['newdate']))); I now tried to pass 'newdate' into the database and still rejected. Any ideas ? Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php