gpt4 book ai didi

php - php 中的问题 if 条件

转载 作者:可可西里 更新时间:2023-11-01 13:36:05 24 4
gpt4 key购买 nike

我有一个小问题。我通过 foro.php?id=74&mode=add 或 foro.php?id=74&mode=edit 访问该站点,它工作正常。但是当我向 foro.php?id=74&mode 添加冒号、分号(; 或 :) 时=添加到编辑选项

foro.php?id=74&mode=add;
foro.php?id=74&mode=add:
foro.php?id=74&mode=add'

下面是我的代码

<?php 
$numb=mysql_real_escape_string($_GET['id']);

if ($_GET['mode']=='add') {

$sql1="select * from cello where number='".mysql_real_escape_string($numb)."' LIMIT 1";
$result1=mysql_query($sql1) or die(mysql_error());
while ($row=mysql_fetch_array($result1)) {

$name=$row['name'];
echo $name;
}
}


elseif ($_GET['mode']='edit') {

$sql="select * from cello account_number='".mysql_real_escape_string($numb)."' limit 1";
$result=mysql_query($sql) or die(mysql_error());

while ($row=mysql_fetch_array($result)) {

$acnumb=$row['number'];
$name=$row['name'];
$address=$row['address'];

echo $acnumb;
echo $name;
echo $address;

}
}
else {echo "error!!";}
?>

有什么办法可以预防吗?

最佳答案

您使用了赋值运算符 = 而不是相等运算符 ==

尝试改变这个:

elseif ($_GET['mode']='edit') {

为此:

elseif ($_GET['mode']=='edit') {

关于php - php 中的问题 if 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3116131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com