SELECT查询中的MySQL语法错误

nec*_*tar -1 mysql syntax select-query

我的代码:

$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;
Run Code Online (Sandbox Code Playgroud)

错误:您的SQL语法有错误; 查看与您的MySQL服务器版本对应的手册,以便在第1行的'photos WHERE id = '12''附近使用正确的语法

Dan*_*llo 5

FROM拼错了.尝试:

$q = "SELECT src FROM photos WHERE id='$fileid'";
Run Code Online (Sandbox Code Playgroud)

此外,虽然与此语法错误无关,但请注意您的代码似乎容易受到SQL注入攻击.