我一直在窃听这个,但无法得到这个工作。这有什么问题?这个SQL查询为什么不起作用?
$query="Select studentid,firstname,lastname,pts from students where collegeid=4";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$pts=$row['pts'];
$name=$row['firstname']." ".$row['lastname'];
$rank= mysql_num_rows(queryMysql("Select distinct pts from students where pts>=$pts"));
echo<<<_END
<a href="student_profile.php?studentid=$row[studentid]" style="text-decoration: none;">
<div class="apps_each your_rank">
<span style="margin-right:5px;">$rank</span>
<div class="dp_small_c"><img class="dp_small" src="upload/$row[studentid].jpg"/></div>
<span class="apps_names">$name</span>
<div style="float:right">
<img src='pts.png' /><span>$row[pts]</span>
<img src='level.png' /><span>Level 1</span>
</div>
</div>
</a>
_END;
错误:
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 '' at line 1.
令人惊讶地,下面一(除去WHERE子句)的工作原理。为什么?
$row=mysql_fetch_array(mysql_query("Select studentid,pts,firstname,lastname from students"));
表结构:
一切都很好用表及其列,因为此查询的工作地方一样,只是不在这里!
这是从您的非工作代码直接复制/粘贴?另外,MySQL扩展不好(不推荐); PDO/MySQLi好 – Phil
是的,这是我的代码复制粘贴。最近我一直在努力学习PDO。 – kamal0808
等一下,该代码不会产生该错误。你需要'mysql_error'。请将* real *代码添加到您的问题中 – Phil