Re: Trying to read the value of a var...

From: Date: Sat, 10 May 2003 13:56:30 +0000
Subject: Re: Trying to read the value of a var...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-147114@lists.php.net to get a copy of this message
On Saturday 10 May 2003 03:55, Amanda McComb wrote: [snip] > However, when all fields are correct and I go to insert it into the > database, I don't get the correct value: > > while ($search_result = mysql_fetch_array($search_results)) { > $name2 = "quantity_"; > $name2 .= $search_result['conference_component_cd']; > ?><BR><? > echo $$name2; //HERE, the correct value displays What exactly does it display? > if ($$name2){ > > $query2 = "INSERT INTO customer_conference_t "; > $query2 .= "(customer_conference_cd, customer_id, > conference_component_cd, quantity) "; > $query2 .= " values('','$customer_id', > $search_result[conference_component_cd], $$name2)"; > > echo $query2;?><BR><? //Here, it displays like this > //$quantity_10 And what exactly does this display? There are very few cases where the use of variable variables is justified. I suggest you change to using arrays instead -- they're easier to understand and more logical to process. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Rubber bands have snappy endings! */

« previous php.general (#147114) next »