Jump to content

[SOLVED] Output to create variables?


Recommended Posts

Hello.

 

I am trying to get values from a database and make them into variables at the moment i have this code:

 

$result = mysql_query("SELECT * FROM type") 
or die(mysql_error()); 
while ($qry = mysql_fetch_array($result)) {
$name = $qry['name'];
$$name = $_GET['$name'];
}

 

But it doesn't seem to be creating the variables with the $_GET, any ideas or advice?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/109257-solved-output-to-create-variables/
Share on other sites

Try:

 

$$name = $_GET[$name];

 

Variables inside single quotes are not parsed. Therefore, your previous line tried to access the element of the $_GET array that had the key $name, rather than that which had a key which was the value of $name.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.