使用php条件运算符在mysqli_查询中设置值

使用php条件运算符在mysqli_查询中设置值,php,mysql,conditional-operator,Php,Mysql,Conditional Operator,我有以下代码。addstats查询echo语句返回一个空白,不确定查询出了什么问题。它是条件运算符吗?category_tally是一个多维数组,因此在赋值之前,我需要检查键是否存在 $add_stats_query= "INSERT INTO stats(word_count, sentence_count, avg_sent_length,

我有以下代码。addstats查询echo语句返回一个空白,不确定查询出了什么问题。它是条件运算符吗?category_tally是一个多维数组,因此在赋值之前,我需要检查键是否存在

$add_stats_query=   "INSERT INTO stats(word_count,
                            sentence_count,
                            avg_sent_length,
                            7charword_count,
                            liwc_1_per,
                            liwc_2_per) VALUES (
                            ".$word_count.",
                            ".$sentence_count.",
                            ".$avg_sentence_length.",
                            ".$sevenchar_words.",
                            ".(array_key_exists(1,$category_tally)?$category_tally[1]["count"]:0).",
                            ".(array_key_exists(2,$category_tally)?$category_tally[2]["count"]:0).");";

echo    "*********".$add_stats_query."<br><br>";
$add\u stats\u query=“插入统计(word\u count,
判决(计算),,
平均发送长度,
7个字的计数,
每件1件,
liwc_2_per)值(
“$word_count。”,
“$SECTION_count。”,
“$avg_句子长度。”,
“$sevenchar_单词。”,
“(数组键存在(1,$category\u-tally)?$category\u-tally[1][“count”]:0)。”,
“(数组键存在(2,$category\u tally)?$category\u tally[2][“count”]:0)。”;
回显“*******”$add_stats_query。”

”;
我粘贴了这个精确的代码并进行了测试:它工作得非常好。我认为正在发生的是,您的代码中有一个错误(在您发布的部分之外的其他地方),并且您已经关闭了display_errors。打开它,调试代码。谢谢,前面的语句中有一个错误。显示所指出的错误。。