在此记录一下,以后不能在同一个地方摔倒了! 数据库为bbs,表为test.三个字段,分别为id,name,sex。id为auto_increment。 连接数据库的php文件conn.php内容为 复制代码 代码如下:$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误"); mysql_select_db("bbs", $conn); mysql_query("set names ‘GBK‘"); //使用GBK中文编码; 表单页:add2.php。内容为: 复制代码 代码如下:<?php include("conn.php"); if(...
返回json数据中文显示的问题上一篇文章中,返回json格式的中文显示成\u5723\u8bde\u8282\u5343\u4e07\u597d\u793c\u5927\u5949\u9001解决方法一:复制代码 代码如下: <?php function Notice(){ include ‘./include/conn.php‘; //数据库链接文件 $sql_notice = mysql_query(‘SELECT * FROM gg_notice where enable = "1" limit 0,10‘); $notice = mysql_fetch_array($sql_notice, MYSQL_ASSOC); $str = json_...
本文实例讲述了PHP中使用file_get_contents抓取网页中文乱码问题解决方法。分享给大家供大家参考。具体方法如下:file_get_contents函数本来就是一个非常优秀的php自带本地与远程文件操作函数,它可以让我们不花吹挥之力把远程数据直接下载,但我在使用它读取网页时会碰到有些页面是乱码了,这里就来给各位总结具体的解决办法.根据网上有朋友介绍说原因可能是服务器开了GZIP压缩,下面是用firebug查看我的网站的头信息,Gzip是开了的,请...
控制面板 > 默认程序 > 右下角,程序与功能 > 左边,打开或关闭Windows功能 按照图片所示打开IIS组件控制面板 > 管理工具 确定IIS两个管理器已打开此时便可以打开http://localhost/本地主页 eclipse PHP Web Application调试前设置:Window > preferences > PHP > PHP Serivers双击选项或点击Edit 看情况设置成http://localhost/或http://localhost/:8080 Local Web Root为设置的网站根目录/*‘).addClass(‘pre-numbering‘).hi...
php程序是部署在IIS7上面,ajax提交数据时,遇到了两个问题,一个就是跨域,一个php程序总会被执行两次。第一个问题的解决方法,是百度出来的,添加下面几行代码就可以了:header(‘Access-Control-Allow-Origin:*‘);header("Access-Control-Allow-Headers: x-requested-with,content-type");header(‘Access-Control-Allow-Methods: OPTIONS,POST,GET‘);其实,也可以直接在iis里面设置,不用添加代码,直接选择站点,然后点右边...
$str = "中华人民共和国";$len = mb_strlen($str,‘utf-8‘);if($len>=6){$str1 = mb_substr($str,0,2,‘utf-8‘);$str2 = mb_substr($str,$len-2,2,‘utf-8‘);}else{$str1 = mb_substr($str,0,1,‘utf-8‘);$str2 = mb_substr($str,$len-1,1,‘utf-8‘); }$this->assign(‘str1‘,$str1);$this->assign(‘str2‘,$str2);$this->assign(‘str‘,$str1.‘**‘.$str2);$this->assign(‘strold‘,substr_replace($str,‘*...
ngxin中安装php-fpm后,html静态页面没问题,不过,虽然phpinfo页面返回200状态码,但浏览却总是空白页,也没有任何报错。考虑应该是nginx已经将php页面转移给php处理了,所以问题应该在php的配置上,经过查找,发现需要在nginx中加入一句话:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;安装完nginx后,默认的fastcgi_params配置文件中没有上面这句。在nginx.conf中的 复制代码 代码如下:location ~ .php...
本文讲述了php中json_encode处理gbk与gb2312中文乱码问题的解决方法,具体方法如下:1.json_encode()中文在gbk/gb2312中对中文返回为null $arr = array ( array ( ‘catid‘ => ‘4‘, ‘catname‘ => ‘www.jb51.net‘, ‘meta_title‘ => ‘脚本之家‘ ) );echo json_encode($arr); 运行结果: [{"catid":"4","catname":"www.jb51.net","meta_title":null}]看一了吗"meta_title":null 他本来是有一个值的为"脚本之家"了,这个我们...
1. 出现“未找到文件“类似的错误时候,检查include文件的位置是否正确,下面引用php手册页面的原话: Files for including are first looked in include_path relative to the current working directory and then in the directory of the current script. E.g. if your include_path is libraries, current working directory is /www/, you included include/a.php and there is include "b.php" in that file, b.php is first...
/** * PHP截取UTF-8字符串,解决半字符问题。 * 英文、数字(半角)为1字节(8位),中文(全角)为2字节 * @return 取出的字符串, 当$len小于等于0时, 会返回整个字符串 * @param $str 源字符串 * $len 左边的子串的长度 */function utf_substr($str,$len){for($i=0;$i<$len;$i++){$temp_str=substr($str,0,1);if(ord($temp_str) > 127){if($i<$len){$new_str[]=substr($str,0,3);$str=substr($str,3);}}else{$new_str[]=substr($...
本文实例讲述了php提示Warning mysql_fetch_array() expects的解决方法,分享给大家供大家参考。具体分析如下:在mysql数据库连接时碰到Warning: mysql_fetch_array() expects ...错误提示,根据我的经验这个是sql返回的query为空了,我们没有加己判断直接使用了.mysql_fetch_array()函数导致的,下面我们一起来看问题解决方案,我的代码如下:复制代码 代码如下:include("conn.php"); if(!empty($_GET[‘id‘])){ $sql="sel...
这是因为用Redis接管了session状态储存,但是Redis又连接不正常导致的在服务器上查看Redis运行状态一切正常,set、get也没有问题,最后琢磨了半天才发现是PHPRedis扩展没有安装,所有PHP连接不上Redis,把扩展安装完后即可解决该问题 安装PHPRedis扩展 原文:https://www.cnblogs.com/shengxihui/p/10802195.html
漏洞名称:dedecms cookies泄漏导致SQL漏洞补丁文件:/member/article_add.php补丁来源:云盾自研漏洞描述:dedecms的文章发表表单中泄漏了用于防御CSRF的核心cookie,同时在其他核心支付系统也使用了同样的cookie进行验证,黑客可利用泄漏的cookie通过后台验证,进行后台注入。解决方法搜索代码:if (empty($dede_fieldshash) || $dede_fieldshash != md5($dede_addonfields.$cfg_cookie_encode))如图:修改代码为:if (empty($de...
更多请支持:http://www.webyang.net/Html/web/article_134.html 最近nginx经常502,解决502最好的办法就是重启php-fpm。 手动去重启还是比较麻烦的事情,最好的就是扔到shell里去。vim restart-php-fpm.sh#!/bin/sh SERVICE=\‘php-fpm\‘#if ps ax | grep -v grep | grep $SERVICE > /dev/nullif netstat -anp | grep 9000>/dev/nullthenecho \"$SERVICE service running, everything is fine\" elseecho \"$SERVICE isnot runni...
折腾了两天,dwz删除后,数据不能自动刷新,解决方案,直接看图 。1、 删除、修改状态后无法刷新记录;在dwz.min.js中添加如下代码:function navTabAjax(json){navTabAjaxDone(json);navTab.reload();}function dialogAjax(json){dialogAjaxDone(json);navTab.reload();}批量删除:selectedTodo:function(){}中success:navTabAjaxDone, navTabAjaxDone改为“navTabAjax”;页面上删除代码如下:<a class="delete" href="__URL__/...