update zhuanye set xibie='11' where id='6' 你在"6"写重新写一下,就可以了,写成以下这样 update zhuanye set xibie='11' where id='6' 看到了吗,是不是有点不同,这个我试过了,没错的
$str="update $table set xibie='$xibie' where id=$id";去掉$id的小分号!我试过了,这样也是不行. 还有id是int型的if(strlen($xibie)!==0) //另外,这个条件是错的,只有在判断变量是否为真假采用===,!==比较符号。否则请老老实实用==,可能这才是你不运行sql查询的根源。 这个办法我也试过了,同样是不执行
如果将这段代码的id直接用数字来写的话,例如 $str="update $table set xibie='$xibie' where id='6'"; 起他的代码不用改,就可以正确地执行,请问怎么解决??
调试sql错误,首先看mysql_error()的输出是什么
我用intval函数将$id转换一下: $s=intval($id); echo $s; $str1="update zhuanye set xibie='".$xibie."' where id='$s'"; 最后执行 echo $str1; echo $id; echo $s; 结果输出的结果是:update zhuanye set xibie='666' where id='0'0如果不对$id进行转换,那么输出结果是: update zhuanye set xibie='666' where id=''
echo $str="update $table set xibie='$xibie' where id='$id'";
上面两句连一起,试试看是不是能正确输出!
同样是不行
我
echo $id;
echo $str="update $table set xibie='$xibie' where id='$id'";
很奇怪,在$str之前的就可以显示,如果执行了$str就不显示$id了,
echo $str;
给出结果
update zhuanye set xibie='11' where id='6'
执行后是
update zhuanye set xibie='11' where id=''
web_php(C#C++_PHPMYSQL_ASP)
还是不对
include("connect.php");
$db="bookticket";
$table="zhuanye";
$xibie=$_GET['xibie'];
$jibie=$_GET['jibie'];
$zhuanye=$_GET['zhuanye'];
$banji=$_GET['banji'];
$id=$_GET['id'];
echo $id;
if(strlen($xibie)!==0)
{$str1="update zhuanye set xibie='".$xibie."' where id='".$id."'";
$res=mysql_db_query($db,$str1);
}
echo $id;
echo $str1;
?>
is $xibie a number , too ???I see the "6" here is 全角字符.....
我的代码贴出来了,你怎么不回复了呢
?
<?php
include("connect.php");
$db="bookticket";
$table="zhuanye";
$xibie=$_GET['xibie'];
$jibie=$_GET['jibie'];
$zhuanye=$_GET['zhuanye'];
$banji=$_GET['banji'];
$id=$_GET['id'];
echo $id;
if(strlen($xibie)!==0) //另外,这个条件是错的,只有在判断变量是否为真假采用===,!==比较符号。否则请老老实实用==,可能这才是你不运行sql查询的根源。
{$str1="update zhuanye set xibie='".$xibie."' where id='".$id."'";
$res=mysql_db_query($db,$str1) or die( 'ERROR in mysql query. Error code: '. mysql_errno() . ', error msg: ' . mysql_error() ) ; ////////按照错误提示输出mysql错误
}
echo $id;
echo $str1;
?>
另外,id的类型是什么?你可以用Maguma调试一下
你在"6"写重新写一下,就可以了,写成以下这样
update zhuanye set xibie='11' where id='6' 看到了吗,是不是有点不同,这个我试过了,没错的
还有id是int型的if(strlen($xibie)!==0) //另外,这个条件是错的,只有在判断变量是否为真假采用===,!==比较符号。否则请老老实实用==,可能这才是你不运行sql查询的根源。
这个办法我也试过了,同样是不执行
$str="update $table set xibie='$xibie' where id='6'";
起他的代码不用改,就可以正确地执行,请问怎么解决??
$s=intval($id);
echo $s;
$str1="update zhuanye set xibie='".$xibie."' where id='$s'";
最后执行
echo $str1;
echo $id;
echo $s;
结果输出的结果是:update zhuanye set xibie='666' where id='0'0如果不对$id进行转换,那么输出结果是:
update zhuanye set xibie='666' where id=''
echo $id;
参数传入了没有?我怀疑你没有传入参数id.
用这种办法检测.
if($_GET['id']!=null)
{
$id=$_GET['id'];
}
else
{
echo "参数没有传入";
}