Insert into table values Not Working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mianmajidali
Forum Commoner
Posts: 30
Joined: Tue Dec 01, 2009 8:05 pm

Insert into table values Not Working

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Insert into table values Not Working

Post by requinix »

Rather than correct it for you, I'm going to tell you to look here.
Post Reply