Insert into table values Not Working
Posted: Tue Dec 15, 2009 4:43 pm
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
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