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

這篇文章有幫助嗎?

 列印本文

Also Read

php/mysql q

Posted by Sammy89, 02-14-2011, 03:45 PMis there a better way to write: Posted by...

Question for PayPal programmer expert!

Posted by pronet-hq, 09-11-2008, 11:30 AMI am creating a website that allows sellers to offer...

yaph killed after start

Posted by SysTeam, 09-16-2008, 03:04 PMHi, I have problem. I install Yet Another Proxy Hunter,...

MySQL error code: 2006

Posted by Glostar, 04-18-2009, 03:54 AMI update MySQL from version 4 to 5.0.67-community. Now, I...

PHP bug? PHP can't resolve domains, server can..

Posted by Drifter13, 07-23-2007, 10:51 PMHello fellow techs, I'm having a strange problem. My...