I'm fairly new to php and MySQL, so sorry if my question seems a little vague. I looked at many forums and everyone seems to have a different way of doing it. None of them work for me. I got my code from w3schools, but it has an error on the try line.
The error says:
"Parse error: syntax error, unexpected '$som' (T_VARIABLE) in /storage/ssd4/647/2267647/public_html/dbinfo.php on line 14"
W3Schols gives examples for both PDOs and MySQLi which I don't totally understand.
Is there anyway I can alter my code to make this work, or is there something I'm fundamentally not understanding about PHP and MySQL?
Here is a portion of my code:
$som = new PDO("mysql:host=$hostname;dbname=myDB", $dbUserName, $dbPassword);
echo "Connected successfully";
echo "Connection failed: " . $e->getMessage();