我一直在竊聽這個,但無法得到這個工作。這有什麼問題?這個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