Jump to content

[SOLVED] SQL Error


abch624

Recommended Posts

Hi All,

 

I have this code

echo $sql = "SELECT DISTINCT E.name, E.dateOfBirth, E.amisID, E.jamaat, F.institute, G.completedUniversity, G.currentUniversity, D.A* AS aStarGcse, D.A AS aGcse, D.B AS bGcse, D.C AS cGcse, D.D AS dGcse, D.E AS eGcse, D.F AS fGcse, D.G AS gGcse, A.A* AS aStarALevel, A.A AS aALevel, A.B AS bALevel, A.C AS cALevel, A.D AS dALevel, A.E AS eALevel, A.F AS fALevel, B.employed, B.quidanceRequired, C.subjects FROM $tbl_personaldetails E JOIN $tbl_study F ON (E.studyID = F.studyID) JOIN $tbl_university G ON (G.universityID = F.universityID) JOIN $tbl_gcseresult D ON (D.gcseID = F.gcseID) JOIN $tbl_currentsubjects C ON (C.currentSubjectsID = F.currentSubjectsID) JOIN $tbl_careerguidance B ON (B.careerGuidanceID = F.careerGuidanceID) JOIN $tbl_alevelresult A ON (A.aLevelID = A.aLevelID) WHERE E.name LIKE '%$name%' ORDER BY E.name";
if (mysql_query($sql)) {
echo "yes";
}
else {
mysql_error();
}

 

This sql statement generates this error :

SELECT DISTINCT E.name, E.dateOfBirth, E.amisID, E.jamaat, F.institute, G.completedUniversity, G.currentUniversity, D.A* AS aStarGcse, D.A AS aGcse, D.B AS bGcse, D.C AS cGcse, D.D AS dGcse, D.E AS eGcse, D.F AS fGcse, D.G AS gGcse, A.A* AS aStarALevel, A.A AS aALevel, A.B AS bALevel, A.C AS cALevel, A.D AS dALevel, A.E AS eALevel, A.F AS fALevel, B.employed, B.quidanceRequired, C.subjects FROM personaldetails E JOIN study F ON (E.studyID = F.studyID) JOIN university G ON (G.universityID = F.universityID) JOIN gcseresult D ON (D.gcseID = F.gcseID) JOIN currentsubjects C ON (C.currentSubjectsID = F.currentSubjectsID) JOIN careerguidance B ON (B.careerGuidanceID = F.careerGuidanceID) JOIN alevelresult A ON (A.aLevelID = A.aLevelID) WHERE E.name LIKE '%Zahid%' ORDER BY E.name
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Talim\searchdo.php on line 53

 

Please advise on why i get this error.

 

Thanks - Zahid

Link to comment
https://forums.phpfreaks.com/topic/121561-solved-sql-error/
Share on other sites

echo $sql = "SELECT DISTINCT E.name, E.dateOfBirth, E.amisID, E.jamaat, F.institute, G.completedUniversity, G.currentUniversity, D.A* AS aStarGcse, D.A AS aGcse, D.B AS bGcse, D.C AS cGcse, D.D AS dGcse, D.E AS eGcse, D.F AS fGcse, D.G AS gGcse, A.A* AS aStarALevel, A.A AS aALevel, A.B AS bALevel, A.C AS cALevel, A.D AS dALevel, A.E AS eALevel, A.F AS fALevel, B.employed, B.quidanceRequired, C.subjects FROM $tbl_personaldetails E JOIN $tbl_study F ON (E.studyID = F.studyID) JOIN $tbl_university G ON (G.universityID = F.universityID) JOIN $tbl_gcseresult D ON (D.gcseID = F.gcseID) JOIN $tbl_currentsubjects C ON (C.currentSubjectsID = F.currentSubjectsID) JOIN $tbl_careerguidance B ON (B.careerGuidanceID = F.careerGuidanceID) JOIN $tbl_alevelresult A ON (A.aLevelID = A.aLevelID) WHERE E.name LIKE '%$name%' ORDER BY E.name";
if (mysql_query($sql)) {
echo "yes";
}
else {
mysql_error();
}

if (mysql_num_rows($result) > 0) {
while ($row=mysql_fetch_array($result)) {
	$num = $num + 1;
	echo $row['name'];
}
}

Link to comment
https://forums.phpfreaks.com/topic/121561-solved-sql-error/#findComment-626954
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.