Comments - mysqli_connect did not work

7 years, 8 months ago Ian Hudson

Thank you for replying & trying to help. However I do not understand what you advise. I do not know how to look at the web server error log, but since mysqli_error() returned nothing, I do not expect there to be anything in it. And then what do you mean by "go into object-oriented style"? Do you mean try to look at $mysqli->connect_errno etc.? If they are just there why does this matter? But they returned nothing. If you want me NOT to go anywhere near "object-oriented style", what is the PHP error variable that I should look at other than my invocation of the SQL database function mysqli_error(), which returned nothing? I looked at the link you gave; it is to the page headed mysqli::$error and says that the thing referred to "Returns the last error message for the most recent MySQLi function call". As I say, the usual function call for that returns nothing so the above appear to be PHP code niceties whereas if the database error mechanism returns nothing, the important question is why can't I connect to the database?!

Why has nobody published a clear complete guide to how to create the PHP code to do this basic, surely universally needed thing?! I can't find a simple example of a connection function with error reporting, so I could just copy the vanilla basic routine that actually works. Thanks again for any further help you can give; and ... anybody else have any advice? I am at a loss because after a lifetime in the business I find a total absence of fundamental information about what is required and where and how to find out what has gone wrong in all this.

 
7 years, 7 months ago Ian Gilfillan

The examples on the PHP website work fine. You need to either use the procedural-style or object-oriented style. Your code as you have pasted it does not work, as it mixes styles.

 
7 years, 7 months ago Ian Hudson

OK. Thanks. Now, I replaced what you said was object-oriented. I just copied the Example #1 mysqli_connect() from http://uk1.php.net/manual/en/function.mysqli-connect.php and I think it has given me its reason why I cannot connect: Debugging errno: 1045 Debugging error: Access denied for user 'iph'@'localhost' (using password: YES) Now I have 2 questions: Where do I look up error numbers like 1045? and how in MariaDB do I check which user name and password I managed to set up for myself and therefore what values I should be using in this function call?! I am afraid that I find the website documentation labyrithine and perplexing.

 
7 years, 7 months ago Ian Gilfillan

Error codes are listed at MariaDB Error Codes.

You can query the mysql.user table to view which host/users have been set up:

select host, user, password from mysql.user;

However, the passwords are hashed, so you will not be able to view the passwords used.

You may also want to look at Troubleshooting Connection Issues.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.