Jump to content

Is there something fundamentally wrong with PHP?


Go to solution Solved by ronc0011,

Recommended Posts

Honestly I’ve hit this wall more times than I can count. It typically turns out to be something seemingly arbitrary like single or double quotes and only maters sometimes and sometimes not.

OK enough with the ranting. Here is the code that is making me pull my hair out…

It’s a PDO connection string that I’m getting from a Youtube video.

$host = "127.0.0.1";
$user = "root";
$pass = "r00t";
$db = "cars";
try{
conn = new PDO ("mysql:host=$host;dbname=$db", "$user", "$pass");
conn -> setAttrabute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
echo "Oh happy day we have connected to our database";
} Catch (PDOException $e) {
die("Well, that didn't work at all");
}

It’s giving me this error…

Parse error: syntax error, unexpected '=' in C:\Apache24\htdocs\PDO\conn.php on line 10

Line 10 is the line with the new PDO.

 

I’ve been staring at the example code and comparing it to my code till my eyes are about to cross and I can’t find what it is that’s causing the problem.

I’ve tried it with double quotes as well as single quotes. No help. I only say that because it’s been an issue on other occasions

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.