Results 1 to 2 of 2
Jul 8, 2013, 05:50 #1
- Join Date
- Apr 2013
- 0 Post(s)
- 0 Thread(s)
Not able to connect to MYsql with php
I am using XAMPP & I am not able to connect MySQL with PHP. I am a novice & learning from a book "php_mysql novice to ninja 5th edition"
when I type the following query in PhpMyAdmin
$pdo = new PDO('mysql:host=localhost;dbname=ijdb', 'ijdbuser',
$pdo->exec('SET NAMES "utf8"');
catch (PDOException $e)
$output = 'Unable to connect to the database server.';
I get the following error.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?php
$pdo = new PDO('mysql:host=localhost:8888;dbname=ijdb', 'ijdbuser',
'' at line 1
Please help me to solve this problem
Jul 8, 2013, 05:55 #2
It looks like you're putting PHP code into phpMyAdmin when it's expecting SQL. If you want to test the code you've shown above, you need to put it in a file with a .php extension and then run it from your server.