使用form方法更新mysql表(utf8)

j13ufse2  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(337)

我正在尝试使用表单更新表查询utf8。它以窗体形式显示,但无法编辑。请告诉我查询中的错误是什么?

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once("./includeadmin/membersite_config.php");
require_once("./includeadmin/membersite_config_editorial.php");
include("database1.php");
if(!$fgmembersite->CheckLogin())
{
$fgmembersite->RedirectToURL("index.php");
exit;
}

$idi = $_POST['id2'];
$sql = mysql_connect("localhost","username","password");

if (!$sql) {
die ('Could not connect!: ' . mysql_error());
}
mysql_select_db("nam33_articles", $sql);
mysql_query("UPDATE editorial SET date = '$_POST[date]', tag =         
'$_POST[tag]', title = '$_POST[title]', small = '$_POST[small]', image = 
'$_POST[image]', smallimage = '$_POST[smallimage]', english = 
'$_POST[english]', full = '$_POST[full]') WHERE id_user = '$idi'");
?>
ozxc1zmp

ozxc1zmp1#

更新查询参数并设置utf8。

mysql_query("set names 'utf8'",$sql);
$query = "UPDATE editorial SET date = '".$_POST['date']."', tag = '".$_POST['tag']."', title = '".utf8_encode($_POST['title'])."', small = '".utf8_encode($_POST['small'])."', image = '".$_POST['image']."', smallimage = '".$_POST['smallimage']."', english = '".$_POST['english']."', full = '".utf8_encode($_POST['full'])."' WHERE id_user = '$idi'";
mysql_query($query);

相关问题