0

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

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

TwoStraws
  • 12,862
  • 3
  • 57
  • 71
zakariya
  • 21
  • 1
  • 1
  • 1
  • 2
    As it has been said, and will continue to be said, do **NOT** use mysql_* commands, they are deprecated. Please consider using PDO or mysqli_* Edit: You are also not sanitizing inputs, which would leave the entire page open to SQL injection attacks. I'm guessing this is a local server and you're just learning, so I'm hoping you don't get discouraged. Good luck. – Xander Luciano Dec 18 '15 at 23:49

1 Answers1

6

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

$sender = $_GET['senderr']

It should be:

$sender = $_GET['senderr'];
TwoStraws
  • 12,862
  • 3
  • 57
  • 71
  • While this is exactly the solution for this issue, it's an off-topic question - because it's a simple typo. Also, this could've easily been a comment instead :-) – Qirel Dec 19 '15 at 00:12