[PHP] Problem creating array from MySql query
What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating array from MySql query
It helps if you show us all your code, not just what you think we might need. For isntance, what does your mysql_query() statement look like? Does it have an or die(mysql_error())) clause? - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:04 AM Subject: [PHP] Problem creating array from MySql query What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- 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] Problem creating array from MySql query
Thanks for taking a look at this. ?php mysql_connect (, , ); mysql_select_db (); $result = mysql_query(SELECT * FROM clubs WHERE id=$id); $row = mysql_fetch_array($result); print Reading affiliations...; $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); print Building array...; $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while print Dumping array...; $count = count($affiliations); print Affiliations:; for ($i=0;i$count;$i++) { print $affiliations[$i]; } ? It does print the affiliations in print $affiliation_row[affiliation]; and it works properly (except for getting the affiliations field) if the line $affiliations[] = $affiliation_row[affiliation]; is commented out. Rick Emery wrote: It helps if you show us all your code, not just what you think we might need. For isntance, what does your mysql_query() statement look like? Does it have an or die(mysql_error())) clause? - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:04 AM Subject: [PHP] Problem creating array from MySql query What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating array from MySql query
where is $id set in (SELECT affiliation FROM club_affiliations WHERE club_id=$id) Also, change to: $query = (SELECT affiliation FROM club_affiliations WHERE club_id=$id; $affiliation_result = mysql_query($query) or die(mysql_error()); The above will help identify bad queries. rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:31 AM Subject: Re: [PHP] Problem creating array from MySql query Thanks for taking a look at this. ?php mysql_connect (, , ); mysql_select_db (); $result = mysql_query(SELECT * FROM clubs WHERE id=$id); $row = mysql_fetch_array($result); print Reading affiliations...; $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); print Building array...; $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while print Dumping array...; $count = count($affiliations); print Affiliations:; for ($i=0;i$count;$i++) { print $affiliations[$i]; } ? It does print the affiliations in print $affiliation_row[affiliation]; and it works properly (except for getting the affiliations field) if the line $affiliations[] = $affiliation_row[affiliation]; is commented out. Rick Emery wrote: It helps if you show us all your code, not just what you think we might need. For isntance, what does your mysql_query() statement look like? Does it have an or die(mysql_error())) clause? - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:04 AM Subject: [PHP] Problem creating array from MySql query What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- 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] Problem creating array from MySql query
Rick Emery wrote: where is $id set in (SELECT affiliation FROM club_affiliations WHERE club_id=$id) The $id comes in from a link and it is the row ID. Also, change to: $query = (SELECT affiliation FROM club_affiliations WHERE club_id=$id; $affiliation_result = mysql_query($query) or die(mysql_error()); Thank you for the suggestion. Since the line print $affiliation_row[affiliation]; Does work, I do not think that it is a bad query in this case but you are correct, I should clean up that section. Thanks! The above will help identify bad queries. rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:31 AM Subject: Re: [PHP] Problem creating array from MySql query Thanks for taking a look at this. ?php mysql_connect (, , ); mysql_select_db (); $result = mysql_query(SELECT * FROM clubs WHERE id=$id); $row = mysql_fetch_array($result); print Reading affiliations...; $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); print Building array...; $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while print Dumping array...; $count = count($affiliations); print Affiliations:; for ($i=0;i$count;$i++) { print $affiliations[$i]; } ? It does print the affiliations in print $affiliation_row[affiliation]; and it works properly (except for getting the affiliations field) if the line $affiliations[] = $affiliation_row[affiliation]; is commented out. Rick Emery wrote: It helps if you show us all your code, not just what you think we might need. For isntance, what does your mysql_query() statement look like? Does it have an or die(mysql_error())) clause? - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:04 AM Subject: [PHP] Problem creating array from MySql query What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating array from MySql query
If you have to comment out $affiliations[] = $affiliation_row[affiliation];, tghen it's not working, because this is the crux of your algorithm. What error are you getting? rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:31 AM Subject: Re: [PHP] Problem creating array from MySql query Thanks for taking a look at this. ?php mysql_connect (, , ); mysql_select_db (); $result = mysql_query(SELECT * FROM clubs WHERE id=$id); $row = mysql_fetch_array($result); print Reading affiliations...; $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); print Building array...; $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while print Dumping array...; $count = count($affiliations); print Affiliations:; for ($i=0;i$count;$i++) { print $affiliations[$i]; } ? It does print the affiliations in print $affiliation_row[affiliation]; and it works properly (except for getting the affiliations field) if the line $affiliations[] = $affiliation_row[affiliation]; is commented out. Rick Emery wrote: It helps if you show us all your code, not just what you think we might need. For isntance, what does your mysql_query() statement look like? Does it have an or die(mysql_error())) clause? - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:04 AM Subject: [PHP] Problem creating array from MySql query What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- 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] Problem creating array from MySql query
No error. It just times out. Rick Emery wrote: If you have to comment out $affiliations[] = $affiliation_row[affiliation];, tghen it's not working, because this is the crux of your algorithm. What error are you getting? rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:31 AM Subject: Re: [PHP] Problem creating array from MySql query Thanks for taking a look at this. ?php mysql_connect (, , ); mysql_select_db (); $result = mysql_query(SELECT * FROM clubs WHERE id=$id); $row = mysql_fetch_array($result); print Reading affiliations...; $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); print Building array...; $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while print Dumping array...; $count = count($affiliations); print Affiliations:; for ($i=0;i$count;$i++) { print $affiliations[$i]; } ? It does print the affiliations in print $affiliation_row[affiliation]; and it works properly (except for getting the affiliations field) if the line $affiliations[] = $affiliation_row[affiliation]; is commented out. Rick Emery wrote: It helps if you show us all your code, not just what you think we might need. For isntance, what does your mysql_query() statement look like? Does it have an or die(mysql_error())) clause? - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:04 AM Subject: [PHP] Problem creating array from MySql query What we are trying to do is build an array from a query. I don't understand why but this is failing on the line $affiliations[] = $affiliation_row[affiliation]; Basically there are two tables in the database, since clubs can have multiple affiliations and the affiliations are not set in stone, there is one table only for affiliations. We are trying to pull the data out of the table for editing. Any tips would be appreciated. Thanks! $affiliation_result = mysql_query(SELECT affiliation FROM club_affiliations WHERE club_id=$id); $affiliations = array(); print Populating array...; //place affiliation data into an array that we can search later while($affiliation_row = mysql_fetch_array($affiliation_result)) { print $affiliation_row[affiliation]; $affiliations[] = $affiliation_row[affiliation]; } //while -- Janyne Kizer -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating array from MySql query
what times out? The query? rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:51 AM Subject: Re: [PHP] Problem creating array from MySql query No error. It just times out. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating array from MySql query
I'm not sure. It sits and spins. If I go to view - source that doesn't yield any additional information. We are trying to build the array and then use in_array to handle the data appropriately. Rick Emery wrote: what times out? The query? rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:51 AM Subject: Re: [PHP] Problem creating array from MySql query No error. It just times out. -- Janyne Kizer CNE-3, CNE-4, CNE-5 Systems Programmer Administrator I NC State University, College of Agriculture Life Sciences Extension and Administrative Technology Services -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating array from MySql query
I believe I've spotted your problem: for ($i=0; i $count;$i++) { You left the $ out. It's looking for a constant named i, which doesn't exist. Janyne Kizer wrote: I'm not sure. It sits and spins. If I go to view - source that doesn't yield any additional information. We are trying to build the array and then use in_array to handle the data appropriately. Rick Emery wrote: what times out? The query? rick People will forget what you said. People will forget what you did. But people will never forget how you made them feel. - Original Message - From: Janyne Kizer [EMAIL PROTECTED] To: Rick Emery [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, February 17, 2003 9:51 AM Subject: Re: [PHP] Problem creating array from MySql query No error. It just times out. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.