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 this answer helpful?

 Print this Article

Also Read

Have they put HW or Software RAID ??

Posted by madrilian, 04-22-2009, 02:05 AMI have recently ordered a new server and I asked for two...

PHP or ASP.NET

Posted by 3DProf4online, 08-27-2008, 07:56 AMHaving found out that Linux hosting is ordered for...

Any way to stop spammers from forging the "From" or "Reply To" fields?

Posted by mifbody, 03-28-2008, 07:21 PMHey guys, Is there any possible way to stop spammers from...

Extension issue

Posted by imad77, 04-20-2009, 10:39 AMHi, I run a Perl/CGI script from a Web page to download...

PHP in htm problem

Posted by HWLJr, 03-04-2010, 07:59 PMI have a Blue Quartz server which seems to run htm, html and...