Jump to content

Displaying Time


ChompGator

Recommended Posts

Hello,

 

I have an html form that users fill out the following fields: <article-name><article-date><article-description>

 

Im testing it out and when you submit the form, article-description submits into the data base, and article-name submits into the database, and article-date does as well...However for some reason if I put 2008-10-05 in the text box it submits into the database as 0000-00-00, and the article name isn't submitting at all

 

Would anyone know why that is happening? Ive included the SQL from the table I have created in PHPMyAdmin, and the php code that does the inserting...thanks!

 

CREATE TABLE `legion`.`cadet_Testing` (
`id` INT( 4 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`articlename` TEXT NOT NULL ,
`date` DATE NOT NULL ,
`description` VARCHAR( 100 ) NOT NULL 
) ENGINE = MYISAM 

 

Here is the script that inserts the data into the MySQL db

<?php
$con = mysql_connect("***","***","***") or die('Could not connect: ' . mysql_error());
mysql_select_db("***", $con);

$sql="INSERT INTO cadet_Testing (articlename, date, description) VALUES ('".$_POST['articlename']."','".$_POST['date']."','".$_POST['description']."')";
$query = mysql_query($sql,$con) or die('Error: ' . mysql_error());

if ($query)
{
  echo "Your Event has been added";mysql_close($con);
}
else
{
  echo "Not added.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/135043-displaying-time/
Share on other sites

 

<form name="input" action="cadethandle.php"
method="post">

<p><strong>Article Name:
<Article Date:<br>
					</strong>
					<input class="pretty" style="WIDTH: 155px" maxLength="100" size="10" name="title">                             
					<input class="pretty" style="WIDTH: 155px" maxLength="100" size="10" value="YYYY-MM-DD" name="date1"><br>
					<br>
					</p>
					<p><strong>Event:				<br>
					</strong>
					<textarea style="WIDTH: 296px; HEIGHT: 104px" name="description" rows="1" cols="50">Event Description
</textarea></p>
                        <p style="margin-left: 10; margin-right: 10; margin-top: 10" class="style5">
				<input type="submit" value="Submit The Event">

Link to comment
https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703393
Share on other sites

Hmm, ok I did an echo "$sql"; and the page was just blank.

 

I fixed the html form where the article name is and changed it to articlename

instead of what it was(I think it was title)...

 

And the name or date still isn't submitting :(

Well the date is, its just submitting as 0000-00-00

Link to comment
https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703407
Share on other sites

Computers only do exactly what their programming tells them to do.

 

name="date1" is not equal to $_POST['date']

 

If you have a piece of data that is not correct, you must backtrack through the code, all the way to the source of that data if necessary, to find out why it is not correct.

 

Link to comment
https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703438
Share on other sites

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.