当我使用 LEFT() 使用以下代码从数据库中获取值时
$select="SELECT LEFT(description,500) FROM tbl_news where id='$id'";
$quer=mysqli_query($select);
$fetch=mysqli_fetch_array($quer);
$descr=$fetch['description'];
echo $descr;
该值没有回显...... LEFT() 在 while 循环中没有工作吗?
在函数的列上提供一个ALIAS
传递。
$select="SELECT LEFT(description,500) description FROM tbl_news where id='$id'";
作为旁注,SQL Injection
如果变量的值(s)来自外部,则查询很容易受到攻击。请看下面的文章,了解如何预防。通过使用PreparedStatements
,您可以摆脱在值周围使用单引号。