Home > Backend Development > PHP Tutorial > PHP 5619 connects to the database. Unable to connect to the database. How to connect to the database. plsql connects to the database.

PHP 5619 connects to the database. Unable to connect to the database. How to connect to the database. plsql connects to the database.

WBOY
Release: 2016-07-29 08:55:00
Original
1427 people have browsed it

It is not recommended to use mysql_connect, mysql_query and other functions in PHP5.3 and above versions. Instead, use the mysqli series (improved). This is an example of connecting to a database and querying data.

<?php
require &#39;conn.php&#39;;  //$link=mysqli_connect($host,$user,$pass,$database);

$query="select * from user_info";
if($result=mysqli_query($link,$query)){
	echo "query was successfully executed.".&#39;<br>';
	while($row=mysqli_fetch_assoc($result)){
		
		echo $row["name"]." ".$row["surname"].'<br>';
			}
	mysqli_free_result($result);
}
else{
	echo "the query is not executed.".'<br>';
}
mysqli_close($link);
?>
Copy after login

The above introduces PHP 5619 to connect to the database, including the content of connecting to the database. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template