Welcome to WebmasterWorld Guest from 54.159.12.17

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Variables in an array ?

     

turbohost

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

10+ Year Member



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',
);

rob7591

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

5+ Year Member



$item = array();
$item['title'] = $title;
$item['description'] = $description;
$item['price'] = '1.00';

cameraman

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

WebmasterWorld Senior Member 5+ Year Member



There's nothing wrong with what you posted.
What error are you getting?

turbohost

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

10+ Year Member



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.

cameraman

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

WebmasterWorld Senior Member 5+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month