Link to home
Start Free TrialLog in
Avatar of Pete C
Pete CFlag for United States of America

asked on

connect to mysql using php

I installed the latest versions of apache, php and mysql on windows 10.  I am trying to connect to mysql for the first time within php and the code simply stops, i.e. there is no error message, and it will not proceed to the line below the following statement.

$connection = new mysqli('localhost','root','password', '');

Do I need to start mysql after installing it, if so, how do I do that?

Thanks,
Pete
Avatar of Pete C
Pete C
Flag of United States of America image

ASKER

To follow up, mysql is running when I view the task manager, so that does not seem to be the issue.  note, I ran into this problem a few years ago, and I implemented the below solution (which I have also done this time around, but it is still not connecting).

To allow php to connect with mysql in windows, change the hosts file that is located within the below directory:
Windows\system32\drivers\etc\hosts
uncomment the below line:
127.0.0.1  localhost   (to do so, type note pad within the startpanel search bar, choose run as administrator, and then open the file).

Thanks again for any thoughts
ASKER CERTIFIED SOLUTION
Avatar of Pete C
Pete C
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial