Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Matt M.
 if ( is_array( $_SESSION['l_industry'] ) ) {
 foreach ( $_SESSION['l_industry'] as $p ) {
 $query = INSERT INTO Profiles_Industries (ProfileID,
 IndID)
 VALUES ($LID, $p);
 }

do you have a } for the if statement?

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Where would that go?

Stuart

--- Matt M. [EMAIL PROTECTED] wrote:

  if ( is_array( $_SESSION['l_industry'] ) ) {
  foreach ( $_SESSION['l_industry'] as $p )
 {
  $query = INSERT INTO Profiles_Industries
 (ProfileID,
  IndID)
  VALUES ($LID, $p);
  }
 
 do you have a } for the if statement?
 

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Matt M.
if ( is_array( $_SESSION['l_industry'] ) ) {
foreach ( $_SESSION['l_industry'] as $p ) {
$query = INSERT INTO Profiles_Industries (ProfileID,IndID) VALUES
($LID, $p);
} //foreach ( $_SESSION['l_industry'] as $p )
} //if ( is_array( $_SESSION['l_industry'] ) )

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Yep, I had found it shortly before.
Only it's not looping.  It is taking last value only.

Stuart


--- Matt M. [EMAIL PROTECTED] wrote:

 if ( is_array( $_SESSION['l_industry'] ) ) {
   foreach ( $_SESSION['l_industry'] as $p ) {
   $query = INSERT INTO Profiles_Industries
 (ProfileID,IndID) VALUES
 ($LID, $p);
   } //foreach ( $_SESSION['l_industry'] as $p )
 } //if ( is_array( $_SESSION['l_industry'] ) )
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Matt M.
where is your insert statement? I am guessing it is after your loop


if ( is_array( $_SESSION['l_industry'] ) ) {
foreach ( $_SESSION['l_industry'] as $p ) {
$query = INSERT INTO Profiles_Industries (ProfileID,IndID) VALUES
($LID, $p);
/This is where your insert statement should
be**/
} //foreach ( $_SESSION['l_industry'] as $p )
} //if ( is_array( $_SESSION['l_industry'] ) )

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Actually it did just loop.  I need to test again.  

The insert statement is the the one $query = 
So it's after yes, but contained in the braces, like
you diagram below.

Stuart
--- Matt M. [EMAIL PROTECTED] wrote:

 where is your insert statement? I am guessing it is
 after your loop
 
 
 if ( is_array( $_SESSION['l_industry'] ) ) {
   foreach ( $_SESSION['l_industry'] as $p ) {
   $query = INSERT INTO Profiles_Industries
 (ProfileID,IndID) VALUES
 ($LID, $p);
 /This is where your insert
 statement should
 be**/
   } //foreach ( $_SESSION['l_industry'] as $p )
 } //if ( is_array( $_SESSION['l_industry'] ) )
 

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



Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Brent Baisley
When are you actually performing the insert into the database? The code 
you posted is only changing the value of the variable $query. You also 
need to have the database function to insert into the database. 
Assuming it MySQL:
...
foreach(...) {
	$query = INSERT INTO ...;
	mysql_query($query);
}

On Oct 15, 2004, at 4:40 PM, Stuart Felenstein wrote:
Yep, I had found it shortly before.
Only it's not looping.  It is taking last value only.
Stuart
--- Matt M. [EMAIL PROTECTED] wrote:
if ( is_array( $_SESSION['l_industry'] ) ) {
foreach ( $_SESSION['l_industry'] as $p ) {
$query = INSERT INTO Profiles_Industries
(ProfileID,IndID) VALUES
($LID, $p);
} //foreach ( $_SESSION['l_industry'] as $p )
} //if ( is_array( $_SESSION['l_industry'] ) )
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Array and insert statement throws error

2004-10-15 Thread Stuart Felenstein
Hopefully these functions will explain it.
I'm starting the transaction, then provided it takes
with no errors it gets the commit

function begin()
{
mysql_query(BEGIN);
}
function commit()
{
mysql_query(COMMIT);
}
function rollback()
{
mysql_query(ROLLBACK);
}

begin();
$query = INSERT INTO...

$result = mysql_query($query);
--- Brent Baisley [EMAIL PROTECTED] wrote:

 When are you actually performing the insert into the
 database? The code 
 you posted is only changing the value of the
 variable $query. You also 
 need to have the database function to insert into
 the database. 
 Assuming it MySQL:
 ...
 foreach(...) {
   $query = INSERT INTO ...;
   mysql_query($query);
 }
 
 On Oct 15, 2004, at 4:40 PM, Stuart Felenstein
 wrote:
 
  Yep, I had found it shortly before.
  Only it's not looping.  It is taking last value
 only.
 
  Stuart
 
 
  --- Matt M. [EMAIL PROTECTED] wrote:
 
  if ( is_array( $_SESSION['l_industry'] ) ) {
 foreach ( $_SESSION['l_industry'] as $p ) {
 $query = INSERT INTO Profiles_Industries
  (ProfileID,IndID) VALUES
  ($LID, $p);
 } //foreach ( $_SESSION['l_industry'] as $p )
  } //if ( is_array( $_SESSION['l_industry'] ) )
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit:
 http://www.php.net/unsub.php
 
 
 -- 
 Brent Baisley
 Systems Architect
 Landover Associates, Inc.
 Search  Advisory Services for Advanced Technology
 Environments
 p: 212.759.6400/800.759.0577
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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