语句判断错误,帮忙看看! 本帖最后由 cqheshuang 于 2010-02-11 14:46:21 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你做这个判断有什么意义呢?if和else中执行的语句完全相同。不清楚你要做什么。 大哥看清楚了回答,你看我两个表一样嘛?,我是根据$type1的返回值来判断是创建的文章还是公告信息,添加到各自对应的表中 这样写给大家好看点<?php $title=$_REQUEST["title"]; $create_type=$_REQUEST["create_type"]; $content=$_REQUEST["content"]; $type1=$_REQUEST["create_news_type"]; if(isset($_REQUEST["post"]) && $_REQUEST["post"]=="create_news" && $type1=="WZ") { $sql="insert into admin_manager_artice(`a_id`,`a_title`,`a_content`,`a_type`,`a_date`) values(null,'{$title}','{$content}','{$create_type}',now());"; mysql_query($sql) or die('query_error'); }else{ $sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());"; mysql_query($sql1) or die('query error'); }?> 不好意思没看仔细。。$title=$_REQUEST["title"]; $create_type=$_REQUEST["create_type"]; $content=$_REQUEST["content"]; $type1=$_REQUEST["create_news_type"]; 分别var_dump()这四个变量,输出每条SQL语句,看是什么。 哦,搞定了一个错误.还有一个错误就是这个else,我还没提交表单它就执行了,并返回or die的错误提示,请帮我看下吧else{ $sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());"; mysql_query($sql1) or die('query error'); } 因为你没有满足IF条件,所以就跑ELSE了。是不是应该再设置一个变量,加载页面不执行IF-ELSE,当提交的时候才执行? 我换了一种判断方法,添加GG的时候sql_query又执行出错了,提示or die的错误信息,请帮忙分析下}elseif($type1=="GG"){ $sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());"; mysql_query($sql1) or die('query error'); echo "success"; } 这个添加语句我是从上面那条直接复制下来的,只是改了xia字段,数据库字段设置也是一样的,但是就不能正常执行呢 晕倒,sql出错你就echo出来看看,你的n_id是不是自增列啊,你自增列的话你给他来个null???? && 你注意下 前面2个表达式的值。。 请教一下PHP模拟登录另外的网站 页面多radio和check如何验证? 怎样格式化一段代码... 我有這樣的一個想法,不知道各位是否可以指點下. 50分:如何解决?select count(*) from client where C_EMPRESA like '%上海%' Oracle的SQL语句问题!在线等,急! 建立目录的问题。能不能同时建几个目录? 关于PHP分页 刚学PHP,第一个自已写的类,希望高手帮手把它简化! PHP file_get_content接收数据遗漏 为何会无限循环 虎年大吉,88分,谁给提供一个php webservice soap 发送xml的例子?
if和else中执行的语句完全相同。不清楚你要做什么。
$title=$_REQUEST["title"];
$create_type=$_REQUEST["create_type"];
$content=$_REQUEST["content"];
$type1=$_REQUEST["create_news_type"];
if(isset($_REQUEST["post"]) && $_REQUEST["post"]=="create_news" && $type1=="WZ")
{
$sql="insert into admin_manager_artice(`a_id`,`a_title`,`a_content`,`a_type`,`a_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
mysql_query($sql) or die('query_error');
}else{
$sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
mysql_query($sql1) or die('query error');
}
?>
$title=$_REQUEST["title"];
$create_type=$_REQUEST["create_type"];
$content=$_REQUEST["content"];
$type1=$_REQUEST["create_news_type"]; 分别var_dump()这四个变量,输出每条SQL语句,看是什么。
还有一个错误就是这个else,我还没提交表单它就执行了,并返回or die的错误提示,请帮我看下吧
else{
$sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
mysql_query($sql1) or die('query error');
}
是不是应该再设置一个变量,加载页面不执行IF-ELSE,当提交的时候才执行?
$sql1="insert into admin_manager_notice(`n_id`,`n_title`,`n_content`,`n_type`,`n_date`) values(null,'{$title}','{$content}','{$create_type}',now());";
mysql_query($sql1) or die('query error');
echo "success";
}