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.

Jul 29, 2016 am 08:55 AM
Connect to the database

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 'conn.php';  //$link=mysqli_connect($host,$user,$pass,$database);

$query="select * from user_info";
if($result=mysqli_query($link,$query)){
	echo "query was successfully executed.".'<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.

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to deal with SQLException when connecting to database in Java? How to deal with SQLException when connecting to database in Java? Jun 24, 2023 pm 09:23 PM

How to deal with SQLException when connecting to database in Java?

How to read the first few records in a database using PHP? How to read the first few records in a database using PHP? Mar 22, 2024 am 10:03 AM

How to read the first few records in a database using PHP?

Using Go language to connect to the database: improve application performance and efficiency Using Go language to connect to the database: improve application performance and efficiency Jan 23, 2024 am 08:57 AM

Using Go language to connect to the database: improve application performance and efficiency

How to connect to the database in go language How to connect to the database in go language Dec 12, 2023 pm 03:51 PM

How to connect to the database in go language

Steps and techniques for implementing product inventory counting with PHP Steps and techniques for implementing product inventory counting with PHP Aug 18, 2023 am 08:39 AM

Steps and techniques for implementing product inventory counting with PHP

Getting Started with Go Language: Basic Concepts of Database Connections Getting Started with Go Language: Basic Concepts of Database Connections Jan 23, 2024 am 08:17 AM

Getting Started with Go Language: Basic Concepts of Database Connections

How to install and configure PHP on Ubuntu system to connect to MSSQL database How to install and configure PHP on Ubuntu system to connect to MSSQL database Feb 29, 2024 am 10:06 AM

How to install and configure PHP on Ubuntu system to connect to MSSQL database

What are the important functions of MySQL's Jar package? What are the important functions of MySQL's Jar package? Mar 01, 2024 pm 09:45 PM

What are the important functions of MySQL's Jar package?

See all articles