Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse error

Status
Not open for further replies.

crjo

Programmer
Jul 3, 2001
15
US
The following statement works fine in MySQL query editor, and DWMX recordset builder but gives the following error when trying to display in browser(PHP):
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING...

Here's my SQL:
SELECT residents.Resident_ID,
Max(IF(residents.Resident_ID=admissionassessment.Resident_ID,
DATE_FORMAT(admissionassessment.AdmissionAssessmentDate,'%m/%d/%Y'),"")) AS AdmissionAssessmentDate,
DATE_ADD(admissionassessment.AdmissionAssessmentDate,INTERVAL 90 DAY) AS AssessmentDueDate,
Max(IF(residents.Resident_ID=painassessment.Resident_ID,
DATE_FORMAT(painassessment.PainAssessmentDate,'%m/%d/%Y'),"")) AS PainAssessmentDate,
Max(IF(residents.Resident_ID=medicalrecords.Resident_ID,medicalrecords.MedicalRecordDate,"")) AS MedicalRecordDate
FROM ((admissionassessment
RIGHT JOIN residents ON admissionassessment.Resident_ID=residents.Resident_ID)
LEFT JOIN painassessment ON residents.Resident_ID=painassessment.Resident_ID)
LEFT JOIN medicalrecords ON residents.Resident_ID=medicalrecords.Resident_ID
GROUP BY residents.Resident_ID;
 
If I'm right, then it's a fairly simple PHP problem.

I imagine that when you use your query in PHP you make it a string by enclosing it in double quotes - however this is a problem because your SQL query also contains double quotes.

Either replace the SQL double quotes with single quotes, or escape them (replace them with \").
 
That was the problem. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top