gpt4 book ai didi

php - inner join with php 浏览器显示语法错误

转载 作者:行者123 更新时间:2023-11-29 05:29:11 26 4
gpt4 key购买 nike

<分区>

我有一个带内连接的选择查询。我在 phpmyadmin 中尝试它工作正常。但是当我在浏览器中尝试时,它会显示此错误消息:

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 s.specialization_name FROM user u INNER JO' at line 1

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com