Jump to content

PHP mysqli() function.


danboy712

Recommended Posts

Hi there I'm going to give myself away as a begginer str8 off. I've been learning PHP, MYSQL & Apache. Managed ok with learning the basics of all 3 seperately (have experience of VB / ASP.net & Microsoft SQL server so understand the theory ok) I worte a test script in php to try connecting to MYSQL using "mysqli()" :

<?php
$mysqli = new mysqli("localhost", "ODBC", "millcnc", "grocery_store");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
} else {
    printf("Host information: %s\n", mysqli_get_host_info($mysqli));
}
?>

I'm pretty much confident the script is ok and think the problem is in the parameters I am passing to mysqli() it returns the connect failed line every time. Can anyone advise how i reset the username password host etc or retreive them from the MYSQL SERVER I am running all 3 (PHP, MYSQL APACHE) on windows XP and have the latest version of each.

many thanks.

Link to comment
Share on other sites

No still doesn't work I entered root as the user tried it with and without the password (the command line client requests only a password).

Apache server error log returns:

 [Fri Feb 06 15:51:44 2009] [error] [client 127.0.0.1] PHP Warning:  mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (28000/1045): Access denied for user 'Root'@'localhost' (using password: NO) in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlconnect.php on line 2 

Link to comment
Share on other sites

[Fri Feb 06 15:51:44 2009] [error] [client 127.0.0.1] PHP Warning:  mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (28000/1045): Access denied for user 'Root'@'localhost' (using password: NO) in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlconnect.php on line 2

 

mysql is case-sensitive root is not the same as Root.

 

You can reset the root user password by reading this guide

Link to comment
Share on other sites

Thanks for that it now appears to accept the password but says the databases are unknown they are on my system so I'll check the configuration and makle sure the file path etc is correct.

[Fri Feb 06 16:32:22 2009] [error] [client 127.0.0.1] PHP Warning:  mysqli::mysqli() [<a href='mysqli.mysqli'>mysqli.mysqli</a>]: (42000/1049): Unknown database 'fruit_properties' in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\mysqlconnect.php on line 2

The other possibility is alter permissions for each DBase does "root" have access to every database on the server?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.