scarhand Posted December 4, 2007 Share Posted December 4, 2007 <?php while ($row = mysql_fetch_array($sql)) { $orig_{$row["name"]} = $row["value"]; } echo "orig_name = $orig_name"; any help is appreciated Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 4, 2007 Share Posted December 4, 2007 It should be working. You're just echoing the wrong variable. try: <?php while ($row = mysql_fetch_array($sql)) { $orig_{$row["name"]} = $row["value"]; } echo 'orig_name = ' . $orig_{$row['name']; ?> Ken Quote Link to comment Share on other sites More sharing options...
scarhand Posted December 4, 2007 Author Share Posted December 4, 2007 well lets say that $row['name'] is = 'username' im trying to get the variable to become $orig_username Quote Link to comment Share on other sites More sharing options...
revraz Posted December 4, 2007 Share Posted December 4, 2007 Which variable? Instead of echoing it, just turn it into a variable. $variable = "orig_name = " . $orig_{$row['name']; Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 4, 2007 Share Posted December 4, 2007 $x['test'] ='teng'; ${'orig_'.$x['test']} = 'i love php'; echo $orig_teng;// echo i love php that works... try Quote Link to comment Share on other sites More sharing options...
teng84 Posted December 4, 2007 Share Posted December 4, 2007 IMO the reason why the above code wont work is that we cant concatenate the existing name of var eg.. $x.'tra'; to become $xtra and that should be ${'xtra'}; or ${$var.'value'} Quote Link to comment Share on other sites More sharing options...
scarhand Posted December 4, 2007 Author Share Posted December 4, 2007 thanks teng Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.