Common methods for connecting to MYSQL database with PHP
想无
想无 2021-09-07 13:56:33
0
3
1092

Configuring a Xiaoniao cloud server and deploying a PHP environment, what are the common methods for connecting to a MYSQL database?

想无
想无

reply all(3)
Z

You can refer to the following

<?php$con = mysql_connect("localhost","root","password");$select_db = mysql_select_db('test');if (!$select_db) { die("could not connect to the db:\n" . mysql_error());}//Query code $sql = "select * from db_table";$res = mysql_query($sql);if (!$res) { die("could get the res:\n" . mysql_error());}while ($row = mysql_fetch_assoc($res)) { print_r($row);}//Query code//Close the database connection mysql_close($ con);?>

yntdx

In fact, there are several common ways to deploy a PHP environment using Xiaoniao Cloud Server and connect to a MYSQL database. Here is the most common one: $mysql_server="localhost";$mysql_username="database username";$ mysql_password="database password";$mysql_database="database name";//Establish a database link//Select a database//Execute MySQL statements//Extract data

逆旅行人

The cloud server simulation environment is no different from the local one. First check whether mysql is successfully installed. You can connect using mysqli or pdo.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template