Noskiw Posted October 22, 2009 Share Posted October 22, 2009 <?php $connect = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("blog", $connect) or die(mysql_error()); if(!$_POST['submit']){ echo " <form action='index.php?p=blog&p=admin' method='POST'> <table width='100%'> <tr> <td width='9%' valign='top'> Your Name: </td> <td valign='top'> <input type='text' name='name' maxlength='25' /> </td> </tr> <tr> <td valign='top'> Your Email: </td> <td> <input type='text' name='email' maxlength='35' /> </td> </tr> <tr> <td valign='top'> Your Post: </td> <td> <textarea cols='50' rows='5' name='message' maxlength='250'></textarea> <p><input type='submit' name='submit' value='Post' /> </td> </tr> </table> </form>"; }else{ $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $date = date("Y-m-d"); $time = date("H:i:s"); if($name && $email && $message){ $querypost = mysql_query("INSERT INTO blog VALUES('','" . $name . "','" . $email . "','" . $message . "','" . $date . "','" . $time . "')"); echo "<hr />Please wait... <meta http-equiv='refresh' content='2'>\n"; echo "Successfuly posted!"; } } ?> This is my code for posting the blog entry. But unfortunately, the date and time are inputted wrong. It looks like time date 00:20:09 0000-00-00 which is really starting toi p**s me off... Link to comment https://forums.phpfreaks.com/topic/178661-solved-date-errors/ Share on other sites More sharing options...
cags Posted October 22, 2009 Share Posted October 22, 2009 The topic is marked as solved so I'm thinking maybe you worked it out. But I'd guess $date and $time were the wrong way round, a good demonstration of why it's a good idea to include the field names in a query. Link to comment https://forums.phpfreaks.com/topic/178661-solved-date-errors/#findComment-942407 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.