Parse error: syntax error, unexpected ‘$connection’ (T_VARIABLE) in C:xampphtdocsfinal ewmail.php on line 7


Parse error: syntax error, unexpected '$connection' (T_VARIABLE) in C:xampphtdocsfinal
ewmail.php on line 7

本问题已经有最佳答案,请猛点这里访问。

当我运行此代码时:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?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);
?>

我得到这个错误:

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

我不知道是什么问题-有人能帮我吗?


这行末尾缺少一个分号:

1
$sender = $_GET['senderr']

应该是:

1
$sender = $_GET['senderr'];