Clinton Posted January 1, 2009 Share Posted January 1, 2009 What's wrong with the code below? It's not inserting into the second query. (If possible can I just combine the two into one statement?) if (empty($errors)) { $a = md5(uniqid(rand(), true)); $query = "INSERT INTO users (username, password, active) VALUES ('$username', SHA('$password'), '$a')"; $result = @mysql_query($query); $query2 = "INSERT INTO employers (username, fname, lname, title, prefix, cname, caddress, ccity, cstate, czip, cinfo, clogo, firstpnumber, secondpnumber, website, email, signuprate) VALUES ('$username', '$fname', '$lname', '$title', '$prefix', '$cname', '$caddress', '$ccity', '$cstate', '$czip', '$cinfo', '$clogo', '$pphone', '$sphone', '$cwebaddy', '$email', '$crate' )"; $result2 = @mysql_query($query2); Link to comment https://forums.phpfreaks.com/topic/139116-solved-multiple-table-inserts/ Share on other sites More sharing options...
Clinton Posted January 1, 2009 Author Share Posted January 1, 2009 extract($_POST); I was inserting the variables without the _POST so I just extracted it. :-p Link to comment https://forums.phpfreaks.com/topic/139116-solved-multiple-table-inserts/#findComment-727610 Share on other sites More sharing options...
revraz Posted January 1, 2009 Share Posted January 1, 2009 use mysql_error() after the query and see what error it's giving. If any of your field names are unique (username maybe?), then your insert will error. Why don't you just combine them? Link to comment https://forums.phpfreaks.com/topic/139116-solved-multiple-table-inserts/#findComment-727611 Share on other sites More sharing options...
Clinton Posted January 1, 2009 Author Share Posted January 1, 2009 Cause I don't know how to (combine them). Link to comment https://forums.phpfreaks.com/topic/139116-solved-multiple-table-inserts/#findComment-727626 Share on other sites More sharing options...
revraz Posted January 1, 2009 Share Posted January 1, 2009 Copy the field names and values in the first one and put them in the second one? Link to comment https://forums.phpfreaks.com/topic/139116-solved-multiple-table-inserts/#findComment-727630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.