Search code examples
phpxamppmysql-connect

getting an error message with a mysql_connect() statement


some comments preceding a mysql_connect statement are telling me to modify the values/variable name to my installation. I'm using xamp and looking in php.ini right now. don't really know where the problem is. please advise. Thanks.

php:

$dbhost = 'localhost'; //unlikely to require changing.
$dbname ='publication'; //moify these
$dbuser = 'username'; //variables 
$dbpass = 'password'; //// to your installation
$appname = 'Robot City'; // and preference

mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());

error message:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\xampp\htdocs\ajaxpagination\testpage.php on line 10
Access denied for user 'username'@'localhost' (using password: YES)

Solution

  • Instead of looking into php.ini you have to look into your XAMPP documentation.
    I am sure it contains database credentials you have to use.

    As a wild guess try to use

    $dbname ='test'; //moify these
    $dbuser = 'root'; //variables 
    $dbpass = '';
    

    But again - refer to the documentation for the actual values.

    There is also a chance that you entered them yourself upon the process of the XAMPP installation.

    Note that I have never seen this application in my life. I am writing only out of the general idea of how most applications work.