有人能够帮助解决一个非常讨厌的数据库错误。
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以获得正确的语法,以便使用“')VALUES(' 0','警告:')'在第1行
INSERT INTO possession_new(id,)VALUES(' 0','警告:')"
我的代码:
John, thanks for identifying this. I can't seem to identify why the $pos variable has no value?
'$pos = '';
foreach($html_base->find('td[width=120]') as $k)
{
if(trim($k->plaintext) != '')
{
$pos .= 'poss_'.str_replace(' ', '_', substr(trim($k->plaintext), 0, -1)).", ";
}
}
$pos_detail = '';
foreach($html_base->find('td[class=color_text_view]b') as $k)
{
$pos_detail .= "'".mysql_real_escape_string(trim($k->plaintext))."', ";
}
foreach($html_base->find('td[width=250], td[width=251], td[width=621]') as $td)
{
$input = $td->find('input[type=text], input[type=checkbox], input[name=manager], textarea');
foreach($input as $in)
{
if($in->getAttribute('name') == 'manager')
{
$pos_detail .= "'".mysql_real_escape_string(trim($td->plaintext))."', ";
continue;
}
elseif($in->hasAttribute('rows'))
{
$pos_detail .= "'".mysql_real_escape_string(trim($td->plaintext))."', ";
continue;
}
elseif($in->getAttribute('name') == 'critical')
{
if($in->hasAttribute('checked'))
{
$pos_detail .= "'Y', ";
continue;
}
elseif(!$in->hasAttribute('checked'))
{
$pos_detail .= "'N', ";
continue;
}
}
elseif($in->getAttribute('name') == 'library')
{
if($in->hasAttribute('checked'))
{
$pos_detail .= "'Y', ";
continue;
}
elseif(!$in->hasAttribute('checked'))
{
$pos_detail .= "'N', ";
continue;
}
}
else
{
$pos_detail .= "'".mysql_real_escape_string(trim($in->getAttribute('value')))."', ";
}
}
if(!$td->find('input') && $td->previousSibling()=='<td width="120">PICOP:</td>')
{
$pos_detail .= "'', ";
}
}
$pos = substr($pos, 0, -2);
$pos_detail = substr($pos_detail, 0, -2);
$possession = "INSERT INTO possession_new ".
"(id, $pos) ".
"VALUES ".
"('0', $pos_detail)";
$this->db->query($possession);
$possession_insert_id = $this->db->insert_id();'
该脚本用于我构建的内部系统,该系统从我公司拥有的登录信息中的其他站点提供。我有完全的权限使用这个卷曲脚本,该脚本已经工作了12个月,然而,它突然发展出牙问题....
有什么建议吗?
答案 0 :(得分:3)
错误消息会清楚地显示您的错误:$pos
没有值会破坏您的查询。现在你需要找出为什么。
INSERT INTO possession_new (id, ) VALUES ('0', 'Warning:')"
^^^^^
MISSING
答案 1 :(得分:0)
您在列名id
INSERT INTO possession_new(id,)VALUES(&#39; 0&#39;,&#39;警告:&#39;)&#34;
您缺少应插入Warning
的列的名称,例如
INSERT INTO possession_new(id,myColumnName)VALUES(&#39; 0&#39;,&#39;警告:&#39;)&#34;