homepage Welcome to WebmasterWorld Guest from 54.226.93.128
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Variables in an array ?
turbohost




msg:3658672
 5:08 pm on May 25, 2008 (gmt 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',
);

 

rob7591




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

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

cameraman




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

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

turbohost




msg:3658688
 5:48 pm on May 25, 2008 (gmt 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.

cameraman




msg:3658692
 5:54 pm on May 25, 2008 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved