Tobie Hillier
Quest Website Design http://www.questwebsitedesign.co.uk/ http://www.questwebsitedesign.co.uk/website_design_rotherham.html http://www.questwebsitedesign.co.uk/website_design_chesterfield.html --- On Tue, 21/7/09, Pete <c...@hotcosta.com> wrote: From: Pete <c...@hotcosta.com> Subject: Re: [php_mysql] Usng variables and sprintf To: php_mysql@yahoogroups.com Date: Tuesday, 21 July, 2009, 8:18 PM In message <CB70B5CCE4319D4ABEA 54BB12D3117CFE45 2...@southcotpdc. southcot. org>, Charlie Markwick <c...@southcot. com> writes >Given:- > >$strFields = 'Gender=%s, UserName=%s' ; >$strValues = '"Male","charlie" ,"nhy01"' ; > >why does:- > >$strUpdateSQL = sprintf('UPDATE UserTable SET ' . $strFields . ' WHERE >ID=%s', "Male","charlie" ,"nhy01") ; > >work, while:- > >$strUpdateSQL = sprintf('UPDATE UserTable SET ' . $strFields . ' WHERE >ID=%s', $strValues); > >doesn't? > >Charlie Because no matter what you put into $strValues, it is still only a single string, no matter how many quotes it contains. And you need 2 strings (or is it 3? $strFields says 2, $strValues says 3) -- Pete Clark Hot Costa - Local Spain http://www.hotcosta .com [Non-text portions of this message have been removed]