Page 1 of 1
check the error in code (insert into table values)
Posted: Tue Dec 15, 2009 4:02 pm
by mianmajidali
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);
}
}
Re: check the error in code (insert into table values)
Posted: Tue Dec 15, 2009 4:18 pm
by AbraCadaver
What error?
Re: check the error in code (insert into table values)
Posted: Tue Dec 15, 2009 4:33 pm
by mianmajidali
can u remove the error in my code plz ??
Re: check the error in code (insert into table values)
Posted: Tue Dec 15, 2009 4:41 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: check the error in code (insert into table values)
Posted: Tue Dec 15, 2009 6:19 pm
by AbraCadaver