Putting variables in a string

From: Date: Tue, 28 Aug 2001 17:54:25 +0000
Subject: Putting variables in a string
Groups: php.general 
Request: Send a blank email to php-general+get-64854@lists.php.net to get a copy of this message
I am trying to make a string that will contain variables. The resulting string will be a sql query string and must look something like " update $table_name set key='$key' , next='$next' where id = $id" Since the variable name is the same as the key name, I tried to generate this string with a foreach statement looking something like this: foreach( $myrow as $key=>$val) { $sql .= "$key = ' \$$key ' ,"; } This then makes the string look as follow: key='$key',next='$next', and I just add the rest of the string to the front and back, yet, when I now try to use this string in the mysql_query() function, it does not recognise the '$key' and '$next' as variables and add them into the db as $key and $next. I need to know how I am going to make this string "recognise" the variables in them.

« previous php.general (#64854) next »