Ok, just when I thought I knew what I was doing...
The code below was my attempt to get a list of orchestra positions (violin, cello, etc.) with a list of the musicians that play that instrument below it. However, nothing is coming out on the page.
The database connection is good and there are no PHP or mySQL errors. I was assuming that the problem comes here:
if ($instrument == $musicianInstrument) {... ...}
but even when that is commented out, there still isn't any display on the page.
Any suggestions? I tried to include all the pertinent code below.
*** Note: I've edited the code here to reflect changes I made after Cupid's post***
$musiciansresult = mysql_query("select ID, name, email, instrument, position from musicians");
if (!$musiciansresult) {
echo("<p>Error performing query:" . mysql_error() . "<p>");
exit();
}
$instrumentsresult = mysql_query("select ID, name, listOrder from instruments");
if (!$instrumentsresult) {
echo("<p>Error performing query:" . mysql_error() . "<p>");
exit();
}
Thanks for the note and sorry about the missing bracket... a cut and paste error rather than coding. I am copying the code to the bottom of this post... hopefully I'll get it right this time.
I will add that the page loads with no PHP errors and there is data in each referenced column.
Also I have one of these just after each query (I didn't post it the first time to make the post shorter -- a mistake, I now realize):
Yes, you can say that "or die()" is analogous to what you've written.
As far as I can tell, I don't see anything obvious that would lead to this. Are you positive that mysql_connect() is working? Also, did you select a database with mysql_select()?
I issolated that section of code into it's own page and the first part of it worked and I got a mySQL error for the second part.
That's when I realized that right in the middle of the code, "musiciansresult" becomes "musicianresult" (I suppose I was subconciously thinking that way since I was only getting results for one musician at a time... )
Thank you for your help! I learned a couple things and will use "or die()" in the future (just as effective and less messy than "if (!$variable)...")
Bookmarks