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? Link to comment https://forums.phpfreaks.com/topic/110643-solved-date-undefined-constant/ 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. Link to comment https://forums.phpfreaks.com/topic/110643-solved-date-undefined-constant/#findComment-567619 Share on other sites More sharing options...
BrianM Posted June 17, 2008 Author Share Posted June 17, 2008 So what is a solution? Link to comment https://forums.phpfreaks.com/topic/110643-solved-date-undefined-constant/#findComment-567621 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? Link to comment https://forums.phpfreaks.com/topic/110643-solved-date-undefined-constant/#findComment-567623 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. Link to comment https://forums.phpfreaks.com/topic/110643-solved-date-undefined-constant/#findComment-567626 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. Link to comment https://forums.phpfreaks.com/topic/110643-solved-date-undefined-constant/#findComment-567628 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.