Question

Hi all im trying to update the current row im putting through mysql. The line which is wrong is

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

if I comment this out all is fine, is there a problem with this specific line or is it a problem with trying to do this during a loop?

Error:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home2/mxadam/public_html/upimages.php on line 19

code:

$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>"; 
}
Was it helpful?

Solution

Basic PHP strings: You cannot use quoted array keys within a double-quoted string unless you use the {} extended syntax:

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

echo "$arr['foo']"; // incorrect
echo "$arr[foo]"; // correct
echo "{$arr['foo']}"; // correct
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top