解析错误:语法错误,第 7 行 C:\xampp\htdocs\final\newmail.php 中出现意外的“$connection”(T_VARIABLE)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34365585/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:56:16  来源:igfitidea点击:

Parse error: syntax error, unexpected '$connection' (T_VARIABLE) in C:\xampp\htdocs\final\newmail.php on line 7

php

提问by zakariya

When I run this code:

当我运行此代码时:

<?php

$reuser = $_GET['ruser'];
$mail = $_GET['msg']; 
$sender = $_GET['senderr']

$connection = mysql_connect("localhost","root");
mysql_select_db("final");

if(!$connection){
    die('could not connect:'.mysql_error());
}

$sql = "INSERT INTO mails (sender,to,message,)
VALUES ('$sender','$reuser','$mail')";

mysql_query($sql) or die("error".mysql_error());
mysql_close($connection);
?>

I get this error:

我收到此错误:

Parse error: syntax error, unexpected '$connection' (T_VARIABLE) in C:\xampp\htdocs\final\newmail.php on line 7

解析错误:语法错误,第 7 行 C:\xampp\htdocs\final\newmail.php 中出现意外的“$connection”(T_VARIABLE)

I don't know what the problem is – can anyone help me please?

我不知道问题是什么 - 任何人都可以帮助我吗?

回答by TwoStraws

You're missing a semi-colon at the end of this line:

您在此行的末尾缺少分号:

$sender = $_GET['senderr']

It should be:

它应该是:

$sender = $_GET['senderr'];