Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 09-24-2004, 03:02 AM   #1 (permalink)
Contributing Member
 
Join Date: 10-14-03
Location: Top left of England, UK
Posts: 243
iTrader: 0 / 0%
Latest Blog:
None

trevHCS is liked by somebodytrevHCS is liked by somebodytrevHCS is liked by somebodytrevHCS is liked by somebodytrevHCS is liked by somebody
Send a message via MSN to trevHCS
PHP - Using assoc. arrays in SQL string

Hopefully that title doesn't put everyone off...

I want to create an SQL string such as...

Code:
$sql = "INSERT INTO client_table (ps_name) VALUES ('$input["ps_name"]')";
...which is then fed to the mysql_query(), but because the value of ps_name is coming from an associative array I'm getting a parsing error
Quote:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
I also tried using ' quotes around the ['ps_name'] bit but that didn't work either and I tried escaping the ' within the brackets, but again failure.


I don't suppose anyone knows of a way around this? I could just drop the data out into temp variables, but I'm sure when they designed PHP4 they probably thought of this?

Cheers
Trev
trevHCS is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-24-2004, 03:49 AM   #2 (permalink)
Contributing Member
 
Join Date: 10-14-03
Location: Top left of England, UK
Posts: 243
iTrader: 0 / 0%
Latest Blog:
None

trevHCS is liked by somebodytrevHCS is liked by somebodytrevHCS is liked by somebodytrevHCS is liked by somebodytrevHCS is liked by somebody
Send a message via MSN to trevHCS
I was going to edit the above, but we seem to have lost the edit button (unless I'm just missing it?).

Anyway, had a brain wave re. the above and tried using

$input[ps_name] instead of $input['ps_name'] and to my total surprise it worked, so now I can use arrays in my SQL statements.

Trev
trevHCS is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
string searching livecoder Computers & Internet 0 08-30-2007 12:14 AM
PHP Appending to MultiDimensional Arrays bytech Coding Forum 5 03-03-2007 07:06 PM
problem with PHP and arrays I think Arenlor Coding Forum 4 01-19-2007 11:35 AM
SME EU - Search Marketing Assoc. EU Nick W Marketing Forum 0 10-25-2004 09:02 AM
Numeric String Pipeline-Webdesign Coding Forum 11 06-16-2004 11:59 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:59 AM.
© Copyright 2008 V7 Inc