我有一个带有内部连接的选择查询。我在 phpmyadmin 中尝试它工作正常。但是当我在浏览器中尝试它时,它会显示以下错误消息:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“SELECT s.specialization_name FROM user u INNER JO”附近使用正确的语法
member_search.php
/default message on top of the result display
$querySrting="WHERE registered_date!='' ORDER BY registered_date ASC ";
$queryMSG="Showing newest to oldest memebrs by default";
///IF STATMENT TO DISTINGOUICH SEARCHING
if(isset($_POST['listbyq']))
{
if($_POST['listbyq']=="newest_members")
{
$querySrting="WHERE registered_date!='' ORDER BY registered_date DESC " or die(mysql_error());
$queryMSG="Showing senior to oldest memebrs";
}
elseif($_POST['listbyq']=="by_specialization")
{
$querySrting="SELECT specialization_name FROM members u
INNER JOIN specialization s
ON u.specialization=s.specialization_id";
$result = mysql_query($querySrting) or die(mysql_error());
$queryMSG="showing members with specs";
}
elseif($_POST['listbyq']=="by_firstname")
{
$fname = $_POST['fname'];
$fname = stripcslashes($fname);
$fname = strip_tags($fname);
$querySrting="WHERE first_name LIKE '%$fname%'"or die(mysql_error());
$queryMSG="Showing member with the name you searched for";
}
}
///******query the member data using the queryString*******//
$sql = mysql_query("SELECT user_id, first_name, last_name, birth_date, specialization, registered_date FROM members $querySrting") or die(mysql_error());
//**********************outputlist*********************************//
$outputlist="";
while($row = mysql_fetch_array($sql))
{
$id=$row['user_id'];
$firstname=$row['first_name'];
$lastname=$row['last_name'];
$birthdate=$row['birth_date'];
$spec = $row['specialization'];
$registereddate=$row['registered_date'];
////***********for the upload image*************************//
$check_pic="members/$id/image01.jpg";
$default_pic="members/0/image01.jpg";
if(file_exists($check_pic))
{
$user_pic="<img src=\"$check_pic\"width=\"120px\"/>";
}
else
{
$user_pic="<img src=\"$default_pic\"width=\"120px\"/>";
}
$outputlist.='
<table width="100%">
<tr>
<td width="23%" rowspan="3"><div style="height:120px;overflow:hidden;"><a href = "http://localhost/newadamKhoury/profile.php?user_id='.$id.'" target="_blank">'.$user_pic.'</a></div></td>
<td width="14%"><div align="right">Name:</div></td>
<td width="63%"><a href = "http://localhost/newadamKhoury/profile.php?user_id='.$id.'" target="_blank">'.$firstname.' '.$lastname.'</a></td>
</tr>
<tr>
<td><div align="right">Birth date:</div></td>
<td>'.$birthdate.'</td>
</tr>
<tr>
<td><div align="right">Registered:</div></td>
<td>'.$registereddate.'</td>
</tr>
<tr>
<td><div align="right">His Job:</div></td>
<td>'.$spec.'</td>
</tr>
</table>
<hr />
';
}//close while