是什么原因导致:"注意:未初始化字符串偏移"出现? [英] What causes: "Notice: Uninitialized string offset" to appear?
问题描述
我有一个表格,用户填写,表格上有多个相同的领域里,如项目名称,项目日期,产品类别等基础上如何多种形式向用户提交:
I have a form that users fill out, on the form there are multiple identical fields, like "project name", "project date", "catagory", etc. Based on how many forms a user is submitting:
我的目标是:
- 遍历的表格的数量
- 创建单独的SQL INSERT语句
然而,PHP抛出我,我似乎不明白的通知:
However, PHP throws me a NOTICE that I don't seem to understand:
注意:
注意:未初始化字符串偏移:1 ... dataPasser.php在线90
Notice: Uninitialized string offset: 1 ...dataPasser.php on line 90
PHP
$myQuery = array();
if ($varsCount != 0)
{
for ($i=0; $i <= $varsCount; $i++)
{
$var = "insert into projectData values ('" . $catagory[$i] . "', '" . $task[$i] . "', '" . $fullText[$i] . "', '" . $dueDate[$i] . "', null, '" . $empId[$i] ."')";
array_push($myQuery, $var);
}
}
有这个问题我有引用,但他们不准确,我无法推断在实际问题源于。我将不胜AP preciate理解任何帮助是什么原因造成的阵列无法正常初始化。
There are references to this issue I am having but they are not exact and I am having trouble deducing where the actual problem stems from. I would greatly appreciate any help in understanding what is causing the array to not initialize properly.
推荐答案
如果任一下列变量实际上是字符串或空的,而不是阵列会发生这种错误,在这种情况下,使用数组语法访问它们是$ var [$ i]
无异是想在一个字符串访问特定的字符:
This error would occur if any of the following variables were actually strings or null instead of arrays, in which case accessing them with an array syntax $var[$i]
would be like trying to access a specific character in a string:
$catagory
$task
$fullText
$dueDate
$empId
总之,一切都在你的插入查询。
In short, everything in your insert query.
也许 $产品类别
变量拼错了?
这篇关于是什么原因导致:&QUOT;注意:未初始化字符串偏移&QUOT;出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!