php留言版不能输入中文 php数据库function表单mysql 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 输入中文时有什么错误提示?1.是否接受页面有限制中文?2.数据库字符集是什么?在数据库操作前加 mysql_query("set names latin1") or die(mysql_error()); 试试。 你可以先把表单中的值获取后看看能不能echo出来,如果不可以好好看代码少了什么,如果可以,就说明是数据部分有问题,一般就是字符集设置错误 这是完整页面代码<?php if(!defined('DEDEINC')) exit("Request Error!");/** * 自定义表单解析类 * * @version $Id: diyform.cls.php 1 10:31 2010年7月6日Z tianya $ * @package DedeCMS.Libraries * @copyright Copyright (c) 2007 - 2010, DesDev, Inc. * @license http://help.dedecms.com/usersguide/license.html * @link http://www.dedecms.com */ require_once DEDEINC.'/dedetag.class.php';require_once DEDEINC.'/customfields.func.php';/** * diyform * * @package diyform * @subpackage DedeCMS.Libraries * @link http://www.dedecms.com */class diyform{ var $diyid; var $db; var $info; var $name; var $table; var $public; var $listTemplate; var $viewTemplate; var $postTemplate; function diyform($diyid){ $this->__construct($diyid); } /** * 析构函数 * * @access public * @param string $diyid 自定义表单ID * @return string */ function __construct($diyid){ $this->diyid = $diyid; $this->db = $GLOBALS['dsql']; $query = "SELECT * FROM #@__diyforms WHERE diyid='{$diyid}'"; $diyinfo = $this->db->GetOne($query); if(!is_array($diyinfo)) { showMsg('参数不正确,该自定义表单不存在','javascript:;'); exit(); } $this->info = $diyinfo['info']; $this->name = $diyinfo['name']; $this->table = $diyinfo['table']; $this->public = $diyinfo['public']; $this->listTemplate = $diyinfo['listtemplate'] != '' && file_exists(DEDETEMPLATE.'/plus/'.$diyinfo['listtemplate']) ? $diyinfo['listtemplate'] : 'list_diyform.htm'; $this->viewTemplate = $diyinfo['viewtemplate'] != '' && file_exists(DEDETEMPLATE.'/plus/'.$diyinfo['viewtemplate']) ? $diyinfo['viewtemplate'] : 'view_diyform.htm';; $this->postTemplate = $diyinfo['posttemplate'] != '' && file_exists(DEDETEMPLATE.'/plus/'.$diyinfo['posttemplate']) ? $diyinfo['posttemplate'] : 'post_diyform.htm';; } /** * 获取表单 * * @access public * @param string $type 类型 * @param string $value 值 * @param string $admintype 管理类型 * @return string */ function getForm($type = 'post', $value = '', $admintype='diy') { global $cfg_cookie_encode; $dtp = new DedeTagParse(); $dtp->SetNameSpace("field","<",">"); $dtp->LoadSource($this->info); $formstring = ''; $formfields = ''; $func = $type == 'post' ? 'GetFormItem' : 'GetFormItemValue'; if(is_array($dtp->CTags)) { foreach($dtp->CTags as $tagid=>$tag) { if($tag->GetAtt('autofield')) { if($type == 'post') { $formstring .= $func($tag,$admintype); } else { // $formstring .= $func($tag,htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype); $formstring .= $func($tag,htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype); } $formfields .= $formfields == '' ? $tag->GetName().','.$tag->GetAtt('type') : ';'.$tag->GetName().','.$tag->GetAtt('type'); } } } $formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"".$formfields."\" />\n"; $formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"".md5($formfields.$cfg_cookie_encode)."\" />"; return $formstring; } /** * 获取字段列表 * * @access public * @return string */ function getFieldList() { $dtp = new DedeTagParse(); $dtp->SetNameSpace("field","<",">"); $dtp->LoadSource($this->info); $fields = array(); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $tagid=>$tag) { $fields[$tag->GetName()] = array($tag->GetAtt('itemname'), $tag->GetAtt('type')); } } return $fields; }}//End Class 你打印下sql应该是你没有用‘’包含起来就直接写入数据库导致写入不进去,如果是英文和数字不写没事,但是中文一定要写的。 把sql语句输出,直接拖到数据库里执行,看看什么结果。 discuz 高手来! 急。。。。 图片延迟加载 iis 404跳转后 为什么地址栏却没改变 PHP session 问题求解 程序传到空间上读取数据库就出现乱码 高手帮我看看php代码错在哪里? JSON 读取问题 如何做在线文档编辑 nginx支持thinkphp的pathinfo php调用sphinx提示failed to send client protocol version 【秀整站系统】与其讨论框架优劣,还不如来点实用的,大家觉得我这个CMS系统如何? 请教一个数组整理方法
1.是否接受页面有限制中文?
2.数据库字符集是什么?
在数据库操作前加 mysql_query("set names latin1") or die(mysql_error()); 试试。
<?php if(!defined('DEDEINC')) exit("Request Error!");
/**
* 自定义表单解析类
*
* @version $Id: diyform.cls.php 1 10:31 2010年7月6日Z tianya $
* @package DedeCMS.Libraries
* @copyright Copyright (c) 2007 - 2010, DesDev, Inc.
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once DEDEINC.'/dedetag.class.php';
require_once DEDEINC.'/customfields.func.php';/**
* diyform
*
* @package diyform
* @subpackage DedeCMS.Libraries
* @link http://www.dedecms.com
*/
class diyform
{
var $diyid;
var $db;
var $info;
var $name;
var $table;
var $public;
var $listTemplate;
var $viewTemplate;
var $postTemplate; function diyform($diyid){
$this->__construct($diyid);
}
/**
* 析构函数
*
* @access public
* @param string $diyid 自定义表单ID
* @return string
*/
function __construct($diyid){
$this->diyid = $diyid;
$this->db = $GLOBALS['dsql'];
$query = "SELECT * FROM #@__diyforms WHERE diyid='{$diyid}'";
$diyinfo = $this->db->GetOne($query);
if(!is_array($diyinfo))
{
showMsg('参数不正确,该自定义表单不存在','javascript:;');
exit();
}
$this->info = $diyinfo['info'];
$this->name = $diyinfo['name'];
$this->table = $diyinfo['table'];
$this->public = $diyinfo['public'];
$this->listTemplate = $diyinfo['listtemplate'] != '' && file_exists(DEDETEMPLATE.'/plus/'.$diyinfo['listtemplate']) ? $diyinfo['listtemplate'] : 'list_diyform.htm';
$this->viewTemplate = $diyinfo['viewtemplate'] != '' && file_exists(DEDETEMPLATE.'/plus/'.$diyinfo['viewtemplate']) ? $diyinfo['viewtemplate'] : 'view_diyform.htm';;
$this->postTemplate = $diyinfo['posttemplate'] != '' && file_exists(DEDETEMPLATE.'/plus/'.$diyinfo['posttemplate']) ? $diyinfo['posttemplate'] : 'post_diyform.htm';;
} /**
* 获取表单
*
* @access public
* @param string $type 类型
* @param string $value 值
* @param string $admintype 管理类型
* @return string
*/
function getForm($type = 'post', $value = '', $admintype='diy')
{
global $cfg_cookie_encode;
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->LoadSource($this->info);
$formstring = '';
$formfields = '';
$func = $type == 'post' ? 'GetFormItem' : 'GetFormItemValue';
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tagid=>$tag)
{
if($tag->GetAtt('autofield'))
{
if($type == 'post')
{
$formstring .= $func($tag,$admintype);
}
else
{
// $formstring .= $func($tag,htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype);
$formstring .= $func($tag,htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype);
}
$formfields .= $formfields == '' ? $tag->GetName().','.$tag->GetAtt('type') : ';'.$tag->GetName().','.$tag->GetAtt('type');
}
}
} $formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"".$formfields."\" />\n";
$formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"".md5($formfields.$cfg_cookie_encode)."\" />";
return $formstring;
} /**
* 获取字段列表
*
* @access public
* @return string
*/
function getFieldList()
{
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->LoadSource($this->info);
$fields = array();
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tagid=>$tag)
{
$fields[$tag->GetName()] = array($tag->GetAtt('itemname'), $tag->GetAtt('type'));
}
}
return $fields;
}}//End Class