php - 更新语句不起作用

标签 php mysql

function add_new($father,$chName)  // add new category
{

    if($father = "1" ) {


$result = mysql_query("INSERT into stinky_menu (title,nest_under)
        VALUES('".$chName."','1')");

    } 
     else { 

$result = mysql_query("UPDATE stinky_menu SET title  = '$chName' nest_under = '$father'");

     }

 }

我正在从父页面获取 father 的值,但如果它不等于 1,则不会使用其他条件。

最佳答案

您正在使用 assignment operator = 而不是 comparison operator ==。所以试试这个:

if ($father == "1") {
    // …
} else {
    // …
}

关于php - 更新语句不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1147773/

相关文章:

MySQL数据获取

php - 如何从聊天对话中获取最后一条消息?

java - session.get() 在 hibernate 状态下返回 null

php - 显示与 WP po​​st-id 匹配的数据库表行

php - 如何通过 PHP 访问 JSON 数组数组中的字符串对象?

基于评分公式的 PHP 数组排序?

c++ - Mysql++ "undefined reference to __imp___ZN7mysqlpp10ConnectionC1Eb"

python - 如何在 Python 中检查 MySQL 连接是否已关闭?

php - 尝试创建用于连接数据库的字符串时出错(mysql :host =' . DB_HOST . ' ;dbname=' . DB_DATABASE;)

php - 获取多个图像以适应未知图像尺寸的浏览器尺寸