form that sends data to mysql?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you need to use now() for both fields.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

still only adds everything except date and time:

Code: Select all

$query = 'IN.SERT INTO news (text, author, email, date, time, title) VALUES(''' . $_POST['text'] .''', ''' . $_POST['author'] .''', ''' . $_POST['email'] . ''', '''. 'NOW()' . ''', '''. 'NOW()' . ''', ''' . $_POST['title'] . ''')';
  $result = mysql_query($query,$db);
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

Code: Select all

... 'I-N-SERT INTO ...
You have to write INSERT
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

its INSERT.. i had to do I-N-SERT because if i dont, i couldnt post the message
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

your asking mysql to enter the string NOW() not the return from NOW()... remove the '' stuff around them.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

thx

got it by doing

Code: Select all

$query = "INS ERT INTO news (text, author, email, date, time, title) VALUES('". $_POST['text'] ."', '". $_POST['author'] ."', '". $_POST['email'] ."',now(),now(),'".$_POST['title']."');";
Post Reply