Re: Please help with code

From: Date: Mon, 01 Apr 2002 16:57:56 +0000
Subject: Re: Please help with code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-90977@lists.php.net to get a copy of this message
You forgot to select the database that you want to insert. Ex: $db = mysql_select_db ( mydatabase ); Hope this helps, Harry --- "Denis L. Menezes" <menezesd@singnet.com.sg> wrote: > 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 > __________________________________________________ Do You Yahoo!? Yahoo! Greetings - send holiday greetings for Easter, Passover http://greetings.yahoo.com/

« previous php.general (#90977) next »