简体   繁体   中英

php can connect remotely to mysql but not locally

UPDATE: I tried having my php file in windows and connect to the mysql server remotely in linux using the code below

mysql_connect('10.128.xx.xx', 'jflim', 'helloworld');

this works! but when i tried uploading the same php file in linux(server) and changing the connection string to

mysql_connect('localhost', 'root', '');

its not working.. its also not showing any error message. php codes are working fine without database connection. Im not sure what the problem is now. many thanks

If you upload the .php file in the server where the mysql server is running you should use 'localhost'. But if the script is located in another machine replace the 'localhost' with an ip address or url (www.example.com).

Apart from that, make sure you use the right username and pw.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM