I'm new to the forum (and relatively new to PHP) and I have already learned a lot from reading the other posts!
Thank you very much for all the knowledge that is shared here.
There is one problem I'm having that I can't find a solution to...
I'm trying to connect to a database, as long as I use mysqli everything is fine, but I wanted to experiment with PDO. Every time I try I get an error message telling me that the driver was not found, so I tried to find out which PDO drivers are installed, and mysql is supposed to be there.
Here is the code I'm running:
Code: Select all
foreach (PDO::getAvailableDrivers() as $driver)
{
echo $driver . '<br />';
}
$dbh = new PDO ('mysql : host = localhost ; dbname = cdcol', 'root', 'Broken00')
or die ("Error");
[text]
mysql
pgsql
sqlite
sqlite2
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /opt/lampp/htdocs/xampp/codershed.co.uk/dbtest.php:23 Stack trace: #0 /opt/lampp/htdocs/xampp/codershed.co.uk/dbtest.php(23): PDO->__construct('mysql : host = ...', 'root', 'Broken00') #1 {main} thrown in /opt/lampp/htdocs/xampp/codershed.co.uk/dbtest.php on line 23
[/text]
Anyone can understand what's happening?
Thank you sooo much...
SR