SELECT 查询中的 MySQL 语法错误
我的代码:
$fileid = $_GET['imgid'];
$fileid = (int)$fileid; //id is int type in photos table
require 'database.php';
//get the image sourc name
$q = "SELECT src form photos WHERE id='$fileid'";
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if ($result)
{
$row = $result->fetch_object();
$filename = $row->src;
错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“photos WHERE id='12”附近使用的正确语法
My code:
$fileid = $_GET['imgid'];
$fileid = (int)$fileid; //id is int type in photos table
require 'database.php';
//get the image sourc name
$q = "SELECT src form photos WHERE id='$fileid'";
$result = $mysqli->query($q) or die(mysqli_error($mysqli));
if ($result)
{
$row = $result->fetch_object();
$filename = $row->src;
ERROR: 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 'photos WHERE id='12'' at line 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
FROM
拼写错误。尝试:此外,虽然与此语法错误无关,但请注意您的代码似乎容易受到 SQL注入.You have
FROM
misspelled. Try:In addition, while not related to this syntax error, note that your code appears to be vulnerable to SQL Injection.