Pete Thanks for responding. I see what you mean. It's 3 strings BTW as the ID is also written: ID=%s. I wondering how I can compile the value statement in advance if this doesn't work.
Charlie -----Original Message----- From: php_mysql@yahoogroups.com [mailto:php_my...@yahoogroups.com] On Behalf Of Pete Sent: 21 July 2009 20:18 To: php_mysql@yahoogroups.com Subject: Re: [php_mysql] Usng variables and sprintf In message <cb70b5cce4319d4abea54bb12d3117cfe45...@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 ------------------------------------ The php_mysql group is dedicated to learn more about the PHP/MySQL web database possibilities through group learning. Yahoo! Groups Links