首页 \ 问答 \ PHP:“注意:未定义的变量”,“注意:未定义的索引”和“注意:未定义的偏移量”(“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP)

PHP:“注意:未定义的变量”,“注意:未定义的索引”和“注意:未定义的偏移量”(“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP)

我正在运行一个PHP脚本,并且不断得到如下错误:

注意:未定义的变量:my_variable_name在C:\ wamp \ www \ mypath \ index.php第10行

注意:未定义的索引:第11行上的my_index C:\ wamp \ www \ mypath \ index.php

第10行和第11行如下所示:

echo "My variable value is: " . $my_variable_name;
echo "My index value is: " . $my_array["my_index"];

这些错误是什么意思?

为什么突然出现? 我曾经使用这个脚本多年,我从来没有任何问题。

我需要做些什么来解决它们?

这是一个通用参考问题 ,人们可以链接到重复,而不是一遍又一遍地解释这个问题。 我觉得这是必要的,因为在这个问题上的大多数真实世界的答案都是非常具体的。

相关元讨论:

  • 对重复性问题可以做些什么?
  • 做“参考问题”有意义吗?

I'm running a PHP script, and continue to receive errors like:

Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php on line 10

Notice: Undefined index: my_index C:\wamp\www\mypath\index.php on line 11

Line 10 and 11 looks like this:

echo "My variable value is: " . $my_variable_name;
echo "My index value is: " . $my_array["my_index"];

What is the meaning of these error messages?

Why do they appear all of a sudden? I used to use this script for years and I've never had any problem.

How do I fix them?

This is a General Reference question for people to link to as duplicate, instead of having to explain the issue over and over again. I feel this is necessary because most real-world answers on this issue are very specific.

Related Meta discussion:


原文:https://stackoverflow.com/questions/4261133
更新时间:2023-01-09 14:01

最满意答案

k ...所以OP没有回应。 这很酷。 这是关于该错误的mysql文档... http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-compression-syntax-warnings.html

  • 运行ALTER TABLE xyz ENGINE=InnoDB; 再次刺激。

  • 然后show errors;

  • 做一个show create table xyz;

  • 看看你是否处于innodb严格模式......(我会在prod和non-prod都这样做,看看有什么区别) SELECT @@GLOBAL.sql_mode; SELECT @@SESSION.sql_mode; SELECT @@GLOBAL.sql_mode; SELECT @@SESSION.sql_mode;

  • 来自docs: 如果您在InnoDB严格模式下运行, KEY_BLOCK_SIZE与除COMPRESSED KEY_BLOCK_SIZE的任何ROW_FORMAT的组合会生成错误,而不是警告,并且不会创建表。

  • 使用您获得的信息和链接中的信息来确定如何设置key_block_sizerow_format以使其获取它。

非prod数据库的工作原理是:

  • 使用任何其他ROW_FORMAT指定ROW_FORMAT生成警告,您可以使用SHOW WARNINGS查看。 但是,该表是非压缩的; 指定的KEY_BLOCK_SIZE被忽略)。 (在非innodb严格模式下)

如果你想要更多的帮助,发布你得到的信息,我绝对可以建议...这可能是alter table xyz engine=innodb ROW_FORMAT=COMPRESSED; 和/或使innodb模式设置等于非prod数据库设置的设置。

key_block_size

比你想知道的行格式更多

对于真实的,虽然......听起来像prod是在innodb严格模式而非prod不是。


发现了这个:

innodb_strict_mode:

The innodb_strict_mode option controls whether InnoDB operates in strict mode, 
where conditions that are normally treated as warnings, cause errors instead 
(and the underlying statements fail).

This mode is the default setting in MySQL 5.5.5 and higher. 

你的一个版本高于5.5.5,另一个低于。 那个默认可能是差异......


k... so OP isn't responding. that's cool. this is the mysql documentation on that error... http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-compression-syntax-warnings.html

  • run ALTER TABLE xyz ENGINE=InnoDB; in prod again.

  • then do show errors;.

  • do a show create table xyz;

  • see if you're in innodb strict mode... (i would do this in both prod and non-prod to see any difference) SELECT @@GLOBAL.sql_mode; SELECT @@SESSION.sql_mode;

  • from docs: If you are running in InnoDB strict mode, the combination of a KEY_BLOCK_SIZE with any ROW_FORMAT other than COMPRESSED generates an error, not a warning, and the table is not created.

  • use that info you got and the info at the link to determine how you should set your key_block_size and row_format to get it to take it.

the non-prod db works because:

  • Specifying a KEY_BLOCK_SIZE with any other ROW_FORMAT generates a warning that you can view with SHOW WARNINGS. However, the table is non-compressed; the specified KEY_BLOCK_SIZE is ignored). (in non-innodb-strict mode)

if you want more help, post the info you get and i can definitely suggest things... which would probably be alter table xyz engine=innodb ROW_FORMAT=COMPRESSED; and/or making the innodb mode setting equal to what your non-prod db is set with.

key_block_size

more than you ever wanted to know on row formats

for real, though... it sounds like prod is in innodb strict mode and non-prod isn't.


found this:

innodb_strict_mode:

The innodb_strict_mode option controls whether InnoDB operates in strict mode, 
where conditions that are normally treated as warnings, cause errors instead 
(and the underlying statements fail).

This mode is the default setting in MySQL 5.5.5 and higher. 

One of your versions is above 5.5.5 and the other is below. That default might be the discrepancy....

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)