BrianM Posted June 17, 2008 Share Posted June 17, 2008 I'm getting this error, all on line 22. Notice: Use of undefined constant m - assumed 'm' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\create.php on line 22 Notice: Use of undefined constant d - assumed 'd' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\create.php on line 22 Notice: Use of undefined constant y - assumed 'y' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\new_mps\report\create.php on line 22 <?php if(!isset($_GET['table'])) { print('You must have a table name set in the query string.'); } $table = $_GET['table']; mysql_connect("localhost", "brian", ""); mysql_select_db("reports"); if (isset($_POST['report_create'])) { if (!$_POST['report']) { print('You must type in a report.'); } mysql_query("INSERT INTO `$table` (date, report) VALUES ('".date(m-d-y)."', '".$_POST['report']."')") or die(mysql_error()); // this is line 22 } ?> I've commented line 22 in the code. Can somebody please tell me what's wrong with my date() function? Quote Link to comment Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 The date function expects its first argument to be a string. Quote Link to comment Share on other sites More sharing options...
BrianM Posted June 17, 2008 Author Share Posted June 17, 2008 So what is a solution? Quote Link to comment Share on other sites More sharing options...
BrianM Posted June 17, 2008 Author Share Posted June 17, 2008 Well I've fixed one problem, the query string is working fine with the form action now. But now I'm getting this error output by mysql_query() - Data truncated for column 'date' at row 1 - again on the same line, 22, with the data function on it. Any suggestions? Quote Link to comment Share on other sites More sharing options...
BrianM Posted June 17, 2008 Author Share Posted June 17, 2008 Solution, add quotes around m-d-y. Quote Link to comment Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 Yeah, as I said, date() expects a string. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.