Re: Terrible-PHP and Postgres

From: Date: Sat, 19 Aug 2000 17:09:41 +0000
Subject: Re: Terrible-PHP and Postgres
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2183@lists.php.net to get a copy of this message
I believe you would want to do this to $fname: $fname = AddSlashes($fname); That should encode things correctly for the insert. You can read what the manual has to say about AddSlashes at: http://www.zend.com/manual/function.addslashes.php Hope that helps you out. :) -Josh Hoover jhoover@mac.com > It's terrible, > I have many lines like > > $conn = pg_connect("host=$host port=$port dbname=$database user=$user"); > $sql_item = "insert into carts_cust > values($cartID,'$fname','$lname','$company')"; > $result = pg_exec($conn,$sql_item); > > Seems all right > > But the problem discovered is when there is a ' in a variable. > Example > $fname = coco' > > How is possible solve this problem ? > Thanks > Enrico >

« previous php.db (#2183) next »