我的函数返回true但我的代码没有执行 [英] My function returns true but my code does not execute
问题描述
我必须遗漏一些明显的东西。
我无法使用此功能在第6行运行更新查询,虽然
运行查询的调用求值为true,并且update_cat_total
函数都执行,而函数本身返回true。
var_dump显示所有变量都是有效的,我可以在mysql命令行运行
完全相同的更新查询而没有错误。我已经在调用mysql_query()之前和之后回显了mysql_error()并且没有
错误出现。
但更新本身永远不会运行!谁能明白为什么?
函数new_category($ category_id = null){
global $ category_id_new;
if(create_category($ _ SESSION [''cat_name''])){
//使用新的category_id更新此页
$ query =" UPDATE
关于
SET
category_id = $ category_id_new
WHERE
about_id = $ _SESSION [about_id ]" ;;
if($ result = mysql_query($ query)){
if(update_cat_total(''add'',$ category_id_new)& ;&
update_cat_total(''删除'',$ category_id)){
返回true;
}
else {
返回false;
}
}
else {
返回false;
}
}
else {
返回false;
}
}
谢谢
J摩尔
Hi,
I must be missing something obvious.
I cannot get this function to run the update query on Line 6, although
the call to run the query evaluates true, and both update_cat_total
functions execute, while the function itself returns true.
A var_dump shows that all the variables are valid, and I can run the
exact same update query at the mysql command line without errors. I''ve
echoed mysql_error() before and after the call to mysql_query() and no
errors show up.
But the update itself never runs! Can anyone see why?
function new_category($category_id=null) {
global $category_id_new;
if (create_category($_SESSION[''cat_name''])) {
// update this page with the new category_id
$query = "UPDATE
about
SET
category_id = $category_id_new
WHERE
about_id = $_SESSION[about_id]";
if ($result = mysql_query($query)) {
if (update_cat_total(''add'', $category_id_new) &&
update_cat_total(''remove'', $category_id)) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
Thanks
J Moore
推荐答案
category_id = null){
global
category_id=null) {
global
category_id_new;
if(create_category(
category_id_new;
if (create_category(
_SESSION [''cat_name''])) {
//使用新的category_id更新此页
_SESSION[''cat_name''])) {
// update this page with the new category_id
这篇关于我的函数返回true但我的代码没有执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!