Parse error: syntax error, unexpected end of file

Hi there,
Problem:
I got this error: Parse error: syntax error, unexpected end of file

Code:
[php]<?php
mysql_connect("SECRET,‘SECRET’,‘SECRET’);
mysql_select_db(‘b9_21718967_applications’);
$username=$_POST{[‘name’]};
$rank=$_POST{[‘rank’]};
$reason=$_POST{[‘reason’]};

   $query='insert into staffapp (name,rank,reason) values('$name,$rank,$reason')';
   $run=mysql_query($query);
   if($run)
   {
   echo 'Succesfully Applied!'
   }
   else
   {
   echo 'Sorry try again!'
   }

?>[/php]
Sorry if i made a stupid mistake its my first time ???
Thanks for your support

The mistake is using dangerous obsolete MySQL code that has been completely removed from Php. Toss the code you have. You need to use PDO.
https://phpdelusions.net/pdo

dont get me wrong but i just want to know whats wrong with it

Your quotes are wrong. If you look at how the code is formatting on the page, it will show that something is wrong.

But, you should listen to Kevin and use a database library that isn’t broken and removed, before you try to use it and it tell you the same thing.

Which editor do you use when coding? As you can see from your marked up code in the original post the colors are wrong from the second line, which hints to a problem with strings (quotes). A proper editor (IDE) would let you know about this problem

could someone send me my code but then with pdo please?
i would appriciate it :-*

Not how this works. You do your own work. We guide you when you get stuck…

im stuck already i dont even know what pdo is

It’s thoroughly explained in the first link posted by Kevin

Thanks, i made something:
But i still got a error:
[embed=425,349]SQLSTATE[HY000] [1045] Access denied for user ‘SECRET’@‘SECRET’ (using password: YES)[/embed]

Code:
[php]

insert data in database

Insert data into database

Student's Form


Student Name :

Student Email :

Student City :


<?php if(isset($_POST["submit"])){ $hostname='SECRET'; $username='SECRET'; $password='SECRET';

try {
$dbh = new PDO(“mysql:host=$hostname;dbname=b9_21718967_applications”,$username,$password);

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line
$sql = “INSERT INTO college (student_name, student_email, student_city)
VALUES (’”.$_POST[“stu_name”]."’,’".$_POST[“stu_email”]."’,’".$_POST[“stu_city”]."’)";
if ($dbh->query($sql)) {
echo “”;
}
else{
echo “”;
}

$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}

}
?>

[/php]

Then, your connection string is incorrect.

Sponsor our Newsletter | Privacy Policy | Terms of Service