Notice (8): file_put_contents(): Write of 270 bytes failed with errno=28 No space left on device [CORE/src/Log/Engine/FileLog.php, line 140]

Notice: file_put_contents() [function.file-put-contents]: Write of 1108 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 5131 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3152 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 5437 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3152 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 24325 of 24565 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2397 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 90093 of 90101 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2490 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 94197 of 94197 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2490 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
php中mysql连接和基本操作代码(快速测试使用,简单方便) - 站长搜索
首页 > 资讯列表 > 编程/数据库 >> PHP

php中mysql连接和基本操作代码(快速测试使用,简单方便)

PHP 2014-12-18 05:09:05 转载来源: 网络整理/侵权必删

本文是一个php中mysql连接和基本操作代码(快速测试使用,简单方便),感兴趣的同学参考下。 偶尔要用到php做一些mysql数据库的操作测试,自己写起来太麻烦,搜索的结果一般都又包含一大堆没用的代码,这里将php mysql的操作做一下总结,希望以后用到的时候不用再感到麻烦了

本文是一个phpmysql接和基本操作代码快速测试使用简单方便),感兴趣的同学参考下。

偶尔要用到php做一些mysql数据库的操作测试,自己写起来太麻烦,搜索的结果一般都又包含一大堆没用的代码,这里将php mysql的操作做一下总结,希望以后用到的时候不用再感到麻烦了。


<?php
$dbhost='localhost';//数据库服务器名称
$dbuser='root';// 连接数据库用户名
$dbpass='123456';// 连接数据库密码
$dbname='products';// 数据库的名字

// 连接到数据库
$connect=mysql_connect($dbhost,$dbuser,$dbpass);
if(!$connect) exit('数据库连接失败!');
mysql_select_db($dbname,$connect);
mysql_query('set names utf8');//设置编码

//查询操作
$sql="SELECT * FROM `category`";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
 echo $row['id'];
}
//插入操作
$sql="INSERT INTO `category` (`id`,`name`) VALUES (NULL,'".$name."')";
$result=mysql_query($sql);
if(mysql_affected_rows()){
 echo '插入成功,插入ID为:',mysql_insert_id();
}else{
 echo '插入失败:',mysql_error();
}
//修改操作
$sql="UPDATE `category` SET `name`='".$name."' WHERE `id`='".$id."'";
$result=mysql_query($sql);
if(mysql_affected_rows()){
 echo '修改成功!';
}
//删除操作
$sql="DELETE FROM `category` WHERE `id`='".$id."'";
$result=mysql_query($sql);
if(mysql_affected_rows()){
 echo '删除成功!';
}
//关闭连接
mysql_close($connect);
?>


标签: php mysql 接和 基本操作 代码 快速 测试 使用 简单


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2025 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持