ChompGator Posted December 1, 2008 Share Posted December 1, 2008 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 More sharing options...
PFMaBiSmAd Posted December 1, 2008 Share Posted December 1, 2008 Post your form as well. Echo $sql to see what is actually in it. Link to comment https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703387 Share on other sites More sharing options...
ChompGator Posted December 1, 2008 Author Share Posted December 1, 2008 <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 More sharing options...
revraz Posted December 1, 2008 Share Posted December 1, 2008 Echo $sql to see what is actually in it. Link to comment https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703398 Share on other sites More sharing options...
revraz Posted December 1, 2008 Share Posted December 1, 2008 Look at your INPUT names and compare them to the POST names you are using. Link to comment https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703402 Share on other sites More sharing options...
PFMaBiSmAd Posted December 1, 2008 Share Posted December 1, 2008 Ummm. The name="...." parameters in your form fields don't match the names being used in the $_POST['...'] variables. How would you expect it to work doing it that way? Link to comment https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703403 Share on other sites More sharing options...
ChompGator Posted December 1, 2008 Author Share Posted December 1, 2008 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 More sharing options...
PFMaBiSmAd Posted December 1, 2008 Share Posted December 1, 2008 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 More sharing options...
ChompGator Posted December 1, 2008 Author Share Posted December 1, 2008 You know what Duh, duh duh! lol - I should have noticed that, what silly mistake...You know sometimes it happens I appreciate your input, it certainly was useful Link to comment https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703446 Share on other sites More sharing options...
revraz Posted December 1, 2008 Share Posted December 1, 2008 I was hoping you would catch that on your own when I told you to compare them. Link to comment https://forums.phpfreaks.com/topic/135043-displaying-time/#findComment-703466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.