解析错误:语法错误,第51行___中的意外T_RETURN

时间:2020-11-26 22:47:21

I'm trying to fetch a single row.

我要去取一行。

$con = mysqli_connect("mydb", "joakim", "password", "db");

$sql = "SELECT *, DATE_FORMAT(dato, '%e. %b kl %H:%i') AS fdato FROM bidrag WHERE bidrag_id = $bidrag_id";

$query = mysqli_query($con, $sql);

$row = mysqli_fetch_assoc($query)

return $row; <--- This line

However this makes this error message:

然而,这就产生了以下错误信息:

Parse error: syntax error, unexpected T_RETURN in /iu/cube/u0/s181322/www/prosjekt/klasser/Bidrag.php on line 51

解析错误:语法错误,意外的T_RETURN in /iu/cube/u0/s181322/www/ replacjekt /klasser/Bidrag。php在51行

3 个解决方案

#1


1  

Missing a semicolon after the penultimate line ($row = mysqli_fetch_assoc($query))

倒数第二行后面缺少一个分号($row = mysqli_fetch_assoc($query))

#2


0  

You're missing a semicolon ; on the line before the error. Keep in mind that when getting an error in PHP, 9/10 times the error isn't on the line indicated.

你漏掉了一个分号;在出错之前。记住,当在PHP中获得错误时,9/10乘以错误不在指示的行上。

#3


0  

You missed a semicolon after the line before :

您在前面的行后漏掉了一个分号:

$con = mysqli_connect("mydb", "joakim", "password", "db");

$sql = "SELECT *, DATE_FORMAT(dato, '%e. %b kl %H:%i') AS fdato FROM bidrag WHERE bidrag_id = $bidrag_id";

$query = mysqli_query($con, $sql);

$row = mysqli_fetch_assoc($query); // There

return $row;

#1


1  

Missing a semicolon after the penultimate line ($row = mysqli_fetch_assoc($query))

倒数第二行后面缺少一个分号($row = mysqli_fetch_assoc($query))

#2


0  

You're missing a semicolon ; on the line before the error. Keep in mind that when getting an error in PHP, 9/10 times the error isn't on the line indicated.

你漏掉了一个分号;在出错之前。记住,当在PHP中获得错误时,9/10乘以错误不在指示的行上。

#3


0  

You missed a semicolon after the line before :

您在前面的行后漏掉了一个分号:

$con = mysqli_connect("mydb", "joakim", "password", "db");

$sql = "SELECT *, DATE_FORMAT(dato, '%e. %b kl %H:%i') AS fdato FROM bidrag WHERE bidrag_id = $bidrag_id";

$query = mysqli_query($con, $sql);

$row = mysqli_fetch_assoc($query); // There

return $row;