这篇文章介绍了PHP连接局域网MYSQL数据库的简单实例,有需要的朋友可以参考一下
复制代码 代码如下:
$conn=mysql_connect('192.168.0.220','root','123');
if(!$conn) echo "失败!";
else echo "成功!";
// 从表中提取信息的sql语句
$sql="SELECT * FROM user where userName='$user_name'";
// 执行sql查询
$result=mysql_db_query('info', $sql, $conn);
// 获取查询结果
$row=mysql_fetch_row($result);
mysql_close();
第一行ip对应局域网某台主机,关于局域网内mysql连接可参考我的摘抄。
第六行$user_name是前台传递的参数,组成条件查询,这里用了双引号变量转换。
从jsp到php,无论哪一种,美国空间,与数据库连接有关的步骤大致就是:
“主机,美国服务器,用户名,密码”得到连接、“数据库,sql,连接”得到结果,最后是结果的处理显示。当然,数据库连接是扩展库为我们完成的,香港虚拟主机,我们能做的仅仅是处理结果而已。

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
