Welcome to WebmasterWorld Guest from 54.147.63.124

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Variables in an array ?

     
5:08 pm on May 25, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Aug 29, 2003
posts:244
votes: 0


Hi Guys,

Anybody knows how I can use a variable in an array ? I tried this, but it doesn't work

$item= array(
'title' => $title,
'description' => $description,
'price' => '1.00',
);

5:17 pm on May 25, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 5, 2008
posts:112
votes: 0


$item = array();
$item['title'] = $title;
$item['description'] = $description;
$item['price'] = '1.00';
5:38 pm on May 25, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Jan 16, 2007
posts:914
votes: 0


There's nothing wrong with what you posted.
What error are you getting?
5:48 pm on May 25, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Aug 29, 2003
posts:244
votes: 0


I don't get an error. I'm using this in a sql query. When I run the query the data from the variables is not present in the table. When I use the same query with strings in the array, the information is added to the table. That's why I think there is a problem with the way I use variables in the array.
5:54 pm on May 25, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Jan 16, 2007
posts:914
votes: 0


Something else is going on, like maybe it's not reaching the lines that set the variable. Try doing a print_r or var_dump of $item right after you set it. If it's getting set, try moving the var_dump down the script some until you get to the sql. If you don't get anywhere post the relevant section of the script so we can look at it.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members