Click to See Complete Forum and Search --> : MySQL PHP Error for 'month'


tomyknoker
04-15-2007, 06:39 AM
I have the following code and for some reason I keep getting "Error, Query failed"... Any ideas?


if($_GET['month']=="1") {
$month = '1';
}
elseif($_GET['month']=="2") {
$month = '2';
}
elseif($_GET['month']=="3") {
$month = '3';
}

//birthday search
$query = mysql_query("SELECT * FROM `tblmembers` WHERE (MONTH(DateOfBirth) = '{$month}') AND `MemberApproved`='A'");
$result = mysql_query($query) or die('Error, query failed');

php_hazard_01
04-15-2007, 07:30 AM
hehe clearly, its from this line...

$query = mysql_query("SELECT * FROM `tblmembers` WHERE (MONTH(DateOfBirth) = '{$month}') AND `MemberApproved`='A'")

try doing some alterations to the query...hehe

aj_nsc
04-15-2007, 09:35 AM
I dont know what you mean php hazard....I can tell you what your error is coming from though tomyknoker....

You have set $query to a mysql query meaning $query is now equal to something like Resource Id #(insert number here)...

Then on your next line you set your result to do mysql_query(Resource Id #(insert number here)) or die....

See what I mean, $query has already been executed and set to a resource id and you're trying to execute it again.