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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.