ronc0011 Posted September 5, 2017 Share Posted September 5, 2017 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 Quote Link to comment Share on other sites More sharing options...
Solution ronc0011 Posted September 5, 2017 Author Solution Share Posted September 5, 2017 OK never mind I finally spotted what the problem was . The variable "conn" didn't have the right syntax. It should have been "$conn" Fixed it instantly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.