php - post to database -



php - post to database -

so have code takes message/post users insert , meant post database , displays , seperate page. ive got displaying park working fine trying insert database problem this code...

<?php mysql_connect("localhost", "root", ""); mysql_select_db("test"); $time = time(); mysql_query "insert threads (title, message, author, dated);" values (null,'$_post[title]','$_post[message]','$_post[author]','0','$time'); echo "thread posted.<br><a href='untitled9.php'>return</a>"; ?>

wont post infomation database!

why , how can resolved?

id int(11) no none auto_increment title varchar(255) latin1_swedish_ci no none message text latin1_swedish_ci no none author varchar(255) latin1_swedish_ci no none replies int(11) no none posted varchar(255) latin1_swedish_ci no none votes_up int(11) no 0 votes_down int(11) no 0

update:

should posted not dated.

heres problem:

mysql_query "insert threads (title, message, author, posted);" values (null,'$_post[title]','$_post[message]','$_post[author]','0','$time');

change to:

mysql_query("insert threads (title, message, author, posted) values ('$_post[title]','$_post[message]','$_post[author]','$time');");

i see have null values also, makes me believe using id auto increment, if case, need supply also. example:

edit: here

mysql_query("insert threads (id,title, message, author, posted) values (null,'$_post[title]','$_post[message]','$_post[author]','$time');");

note inserting values straight post info unsafe , leaves open various attacks.

php

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -