Jump to content

[SOLVED] date() - undefined constant


BrianM

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.