Re: Please help with code

From: Date: Mon, 01 Apr 2002 16:26:41 +0000
Subject: Re: Please help with code
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-90970@lists.php.net to get a copy of this message
Should I change the position of the php code? Thanks denis ----- Original Message ----- From: "Andrew Brampton" <andrew@bramp.freeserve.co.uk> To: "Denis L. Menezes" <menezesd@singnet.com.sg>; <php-general@lists.php.net> Sent: Tuesday, April 02, 2002 12:31 AM Subject: Re: [PHP] Please help with code > You are not actually posting the form to a page with your PHP on... so its > trying to insert that form into your DB before u actually fill it out. > either check if the form has been posted before running your PHP, or split > this into 2 pages > > Andrew > ----- Original Message ----- > From: "Denis L. Menezes" <menezesd@singnet.com.sg> > To: <php-general@lists.php.net> > Sent: Monday, April 01, 2002 5:08 PM > Subject: [PHP] Please help with code > > > > Hello friends, > > > > can someone tell me what is wrong with this code : > > > > > > <form name="form1" method="post" action=""> > > <p> > > <input type="text" name="newsid"> > > </p> > > <p> > > <input type="text" name="title"> > > </p> > > <p> > > <input type="text" name="author"> > > </p> > > <p> > > <input type="text" name="body"> > > </p> > > <p> > > <input type="submit" name="Submit" value="Submit"> > > </p> > > </form> > > </body> > > <?php > > $link=mysql_connect("localhost","myid","mypassword"); > > if ($link){ > > print "link id is $link"; > > } else { > > print "error connecting to database"; > > } > > $posted=time(); > > $query="INSERT INTO news (newsid,title, author, body, posted) > > VALUES($newsid,$title, $author, $body, UNIX_TIMESTAMP())"; > > IF (mysql_query($query)){ > > print "Row added to table"; > > } else { > > print "error adding row"; > > } > > ?> > > > > > > It gives the link ID. But then gives "error adding row" > > > > Thanks in advance > > > > Denis > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#90970) next »