I am trying to teach myself PHP and I've come unstuck at a very early stage, I'm trying to connect to my db with the following code:
$server = 'server';
$username = 'username';
$password = 'password';
$database = 'database';
if(!mysqli_connect($server, $username, $password))
{
exit('Error: could not establish database connection');
}
if(!mysqli_select_db($database)
{
exit('Error: could not select the database');
}
However, when I run this code I get the following error:
Parse error: syntax error, unexpected '{' in connect.php on line 22
If I comment out the final if statement the error goes away.
I have tried Google etc, but I feel that my lack of knowledge/experience means that I might not recognise the solution just from scouring random search results.
As a side note, Visual Studio is also giving me a sytax error on the final semi colon.