Re: Re[4]: [PHP] value passing from html form to php variable.

From: Date: Sat, 01 Jun 2002 17:00:22 +0000
Subject: Re: Re[4]: [PHP] value passing from html form to php variable.
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-100243@lists.php.net to get a copy of this message
Changed the query and get this error when input dave as firstname: ERRORERROR: Attribute 'dave' not found add2.php is: <html> <body> <?php $db = pg_connect("dbname=friends"); $query = "INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")"; $result = pg_exec($db, $query); if (!$result) { printf ("ERROR"); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf ("These values were inserted into the database - %s %s", $firstname, $surname); pg_close(); ?> </body> </html> addform.php is: <html> <body> <form action="add2.php" method="post"> First Name : <input type="text" name="firstname" size="40" length="40" value=""><BR> Surname : <input type="text" name="surname" size="40" length="40" value=""><BR> <input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Clear It"> </form> </body> </html> On Sat, 1 Jun 2002 17:44:57 +0100 stuart@sharedserver.net (Stuart Dallas) wrote: > On Saturday, June 1, 2002 at 5:35:03 PM, you wrote: > > Is there anything I should do to make the php.ini come into effect? I did > > put the register_global = On but still got empty values. > > you may not need to do anything or you may need to restart your http server. > Have a look at your phpinfo() page. If it's picking up the php.ini file then it > will show it's filename as well as it's path. > > > <?php > > $db = pg_connect("dbname=friends"); > > $query = "INSERT INTO friends (id, firstname, surname) values > > (nextval('friends_id_seq'), $_POST['firstname'], > > $_POST['surname'])"; > > $result = pg_exec($db, $query); > > if (!$result) { > > printf ("ERROR"); > > $errormessage = pg_errormessage($db); > > echo $errormessage; > > exit; > > } > > printf ("These values were inserted into the database - %s %s", $firstname, > > $surname); > > pg_close(); > ?>> > > </body> > > </html> > > Hmm, line 6 of that code would be printf ("ERROR"); but I'll assume that you > haven't included the first few lines and that line 6 is actually the pg_exec > line. You haven't changed $query as I suggested in a previous message. Change > the $query = line to the following... > > $query = "INSERT INTO friends (id, firstname, surname) values > (nextval('friends_id_seq'), ".$_POST['firstname'].", > ".$_POST['surname'].")"; > > -- > Stuart >

« previous php.general (#100243) next »