Jump to content

can't connect to mysql in PHP


ssffcc

Recommended Posts

in my php file, I have:

<?php // hostname or ip of server $servername='localhost'; // username and password to log onto db server $dbusername=''; $dbpassword=''; // name of database $dbname='s12921685'; connecttodb($servername,$dbname,$dbusername,$dbpassword); ////////////// Do not  edit below///////// function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_pconnect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } ?>

at run time, it throws this error:Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in c:\Inetpub\wwwroot\DreamWeaverSites\wk5\db.inc.php on line 21Could not connect to MySQL
btw, mysql database is hosted locally without username and passwordplz help
Link to comment
Share on other sites

Chances are you do have a password, if you do not then I really pitty that database. Another thing you could do is assign a user and password to it so that even if you do have a username/pass and you dont realize it by making a user specifically for that database you ensure that doesn't matter.I havn't played with connect codes in a while since iv functionalized all of it for my own sanity. However you might want to try the assigning a user part to see if that helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...