2

I'm setting up a PHP script that connects to the 4D Database on my local system.

However, I keep getting:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1044] Access denied for user ''@'localhost' to database 'tester'' in /Applications/MAMP/htdocs/4d/index.php:8 Stack trace: #0 /Applications/MAMP/htdocs/4d/index.php(8): PDO->__construct('mysql:host=loca...', 'XXXX', 'XXXX') #1 {main} thrown in /Applications/MAMP/htdocs/4d/index.php on line 8

I don't know HOW and WHERE to set the username & password for permissions for PHP to connect to the database :/

Any help is appreciated.

Simple code:

$db = new PDO('mysql:host=localhost;dbname=tester', "tester", "");

try {
echo "OK";
} catch (PDOException $e) {
die("Error 4D : " . $e->getMessage());
}
Noctis Skytower
  • 21,433
  • 16
  • 79
  • 117
Matt Reid
  • 235
  • 5
  • 14

2 Answers2

0

For connect 4D, you must to use like :

$db = new PDO('4d:host=localhost;charset=UTF-8', "tester", "");
Ororuk
  • 461
  • 4
  • 17
0

Connections to 4D Server from PDO_4D must either utilize a valid 4D user or the developer of the 4D application has to have written code in the On SQL Authentication database method (of the 4D application) to handle the login in a custom way.

More info regarding managing 4D Users

More info regarding the On SQL Authentication database method

Tim Penner
  • 3,551
  • 21
  • 36