php在w循环期间更新当前行

时间:2014-03-04 19:49:20

标签: php mysql

大家好我试图通过mysql更新当前行。错误的一行是

mysql_query("UPDATE wp_postmeta SET meta_value = '$newimg', converted = 1 WHERE post_id = $info['post_id']");

如果我评论这一切都很好,这个特定的行是否有问题,或者在循环期间尝试执行此操作是否有问题?

错误:

  

解析错误:第19行/home2/mxadam/public_html/upimages.php中的语法错误,意外的''(T_ENCAPSED_AND_WHITESPACE),期望标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)

代码:

$data = mysql_query("SELECT post_id, meta_value FROM wp_postmeta WHERE post_id =   1926914") 
or die(mysql_error()); 
Print "<table border cellpadding=3>"; 
Print "start";
while($info = mysql_fetch_array( $data )) 
{ 
$newimg = itg_fetch_image($info['meta_value']);
echo $newimg;
mysql_query("UPDATE wp_postmeta SET meta_value = '$newimg', converted = 1 WHERE post_id = $info['post_id']");
Print "<tr>"; 
Print "<th>ID:</th> <td>".$info['meta_postid'] . "</td> "; 
Print "<th>VALUE:</th> <td>".$info['meta_value']. "</td> "; 
Print "<th>DONE:</th> <td>YES</td> "; 
} 
Print "End";
Print "</table>"; 
}

1 个答案:

答案 0 :(得分:4)

基本PHP字符串:除非使用{}扩展语法,否则不能在双引号字符串中使用带引号的数组键:

$arr['foo'] = 'bar';

echo "$arr['foo']"; // incorrect
echo "$arr[foo]"; // correct
echo "{$arr['foo']}"; // correct