Page 1 of 1

issue with SELECT queries

Posted: Wed Oct 19, 2005 7:33 pm
by banned in dc
hey all
first of all, i'm a newbie. so the issue is probably something dumb that i should know. im using php 4.

now for the issue. i'm having some issues with using the SELECT query. i have pages setup so you can add new bands, edit and delete those bands and now i am having problems querying the database to add release information and see if there is existing release information and comparing it to band information.

i can echo out both of the post variables and they come out correctly so i know that isnt the issue. The error i am recieving is this:

mysql_num_rows(): supplied argument is not a valid MySQL result resource

I am guessing that is due to an errror in my SELECT query. what i am trying to do, select the band_name and the release_name from my band and release tables, and my band_to_release lookup table so that the bandname in the POST arrays match the band_name in my band table. then extract any releases they might have and test them to see if the release names = the release name posted.

i apologize if this is really confusing. any help would be greatly appreciated.


here is the part of my code that is screwing up:

Code: Select all

echo $_POST['band'];
//above echo of 'band' array which has 2 strings inside of it
echo $_POST['release_name'];
//above echo produces name of the new release

		//check bands for this release
		$getNames = 'SELECT band_name, release_name
					 FROM band, band_to_release , release
					 WHERE band_name IN "'.$_POST['band'].'"
					 AND band.band_id = band_to_release.band_id
					 AND release.release_id = band_to_release.release_id
					 AND release.release_name = "'.$_POST['release_name'].'"';
		$checkBand = mysql_query($getNames);
		if(mysql_num_rows($checkBand) > 0){
			$error[] = 'This release already exists.';
		}

Posted: Wed Oct 19, 2005 8:26 pm
by feyd
your query failed. emit mysql_error().