Problem in SQL server.

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problem in SQL server.

Postby safee » 26. December 2008 04:14

HI,
I am a new user of XAMPP. I can do and run codes of normal PHP files. But While trying with MySQL in PHP I have faced a problem.
My problem is,
When I try to use $con=mysql_connect("localhost","peter","abc123"); function I get an error message like this
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'peter'@'localhost' (using password: YES) in C:\xampp\htdocs\PHP_Mysql\Php_Sql.php on line 7
Couldnot Connect to the server: Access denied for user 'peter'@'localhost' (using password: YES)

My code is given bellow:
Code: Select all
 $con=mysql_connect("localhost","peter","abc123");
      if(!$con)
      {
       die("Couldnot Connect to the server: ".mysql_error());
      }
      //somecode
      if(mysql_query("CREATE DATABASE my_db", $con))
      {
       echo "Database created";
      }
      else
      {
       echo "Error Creating database: ".mysql_error();
      }
      //creating database
      mysql_select_db(my_db,$con);
      $sql= "CREATE TABLE persons
      (
       personID int NOT NULL AUTO_INCREAMENT,
       PRIMARY KEY(personID),
       FirstName varchar(15),
       LastName varchar(15),
       Age int,
      )";
      mysql_query("INSERT INTO Persons (FirstName, LastName, Age)
      VALUES ('Peter','Grafin', '35')");
      mysql_querry("INSERT INTO Persons(FirstName, LastName, Age)
      VALUES ('Glemn','Quagmire','33')");
      mysql_close($con);

If there is any solutions that anybody can give me...
I will verymuch happy...
Last edited by safee on 26. December 2008 11:13, edited 1 time in total.
safee
 
Posts: 5
Joined: 26. December 2008 03:59

Re: Problem in SQL server.

Postby Wiedmann » 26. December 2008 06:37

When I try to use $con=mysql_connect("localhost","peter","abc123"); function I get an error message like this:
Access denied for user 'peter'@'localhost' (using password: YES)

You have a MySQL user with the name "peter" and the password "abc123"?
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Problem in SQL server.

Postby safee » 26. December 2008 08:40

No. Actually I have installed XAMPP(Apache Freinds). Here I have an sql server with an php server. :idea:
safee
 
Posts: 5
Joined: 26. December 2008 03:59

Re: Problem in SQL server.

Postby Wiedmann » 26. December 2008 14:30

No.

Hm, so why do you use this username if you don't have such an user?

a) create such an user
b) or use the predefined root user (see readme_en.txt)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Problem in SQL server.

Postby safee » 27. December 2008 05:02

Ahh thanks. I got it.
safee
 
Posts: 5
Joined: 26. December 2008 03:59


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 172 guests