0

I know this question has been asked a few times here but still i wasn't able to find any answer that would actually help me.

Since i read in documentation that mysql_connect is now deprecated i wanted to replace it with mysqli_connect.
Original script looked like this:

mysql_connect($host, $user, $pswd);
mysql_select_db($db);

This script was functional and could successfully connect to MySQL. I replaced it with:

mysqli_connect($host, $user, $pswd, $db);

(no changes in variables or any other lines of code)

Althought it should work according to documentation and like every tutorial i read, it gives me access denied error. Most problems i saw answered were just typos or worng variables, which is not this case.

Since i am going to keep this project procedural and i am pretty sure i have enough to learn before i'll start with PDO's which is solution provided in the rest of answers i found i am quite desperate.

So where is the problem?

PS: This is my first question here, i really tried to ask properly, but if i did something wrong please be kind and just tell me what i did wrong and how should i do it next time :)

An Capone
  • 123
  • 2
  • 15
  • did you really just replaced the two upper lines by `mysqli_connect()` and changed nothing more? – SaschaP Jun 14 '16 at 22:13
  • What do you use (linux, windows, wammp, xamp, lcpanel on linux etc ) – Ivan Barayev Jun 14 '16 at 22:13
  • are you sure it's the "access denied" error? the host, username, password, and database are all the same? I would expect other errors from not changing all the other function calls, but not "access denied" – Jeff Puckett Jun 14 '16 at 22:19
  • Yes, i am sure i did not change anything else, and yes i am sure it's the access denied error. It's true, that there are more errors which come later in code, but i assume that they are caused by the simple fact that the script wasn't able to connect to server and therefore it wasnt able to insert data in database or anything else. I would also expect different errors and it makes me kinda clueless, that is why i asked this question. I use cpanel (or whatever 000webhost.com provides) tomorrow ill try my code on local linux server and see if it behaves differently, but i am not very optimistic – An Capone Jun 15 '16 at 02:59
  • I see this question being marked as a duplicate of the one in link, which it is not. I understand what is descibed in the provided link, but that doesn't solve my problem. It doesnt matter if all the following functions fail (until the initial problem is solved) because if i cannot connect to database it doesnt matter if i fail with mysql_query or mysqli_query. just to make it clear, when i solve access denied problem i ll change all the following functions to their mysqli equivalents and add $link attribute, but again THAT IS NOT THE PROBLEM – An Capone Jun 15 '16 at 04:08

0 Answers0