I try to connect my php website with a XAMPP Server so I can access my MySQL database. Any Ideas how the config has to look like, because I'm rather stuck with this one.
I tried to make a config but it didnt really work. I'll post my current config below:
<?php
try {
global $con;
$server = 'localhost:3307';
$user = 'root';
$schema = '';
$con = new PDO('mysql:host='.$server.';schema = '.$schema.';charset=utf8', $user);
$con->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
} catch(Exception $e) {
echo $e->getCode().': '.$e->getMessage();
}
I think missing the password param after the user. Unfortunately you didnt provide the error, but maybe your error is the blank $schema param. You wont connect to a schema, if you dont put the name of the schema in there, so you whould have to use <use [name of schema]> to connect to it.
<?php
try
{
global $con;
$server = 'localhost:3307';
$user = 'root';
$pwd = '';
$schema = '';
$con = new PDO('mysql:host='.$server.';schema = '.$schema.';charset=utf8', $user,$pwd);
$con->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch(Exception $e)
{
echo $e->getCode().': '.$e->getMessage();
}