Re: [PHP] MySQL/PHP Associative Array Insert

2003-02-02 Thread Matt
- Original Message -
From: CDitty [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, February 01, 2003 11:26 AM
Subject: [PHP] MySQL/PHP Associative Array Insert


 A co-worker is teaching me to move to the next level in php. I have
 started using associative arrays for my scripts, but I am having a problem
 using them to do an insert into MySQL. Can someone give me an example of
 how to do an insert to the database using these arrays? My array is
 this...$item['itemID']

The trick is to wrap array references in curly braces inside double quoted
strings.

// some data
$array['one'] = 'one';
$array['two'] = 'two';
// build the sql
$sql = INSERT into table (field1,field2)
values('{$array['one']}','{array['two']}';



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] MySQL/PHP Associative Array Insert

2003-02-01 Thread @ Nilaab
Yes Chris,

When you add the item to the database, make sure to leave out the single
quotes inside the brackets of the associative array. For example:

Instead Of:
$item['itemID']

Do This:
$item[itemID]

Example Query:
$query = SELECT * FROM items WHERE '$item[itemID]';

Hope that helps.

 -Original Message-
 From: CDitty [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, February 01, 2003 10:26 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] MySQL/PHP Associative Array Insert


 A co-worker is teaching me to move to the next level in php. I have
 started using associative arrays for my scripts, but I am having a problem
 using them to do an insert into MySQL. Can someone give me an example of
 how to do an insert to the database using these arrays? My array is
 this...$item['itemID']

 Thanks
 Chris



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] MySQL/PHP Associative Array Insert

2003-02-01 Thread @ Nilaab
Oops, I forgot the double quotes at the end of the example query from the
last email.
This is how it should be:

Example Query:
$query = SELECT * FROM items WHERE '$item[itemID]';





 -Original Message-
 From: @ Nilaab [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, February 01, 2003 1:00 PM
 To: [EMAIL PROTECTED]
 Subject: RE: [PHP] MySQL/PHP Associative Array Insert


 Yes Chris,

 When you add the item to the database, make sure to leave out the single
 quotes inside the brackets of the associative array. For example:

 Instead Of:
 $item['itemID']

 Do This:
 $item[itemID]

 Example Query:
 $query = SELECT * FROM items WHERE '$item[itemID]';

 Hope that helps.

  -Original Message-
  From: CDitty [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, February 01, 2003 10:26 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP] MySQL/PHP Associative Array Insert
 
 
  A co-worker is teaching me to move to the next level in php. I have
  started using associative arrays for my scripts, but I am
 having a problem
  using them to do an insert into MySQL. Can someone give me an example of
  how to do an insert to the database using these arrays? My array is
  this...$item['itemID']
 
  Thanks
  Chris
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php