作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果没有要插入的数据,mysql会发生什么情况。意思是下面的代码:
$result = mysql_query("INSERT INTO table (column1, column2)
VALUES ('$var1', '$var2')");
mysql_close();
如果 $var2 为空,后续的 if($result)
会发生什么情况?$var1 和 $var2 是从数组中提取的,如下所示:
$var1= $data->var1;
$var2= $data->var2;
我碰巧知道 var2 没有(或者不应该返回任何内容,因为它不在数组检索的原始数据集中)。
基本上我的页面停止了,当它应该进入这个if
时什么也没有发生...但事实并非如此。这有任何意义吗?我认为只要 $result 内部至少发生了一些事情,它就存在?问题是,else
也没有发生,整个代码只是停在中间......:(
最佳答案
$result = mysql_query("INSERT INTO table (column1, column2)
VALUES ('$var1', '$var2')");
mysql_close();If $var2 is empty, what happens to the subsequent if($result)?
没有数据“丢失”。空字符串 (""
) 是完全有效的字段值。
$var1 and $var2 were extracted from an array like so:
$var1= $data->var1;
$var2= $data->var2;
您无法从这样的数组中获取数据,所以,不,它们不是。
<小时/>The thing is, the else isn't happening either, the whole code just stops in the middle... :(
打开错误日志记录。您在某处没有看到错误。
关于php - 当某些数据丢失时,mysql $result 是否设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8771943/
我是一名优秀的程序员,十分优秀!