Escaping quotes

From: Date: Thu, 12 Aug 2004 00:03:32 +0000
Subject: Escaping quotes
Groups: php.general 
Request: Send a blank email to php-general+get-193519@lists.php.net to get a copy of this message
Hi All, I have this expression; $query = "INSERT INTO $table (%s) VALUES (%s)"; $query = sprintf($query, implode(",", $fld), implode(",", $val)); $result = mssql_query($query) or die($errmsg); I am trying to insert values from an array into the database. I keep getting the error that I can't pass column names in this context. I know it's because I'm not enclosing $val in quotes. I've tried a number of variations; implode("\"","\"", $val) implode("\',\'", $val) implode(",", "\"".$val."\"") - This blows up nicely ;-) Where am I going wrong on this? alex hogan ************************************************************************************* The contents of this e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom it is addressed. The views stated herein do not necessarily represent the view of the company. If you are not the intended recipient of this e-mail you may not copy, forward, disclose, or otherwise use it or any part of it in any form whatsoever. If you have received this e-mail in error please e-mail the sender. *************************************************************************************

« previous php.general (#193519) next »