Forum Moderators: coopster

Message Too Old, No Replies

Inserting into one table while grabbing data from another

         

ntbgl

7:15 pm on Aug 30, 2008 (gmt 0)

10+ Year Member



Are mysql inserts inherently flawed when inside a while loop outputting results from another table?

This doesn't seem to be working.

$query=mysql_query("SELECT * from table1");
while($result=mysql_fetch_array($query)){

mysql_query("INSERT INTO table2 (data1, data2, data3) VALUES ('".addslashes($data1)."', '".addslashes($data2)."', '".addslashes($data3)."')");

}

coopster

7:22 pm on Aug 30, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You aren't using the fetched data array [php.net]. In your example you called it
$result
.