Darn I am missing one simple step with this PHP array please help

Posted by lexington, 02-10-2011, 09:48 AM
Hello, I have been up all night so my brain must be fried since I cannot figure this simple thing out. I am trying to assign values from an array to a variable. I can echo the $key and $val just fine, but when I try to assign them to a variable, it doesn't work. I *think* I have to use $config[] or $config = array() before it starts, but neither are working so I am doing something wrong. Here is the code example: That works just fine, when you echo the data it shows the key and it's value. However I am trying to make a variable use those values, like: So that each $config[ name ] equals $row[ value ] and for some reason it doesn't work. I assume I need to add something first with $config and $row to make the values assign to those variables. They just appear empty on the page. Please help. Last edited by lexington; 02-10-2011 at 09:58 AM.

Posted by GGWH-James, 02-10-2011, 09:57 AM

Posted by Squidix - SamBarrow, 02-10-2011, 09:58 AM
You're trying to pull something out of $row but I don't see you ever creating it.

Posted by lexington, 02-10-2011, 10:04 AM
Thanks GGWH-James I did that but the $config[$key] value is still empty. If you echo it on your end does it show? Thanks samb0057, yes you are right I do not know the $row, the $val works now but $config[$key] is still empty.

Posted by GGWH-James, 02-10-2011, 10:06 AM
outputs:

Posted by Squidix - SamBarrow, 02-10-2011, 10:08 AM
James' code looks like it should work. Try this:

Posted by lexington, 02-10-2011, 10:09 AM
Thanks again, it works. I thoguht I could echo each value within the while loop though, like No worries though, all is fine

Posted by lexington, 02-10-2011, 10:11 AM
Oops, nevermind it works. Last edited by lexington; 02-10-2011 at 10:16 AM.

Posted by lexington, 02-10-2011, 10:16 AM
ROFL, oops everything is fine. For some odd reason that array name was not in my original array. Weird I could have sworn I added it, all works now thanks again

Was dit antwoord nuttig?

 Print dit artikel

Lees ook

Genius-hosting??

Posted by Luminance, 09-03-2002, 06:13 PMHello guys, Is there any other company comparable to...

Compromised???

Posted by Chinese Democracy, 04-20-2009, 12:01 PMIt appears that one new sign-up on a shared...

Need to run this shell file in the background every 10 secs

Posted by mikey1090, 03-19-2007, 04:44 PMThe following shell script (a php loop to run a file)...

Data Mirroring Software (Windows)

Posted by ServerFarmer, 03-28-2008, 07:22 PMWhat are some of the most popular data mirror...

how to config my domain ???

Posted by hangnguyen, 03-27-2008, 12:50 PMPlease move this post if I posted on wrong box . I...