Page 1 of 1

Insert into table values Not Working

Posted: Tue Dec 15, 2009 4:43 pm
by mianmajidali
hi to all,
i m trying to copy data from one table to another table in same database. by this code.
-------------------------------
foreach($_POST['delbox'] as $k=>$v)
{
$count++;
$result = mysql_query("SELECT * FROM query WHERE id=".$k);
while($row = mysql_fetch_array($result))
{
$data="insert into trash (id, name) VALUES('$row['id']','$row['name']')";
mysql_query("$data");

}
//mysql_query("delete from query where id=".$k);
}


------------------
when i execute this file, it generates the following error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home3/oscobizz/public_html/new/data.php on line 19
This is Line 19
$data="insert into trash (id, name) VALUES('$row['id']','$row['name']')";
--------------------------------------------------------
Please check and correct the error.
thanks

Re: Insert into table values Not Working

Posted: Tue Dec 15, 2009 4:50 pm
by requinix
Rather than correct it for you, I'm going to tell you to look here.