PHP cannot be connected to mysql online. the local machine is win7 & nbsp; system & nbsp; php Version: PHP & nbsp; Version & nbsp; 5.2.6 & nbsp; apache & nbsp; 2.2 mysql: 5.1.40 local test, PHP can be normal & nbsp; PHP cannot be connected to mysql online, etc.
Windows 7
Php Version: PHP Version 5.2.6
In apache 2.2
Mysql: 5.1.40
For local testing, PHP works normally, but the only difference is that you cannot connect to mysql or use phpmyadmin.
The local test is directly an error page under IE, and a prompt is displayed under 360: The webpage you specified cannot be accessed! Error Type: connection failed
Please help me solve this problem. thank you again...
------ Solution --------------------
Let's take a look at the MYSQL connection statement.
------ Solution --------------------
Open the service first and check whether your mysql service has been started.
Download a Navicat file and test the setting.
Enter the host name or ip address: localhost
Port 3306
Enter the user name and password according to your settings. the default user name is: root
------ Solution --------------------
$ Link = mysql_connect ('localhost', 'root', 'admin ');
If (! $ Link) echo "fail". mysql_error (); // check the output error message.
Else echo "success ";
?>
------ Solution --------------------
$ Link = mysql_connect ('localhost', 'root', 'admin ');
If (! $ Link) echo "fail". mysql_error (); // check the output error message.
Else echo "success ";
?>
------ Solution --------------------
Try using my code
$ Conn = mysql_connect ("localhost", "root", "admin", 1) Or Die ('database server connection failed, check the Config configuration is correct! ');
Or
$ Pdo = New PDO ('MySQL: host = localhost; dbname = Data Table name', 'root', 'admin ');
------ Solution --------------------
Reference:
The code of this webpage cannot be displayed when I stick it to it.
HTML code
This is not helpful for solving the problem, but it is a 404 error page.
------ Solution --------------------
404 error. the Accessed file does not exist or the URL you entered is incorrect.
------ Solution --------------------
The environment is not ready.
------ Solution --------------------
You only need to enable the error display function of php.
------ Solution --------------------
You can download the integration environment.
Http://www.php100.com/html/download/server/2010/1226/wamp21a.html
This is simple and practical. you don't need to configure ini.
------ Solution --------------------
This post was last edited by xuzuning at 16:26:38 $ link = mysql_connect ('localhost', 'root', 'admin') or die (mysql_error ());
If the webpage cannot be found, it indicates that the error display function is not enabled for your php.
------ Solution --------------------
Display_startup_errors = On.
------ Solution --------------------
You need to view the display_errors item on the result page of phpinfo ().
------ Solution --------------------
$ Dbbase = "localhost ";
$ Dbname = "root ";
$ Dbpass = "1234 ";
$ Id = mysql_connect ($ dbbase, $ dbname, $ dbpass );
$ OK = mysql_select_db ("lvyou", $ id );
Mysql_query ('set names "utf8 "');
?>
This is a frequently-used change test.
------ Solution --------------------