mysql - PHP insert problems -
righ,t on website admin puts information form , sent , becomes news feed on main page (title, body, dateposted), reason, (and i've checked against working code) code not working , don't know why, can me?
<?php $post = mysql_query("insert news(`title`,`body`,`date_posted`) values('$title','$body','$date')"); mysql_close($connect); header("location: news.php"); } else { echo "the body of news post entered short."; } } ?>
my datebase rows:
[id] [title] [body] [date_posted]
this work if id field designated being auto-incrementing
http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
edit
the other technique adopt put sql variable , when hit problems can echo out onto page (or error_log). means doing this:
$sql = "insert news(`title`,`body`,`date_posted`) values('$title','$body','$date')"; $post = mysql_query($sql); // have optional line of debug echo $sql;
Comments
Post a Comment