PHP5i如何连接MySQL数据库和读取数据
来源:互联网 发布:php彩票开奖源码 编辑:程序博客网 时间:2024/06/06 00:17
- <?php
- /* Connect to a MySQL server 连接数据库服务器 */
- $link = mysqli_connect(
- 'localhost', /* The host to connect to 连接MySQL地址 */
- 'user', /* The user to connect as 连接MySQL用户名 */
- 'password', /* The password to use 连接MySQL密码 */
- 'world'); /* The default database to query 连接数据库名称*/
- if (!$link) {
- printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
- exit;
- }
- /* Send a query to the server 向服务器发送查询请求*/
- if ($result = mysqli_query($link, 'SELECT Name, Population FROM City ORDER BY Population DESC LIMIT 5')) {
- //print("Very large cities are: ");
- /* Fetch the results of the query 返回查询的结果 */
- while( $row = mysqli_fetch_assoc($result) ){
- printf("%s (%s) ", $row['Name'], $row['Population']);
- }
- /* Destroy the result set and free the memory used for it 结束查询释放内存 */
- mysqli_free_result($result);
- }
- /* Close the connection 关闭连接*/
- mysqli_close($link);
- ?>
阅读全文
0 0
- PHP5i如何连接MySQL数据库和读取数据
- Unity3D_WebPlayer_PHP连接MySQL数据库_3_php登录和读取所有数据
- java连接数据库和读取数据
- 读取mysql数据库数据
- PHP: 如何连接oracle数据库进行数据读取
- PHP中如何连接Mysql以及读取数据
- 【python 读取mysql数据】Python如何读取MySQL数据库表数据
- mysql读取配置文件连接数据库
- PHP_mysql_连接数据库+读取数据
- 如何读取配置文件连接数据库
- 如何连接MYSQL数据库?
- Workerman 如何连接到mysql数据库查询数据
- 从 MySQL 数据库读取数据
- 数据库ADO如何读取数据
- SQLite数据库如何存储和读取二进制数据
- SQLite数据库如何存储和读取二进制数据
- php基础之连接mysql数据库和查询数据
- MyEclipse如何连接数据库,例为MSSQLSERVER和MySQL,两个.
- WPF中INotifyPropertyChanged用法与数据绑定
- C代码替代汇编代码实现启动ARM-M内核CPU
- 几个基本的小程序(3)(素数/闰年)
- Python 简介
- Java 将图片转二进制再将二进制转成图片
- PHP5i如何连接MySQL数据库和读取数据
- 开通博客 记录点点滴滴
- 浅谈UML学习笔记之构件图和部署图
- quartz实现定时任务
- Unity Shader 学习笔记(23) 运动模糊
- hashcode & equals
- Git merge时遇到的坑
- Spring+Struts2+Hibernate整合开发环境搭建
- vim常用设置