Thursday 11 January 2018

php - PDO parse error unexpected ":"





I'm trying to establish a new PDO instance with the following
code




$handler
= new PDO(“mysql:host=127.0.0.1;dbname=database”,
“root”,
“”);


I get the
following error message:





Parse error: syntax error, unexpected ':', expecting ',' or ')' in
/Applications/XAMPP/xamppfiles/htdocs/example/connection.php on line
2





There
has been no problems like this before until I attempted to do this on a new Mac. Can
someone help with this issue?


itemprop="text">
class="normal">Answer



try
this:



$handler = new
PDO("mysql:host=127.0.0.1;dbname=database",
"root",
"");


your quotes were
wrong



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...