RE: [PHP-DB] insert into mysql

From: Date: Thu, 25 Jan 2001 20:19:36 +0000
Subject: RE: [PHP-DB] insert into mysql
Groups: php.db 
Request: Send a blank email to php-db+get-6184@lists.php.net to get a copy of this message
try this: $db = mysql_connect(host,uid,pwd); if($act=="ADD"){ $sql="INSERT INTO ecomm (ID,part) VALUES ('$sid','$spp')"; $res = mysql_db_query($dbname,$sql,$db); if(!$res){ echo("Unable to add part."); mysql_close($db); exit(); } } you didn't specify $dbname -----Original Message----- From: Robert [mailto:rarg@bruinel.com] Sent: Thursday, January 25, 2001 3:07 PM To: Darryl Friesen; php-db@lists.php.net Subject: Re: [PHP-DB] insert into mysql It still didn't work. just says unable to add part $db = mysql_connect("tech2000", "wwwguest", "guest"); ----- Original Message ----- From: "Darryl Friesen" <Darryl.Friesen@usask.ca> To: <php-db@lists.php.net> Sent: Thursday, January 25, 2001 2:02 PM Subject: Re: [PHP-DB] insert into mysql > > > //--------------------------- Add part ---------------------------------- > > if($act=="ADD"){ > > $sql="INSERT INTO ecomm (ID,part) VALUES > > ('$sid','$spp'),$db"; > > if(! @mysql_db_query("$sql")){ > > echo("Unable to add part."); mysql_close($db);exit();} } > > > > Why does this not work? > > > > You're INSERT query is wrong. Take the ',$db' off the end. > > $sql = "INSERT INTO ecomm (ID,part) VALUES ('$sid','$spp')"; > > > - Darryl > > ---------------------------------------------------------------------- > Darryl Friesen, B.Sc., Programmer/Analyst Darryl.Friesen@usask.ca > Education & Research Technology Services, > http://gollum.usask.ca/ > Department of Computing Services, > University of Saskatchewan > ---------------------------------------------------------------------- > "Go not to the Elves for counsel, for they will say both no and yes" > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#6184) next »