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 (wwww, xxxx, yyyy); > mysql_select_db (zzzz); > $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