PHP simple database connection program_PHP tutorial
A good and simple database connection program. Students who need php mysql database connection class can refer to this article.
The code is as follows
|
Copy code | ||||
require_once("mssql.class.php");
//1. Create a class and connect to the database
$db = new mssql("dns=aaa;uid=sa;pwd=sa;dbname=test");
//2. Connect to database
$conn = $db->config("dns=aaa;uid=sa;pwd=sa;dbname=test");
//3.Select database
$dbname = $db->select_db("test");
//4.Set to allow debugging
$db->debug = true;
//5. Execute a SQL statement that does not return a result
$db->execute("insert into test01(name) values('This is a test!')");
//$db->exec("");
//6. Execute a SQL statement that returns results
$rs = $db->query("select * from test01");
//7. Display the results in row format
echo "
Display the result set in row format
";
while($r = $db->fetch_row($rs)){
echo $r[0].":".$r[1]."
";
}
//8. Display the results in array format
$rs2 = $db->query("select * from test01");

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How to fix mysql_native_password not loaded errors on MySQL 8.4

How To Set Up Visual Studio Code (VS Code) for PHP Development
