Hi,

I'm trying to do an update on one table of a record, depending on a field in that table matching a field in an associated table.

I've tried this query, and continually get a mysql_error even after trying a few different variations.

Any suggestions? I may have the structure incorrect for doing the join.

mem_id is the auto increment field in user table and the matching record number in the user_data table

$sql_ud = "UPDATE user_data d, users u SET d.fname=$fname, d.mname=$mname, d.lname=$lname, d.addr1=$addr1, d.addr2=$addr2, d.city=$city, d.state=$state, d.zip=$zip, d.phone=$phone, d.dsp_pref=$dsp_pref WHERE u.user = '$affiliate' AND d.mem_id = u.mem_id ";

    $result=mysql_query($sql_ud) or die(mysql_error);

    I noticed that many of your variables which appear to be text are not enclosed in quotes (i.e. - add1, addr2, etc.). Are the quotes already part of the variable?

    Could you change your die() statement to...

    $result = mysql_query($sql_ud) or die(mysql_error()."<br><br>".$sql_ud);

    ...and post the result here?

      Thank you ixalmida,

      It is sometimes amazing how easy it is to over look the simple things...

      That was the issue, and it is working fine now.

      Doug

        Write a Reply...