Page 1 of 1
connecting from php to my sqlserver
Posted: Sun Dec 07, 2008 12:44 pm
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
Re: connecting from php to my sqlserver
Posted: Sun Dec 07, 2008 12:50 pm
by alex.barylski
Are you using XAMPP?
Can you login into the mysql console with no user or pass?
Re: connecting from php to my sqlserver
Posted: Sun Dec 07, 2008 12:53 pm
by fuzzyfuzz
yes u can access the console. i'm using wampserver
Re: connecting from php to my sqlserver
Posted: Sun Dec 07, 2008 1:13 pm
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?
Re: connecting from php to my sqlserver
Posted: Sun Dec 07, 2008 1:21 pm
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
Re: connecting from php to my sqlserver
Posted: Sun Dec 07, 2008 4:38 pm
by alex.barylski
In your case it's likely 'localhost' is the host name...
Re: connecting from php to my sqlserver
Posted: Mon Dec 08, 2008 1:08 am
by hemraj
fuzzyfuzz wrote:yes u can access the console. i'm using wampserver
saASsSas
Re: connecting from php to my sqlserver
Posted: Mon Dec 08, 2008 12:29 pm
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.
Re: connecting from php to my sqlserver
Posted: Mon Dec 08, 2008 3:42 pm
by pickle
This sure does look like a
Databases question.
Moving to the appropriate forum.