After weeks of trying because I can not see why it is not working. Here is the code
$qry="SELECT (dm_id, mpm_id, sfi_id, hit_id, am_id, nc_id, spm_id, ds_id, s4t_id, d2c_id, ts_id, tr_id, ts25_id, tg_id, wbi_id, tp_id, tops_id) VALUES (\"$dm_id\", \"$mpm_id\", \"$sfi_id\", \"$hit_id\", \"$am_id\", \"$nc_id\", \"$spm_id\", \"$ds_id\", \"$s4t_id\", \"$d2c_id\", \"$ts_id\", \"$tr_id\", \"$ts25_id\", \"$tg_id\", \"$wbi_id\", \"$tp_id\", \"$tops_id\") FROM ews_programs WHERE $referrer_id = ews_programs.af_id";
$result=mysql_query($qry, $db);
while ($myrow=mysql_fetch_row($result)) $diff=$myrow[0];
$qry="INSERT INTO ews_programs af_id dm_id, mpm_id, sfi_id, hit_id, am_id, nc_id, spm_id, ds_id, s4t_id, d2c_id, ts_id, tr_id, ts25_id, tg_id, wbi_id, tp_id, tops_id) VALUES (\"$af_id\"\"$dm_id\", \"$mpm_id\", \"$sfi_id\", \"$hit_id\", \"$am_id\", \"$nc_id\", \"$spm_id\", \"$ds_id\", \"$s4t_id\", \"$d2c_id\", \"$ts_id\", \"$tr_id\", \"$ts25_id\", \"$tg_id\", \"$wbi_id\", \"$tp_id\", \"$tops_id\")";
$result=mysql_query($qry, $db);
What I am trying to do is copy the record of the person referring the new person to the new person. The af_id is created by sql, $referrer_id is already preset from a cookie.