yddib Posted September 10, 2008 Share Posted September 10, 2008 Hi, I am having a problem assigining an auto number generated in one table to two other tables. When people register on the site, there is an autonumber generated in the database. I am trying to insert this into 2 other fields in different tables. When I tried this is stopped inserting anything to the database. Please help! <?php session_start(); $id = $_SESSION['id']; ?> <html> <head> <title>4grads - Contact Us</title> <link rel="stylesheet" href="style1.css" type="text/css" /> <style type="text/css"> form.pos {position:absolute; left: 250px} </style> <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.4grads.net"> </head> <body> <div id="sidebar"> <a href="index.html" /><img src="translogo.jpg" alt="4Grads Logo" /></a><br /><br /><br /><br /> <div id="menu" style="width: 170; height: 220"> </div> </div> <div id="content"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" background="bannercreator-nu2.gif" height="55"> <tr> <td width="5%" height="55" align="center"> <td width="40%" height="55" align="center"> <font color="#FFFFFF" size="3">Registration Successful</font></td> <td width="15%" height="55" align="center"></td> <td width="20%" height="55" align="center"> </td> <td width="20%" height="55" align="center"> <font color="#FFFFFF" size="3"></font></td> <td width="20%" height="55" align="center"> <a href="help.html"><font color="#FFFFFF" size="3">Help </font></a></td> </tr> </table> <?php mysql_connect("host", "user", "pass") or die(mysql_error()); //connects to the blacknight server mysql_select_db("db")or die(mysql_error()); $fname=$_POST['myname']; $lname=$_POST['myname1']; $email=$_POST['myEmail']; $pass=$_POST['pass']; $gender=$_POST['gender']; $birthm=$_POST['birthm']; $birthd=$_POST['birthd']; $birthy=$_POST['birthy']; $address1=$_POST['address1']; $county=$_POST['county']; $country=$_POST['country']; $phone=$_POST['phone']; $location=$_POST['location']; $course=$_POST['course']; $occupation=$_POST['occupation']; mysql_query("INSERT INTO gradinfo (f_name,l_name,email,pass,gender,birthm,birthd,birthy,address1,county,country,telephone,location) VALUES ('$fname','$lname','$email','$pass','$gender','$birthm','$birthd','$birthy','$address1','$county','$country','$phone','$location')");//Set SQL mysql_query("INSERT INTO gradcoll (u_course) VALUES ('$course')"); mysql_query("INSERT INTO gradcoll (u_id) VALUES ('$id')"); mysql_query("INSERT INTO gradwork (occupation) VALUES ('$occupation')"); mysql_query("INSERT INTO gradwork (u_id) VALUES ('$id')"); echo '<br /><br />Congratulations!! You have successfully joined <i>4Grads</i>'; echo '<br /><br />Please Login <a href="index.html">HERE</a>' ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
fenway Posted September 10, 2008 Share Posted September 10, 2008 I'm very confused about your db design. Quote Link to comment Share on other sites More sharing options...
StrangeWill Posted September 10, 2008 Share Posted September 10, 2008 I'm guessing you want to do this: mysql_query("INSERT INTO gradinfo (f_name,l_name,email,pass,gender,birthm,birthd,birthy,address1,county,country,telephone,location) VALUES ('$fname','$lname','$email','$pass','$gender','$birthm','$birthd','$birthy','$address1','$county','$country','$phone','$location')");//Set SQL mysql_query("INSERT INTO gradcoll (u_course, u_id) VALUES ('$course', '$id')"); mysql_query("INSERT INTO gradwork (occupation, u_id) VALUES ('$occupation', '$id')"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.