Jump to content

mySql and xampp


abdelelbouhy

Recommended Posts

hello guys if you please help me i just installed xampp to start learn sql and i download the world database from mysql i'm not to sure where to place this file does it go with hdocs where there's php files or with mysql server because i got this error and i don't know what's wrong the place of the file or the PDO is not available or something to do with userName and password here's the errorFatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'user'@'localhost' (using password: YES)' in C:\xampp\htdocs\abdel.php:14 Stack trace: #0 C:\xampp\htdocs\abdel.php(14): PDO->__construct('mysql:host=loca...', 'user', 'secret') #1 {main} thrown in C:\xampp\htdocs\abdel.php on line 14 and here is the code<?php $dsn = 'mysql:host=localhost;dbname=world;'; $user = 'user'; $password = 'secret'; try{ $db = new PDO($dsn,$user,$password); }catch(PDOException $e){ echo 'connection faild: ' . $e->getMessage(); } ?>

Link to comment
Share on other sites

I'm not sure since I'm a newbie to but did u make a user in xampp?In the mysql main pageProbablyhttp://127.0.0.1/phpmyadmin/Did u make a new database?And go to Privileges to Add a new user?Make sure the user and password are ok.If it doesn't work I'll try the codeEDIT:Ok since I have to wait to go clubbing and have nothing to do I checked the code. After checking, the code works fine with me. Doesn't display anything tho.Make sure the following parameters are correctdbname=mydatabase;$user = '####';$password = 'password';

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...