yeoman_z
(yeoman_z)
注册会员

中级会员
UID 60744
精华
0
积分 184
帖子 184
金钱 184 喜悦币
威望 0
人脉 0
阅读权限 20
注册 2004-12-6 来自 南河沟
状态 离线
|
简单的插入和删除的问题:
一个简单的新闻发布系统的后台管理程序,运行出了问题
1 insert.php:
<?php
$hostname='localhost';
$username='root';
$dbname='news';
$tablename='news';
$password='';
$link_id=mysql_connect($hostname,$username,$password);
if (!$link_id)
{ echo '<html><head><title>Error</title></head><body>';
echo '数据库连接失败。';
echo '</body></html>';
exit(); }
$str_sql="insert into news(title,date,author,source,content,category) values('$title','$date','$author','$source','$content','$category')";
$result=mysql_db_query($dbname,$str_sql);
/*if (!$result)
{
print('数据库更新失败!');
exit();
}*/
print"数据已经更新<br>";
?>
$str_sql&$result有问题吗?总显示'数据库更新失败!',可是已经插入了,所以我把这段注释掉了.
2 delete.php:
<?php
$hostname='localhost';
$username='root';
$dbname='news';
$tablename='news';
$password='';
$link_id=@mysql_connect($hostname,$username,$password);
if (!$link_id)
{ echo '<html><head><title>Error</title></head><body>';
echo '数据库连接失败。';
echo '</body></html>';
exit(); }
echo"<script language='JavaScript'>";
echo"if(!confirm('确定要删除该项记录吗?')){history.back();exit();}";
echo"</script>";
$str_sql="delete from news where title='$title'";
$result=mysql_db_query($dbname,$str_sql);
if(!result){echo"内部错误,删除失败";exit();}
echo"删除完成<br>";
?>
其中有javascript实现的那个提示框点取消和点确定都完成了删除操作,而且$str_sql="delete from news where title='$title'";有问题吗?当我要删除的title为英文字母的时候能删掉,但当title为汉字的时候就出错,是怎么回事?
|
|