I have a Win 2019 (1809) server running with PHP and mySQL-DB.
IIS 10 Webserver is running, everything fine, mySQL-DB is also running.
I can connect to my mySQL-DB using phpMyAdmin.
Now my issue is that I always get "500 internal server error" ("The website cannot display the page") once I try to connect to mySQL-DB via php-file using PDO or mysqli.
Example:
<?php
define("DB_HOST", "host=xxxx:3306");
define("DB_NAME", "xxxx");
define("DB_USER", "xxxxx");
define("DB_PASS", "xxxxxxx");
define("DB_CHARSET", "utf8");
try {
$pdo = new PDO('mysql:'.DB_HOST.';
dbname='.DB_NAME.';
charset='.DB_CHARSET,
DB_USER,
DB_PASS);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch (PDOException $e) {
echo "Verbindung zur Datenbank fehlgeschlagen (100).";
die();
}
catch (Exception $e) {
echo "Verbindung zur Datenbank fehlgeschlagen (200).";
die();
}
?>
When I execute the script on php.exe I get:
PHP Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
PHP Parse error: syntax error, unexpected '$pdo' (T_VARIABLE) in C:\inetpub\wwwroot\db.php on line 12
Parse error: syntax error, unexpected '$pdo' (T_VARIABLE) in C:\inetpub\wwwroot\db.php on line 12
I don't understand, why? I'm using same structure on other projects and always works correct. Don't know what I'm doing wrong... All mysql-extensions are installed correctly. I tried with PDO and mysqli.
Thanks a lot in advance!