Sql Query with PHP, need Help
Posted: Mon Jul 28, 2003 11:51 pm
Hey thanks for taking a look, I am trying to to access data through a form and i am incountering a couple problems. This is the error i am getting:
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT sa.AgencyID FROM AgencyAreas aa"
here is the code for the query:
$result = mysql_query("SELECT ag.AgencyID, ag.CompanyName, ag.Address, ag.StateOrProvince, ag.City, ag.PostalCode
FROM Agencies ag
WHERE ag.StateOrProvince ='$province'
AND ag.AgencyID IN ( SELECT sa.AgencyID
FROM AgencyAreas aa
INNER JOIN Areas ar ON (aa.AreaServedID=
ar.AreaServedID)
WHERE a.AreaServed LIKE '%$city')
AND ag.AgencyID IN ( SELECT as.AgencyID
FROM AgencyServices
WHERE ServiceID IN ($services))"
) or die("Invalid query: " . mysql_error() );
// $services is a check box array
what i am trying to do is to get the relevent information based on the area the agency served based on a text field search and services provided based on a check box query. I hope this makes sense, if not sorry my brain is mush right now. Thanks again
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT sa.AgencyID FROM AgencyAreas aa"
here is the code for the query:
$result = mysql_query("SELECT ag.AgencyID, ag.CompanyName, ag.Address, ag.StateOrProvince, ag.City, ag.PostalCode
FROM Agencies ag
WHERE ag.StateOrProvince ='$province'
AND ag.AgencyID IN ( SELECT sa.AgencyID
FROM AgencyAreas aa
INNER JOIN Areas ar ON (aa.AreaServedID=
ar.AreaServedID)
WHERE a.AreaServed LIKE '%$city')
AND ag.AgencyID IN ( SELECT as.AgencyID
FROM AgencyServices
WHERE ServiceID IN ($services))"
) or die("Invalid query: " . mysql_error() );
// $services is a check box array
what i am trying to do is to get the relevent information based on the area the agency served based on a text field search and services provided based on a check box query. I hope this makes sense, if not sorry my brain is mush right now. Thanks again