connecting from php to my sqlserver

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fuzzyfuzz
Forum Newbie
Posts: 10
Joined: Fri Dec 05, 2008 5:07 pm

connecting from php to my sqlserver

Post by fuzzyfuzz »

hi everyone;
I'm getting started with php and mysql. I have a problem with connecting from my php script to mysql server - please check up this code:

Code: Select all

 
 
<?php
// Make a MySQL Connection
 
 $link= mysql_connect("localhost","","") or die(mysql_error());
echo "connected successfully to MySQL server.";
 mysql_close($link);  
 
?>
 
I'm reciveing the folowing messege: accec is denied [password:no]
I don't use any user name or password to log into the mysqlserver since it id instaleed on my pc

Please help me

fuzzyfuzzzz
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: connecting from php to my sqlserver

Post by alex.barylski »

Are you using XAMPP?

Can you login into the mysql console with no user or pass?
fuzzyfuzz
Forum Newbie
Posts: 10
Joined: Fri Dec 05, 2008 5:07 pm

Re: connecting from php to my sqlserver

Post by fuzzyfuzz »

yes u can access the console. i'm using wampserver
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: connecting from php to my sqlserver

Post by alex.barylski »

I have never used wampserver...

You are sure did not specify a username/password when setting up the system?

Are you sure the mysql service is running?
fuzzyfuzz
Forum Newbie
Posts: 10
Joined: Fri Dec 05, 2008 5:07 pm

Re: connecting from php to my sqlserver

Post by fuzzyfuzz »

How do i know what is mysql server's name? is it always host? or local host?
because it is posiible to connect through the consloe
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: connecting from php to my sqlserver

Post by alex.barylski »

In your case it's likely 'localhost' is the host name...
hemraj
Forum Newbie
Posts: 11
Joined: Mon Dec 08, 2008 1:05 am

Re: connecting from php to my sqlserver

Post by hemraj »

fuzzyfuzz wrote:yes u can access the console. i'm using wampserver
saASsSas
fuzzyfuzz
Forum Newbie
Posts: 10
Joined: Fri Dec 05, 2008 5:07 pm

Re: connecting from php to my sqlserver

Post by fuzzyfuzz »

here is the code

Code: Select all

 
<?php
 $mysql_link= mysql _connect('localhost','','') or die("ERROR:cannot connect");
echo "connected successfully to MySQL server.";
 mysql_close($mysql_link);  
 
?>
 
 
 
what's wrong with it?
10x.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: connecting from php to my sqlserver

Post by pickle »

This sure does look like a Databases question. :roll:

Moving to the appropriate forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply