Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 声明变量时未定义索引_Php_Variables_Indexing_Undefined - Fatal编程技术网

Php 声明变量时未定义索引

Php 声明变量时未定义索引,php,variables,indexing,undefined,Php,Variables,Indexing,Undefined,为什么我在声明变量时得到未定义的索引?目前正在使用引导 <?php mysql\u connectlocalhost、root、1234或diemsql\u错误; mysql\u select\u dbnewitems或diemsql\u错误 $up=$_POST['update']; mysql_queryUPDATE公告设置内容=$up ?> 创建公告/提醒: 只有在您提交表单时才应进行更新。将代码包装在此条件内: if ($_SERVER['REQUEST_METHOD']

为什么我在声明变量时得到未定义的索引?目前正在使用引导

<?php 
mysql\u connectlocalhost、root、1234或diemsql\u错误; mysql\u select\u dbnewitems或diemsql\u错误

$up=$_POST['update']; mysql_queryUPDATE公告设置内容=$up

?> 创建公告/提醒:


只有在您提交表单时才应进行更新。将代码包装在此条件内:

if ($_SERVER['REQUEST_METHOD'] == POST && isset($_POST['update']) { 
   $up = $_POST['update']; 
   mysql_query("UPDATE announcements SET content = $up");
}

您正在使用变量$_POST['update'];直到你张贴表单为止没有设置。我需要做什么?也不推荐MySqL**函数,所以考虑使用MySQL函数。最后,强烈建议在查询中使用之前过滤输入:-谢谢大家!固定的:
if ($_SERVER['REQUEST_METHOD'] == POST && isset($_POST['update']) { 
   $up = $_POST['update']; 
   mysql_query("UPDATE announcements SET content = $up");
}