I just went to upload the 1st version of a new project I built on the host. To be clear, everything were ready to start working but finally all I got was :
HTTP ERROR 500
I know what does this mean.
My project is 100% handmade with PHP, no WP or other CMS/platform, and there is no Apache file (.htaccess will be added later).
But there is a error_log file, which always have the same line :
[19-Jan-2017 12:59:06 America/Chicago]
PHP Parse error: syntax error, unexpected '$sgbd' (T_VARIABLE)
in /path/to/the/file.php on line 1
It refers to my database connexion file :
<?php
$sgbd = "mysql";
$host = "localhost";
$database = "dont_worry";
$charset = "utf8";
$user = "this_is_not";
$password = "my_infos";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
];
try {
$bdd = new PDO('' . $sgbd . ':host=' . $host . ';dbname=' . $database . ';',
'' . $user . '', '' . $password . '', $options);
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
?>
This is the 1st file called by my pages, right after session_start();
. I really don't get what can be wrong.
I was not prepared to this, thanks for helping !
EDIT : I "solved" the problem, but don't know how it happened. The file was automatically modified on upload, deleting the space between the begining of the PHP code and my first variable :
1 | <?php$sgbd = "mysql";
I verified this file and modified it many times to try to find a solution. The only way was to delete and re-upload the complete project.