Log in

View Full Version : Problem with Mysql query



ace2721
10-10-2008, 10:21 AM
Hi I am after some help with mysql, I am new to this so please be gentle . I have created a form on our website that sends an email to our database and then to an email account which is working fine, I am trying to date stamp on submit which is working but its creating a new line in the database and not including the enquiry, what I think I have done is created two query that are working separately and not together. I have included the queries below; please can someone show me how to join these two queries together please.

Thanks


$query = "INSERT INTO pitman (id, f_name, postcode, tel, mobile, email, course) VALUES ('', '$f_name', '$postcode', '$tel', '$mobile', '$email' , '$course')";

$query = "INSERT INTO `pitman` (`pdate`) VALUES (NOW())";

Moshambi
10-10-2008, 06:55 PM
if they are both inserting values into the same table why not just do it all in one shot?




$query = "INSERT INTO pitman(id, f_name, postcode, tel, mobile, email, course, pdate) VALUES ('$f_Name', '$postcode', '$tel', '$mobile', '$email', '$course',NOW())";



Also I am just curious, for your id field are you setting it to auto_increment or are you inserting the id in each INSERT query?

I hope this helps...

motormichael12
10-11-2008, 02:47 AM
Whether it is incrementing or not the query still needs to be changed... either one of these would work for auto increment:


$query = "INSERT INTO pitman(id, f_name, postcode, tel, mobile, email, course, pdate) VALUES (null, '$f_Name', '$postcode', '$tel', '$mobile', '$email', '$course',NOW())";

$query = "INSERT INTO pitman(f_name, postcode, tel, mobile, email, course, pdate) VALUES ('$f_Name', '$postcode', '$tel', '$mobile', '$email', '$course',NOW())";


If you are keeping track on your own you need something liek this:

$query = "INSERT INTO pitman(id, f_name, postcode, tel, mobile, email, course, pdate) VALUES ('$id', '$f_Name', '$postcode', '$tel', '$mobile', '$email', '$course',NOW())";

ace2721
10-13-2008, 07:26 AM
Hi guys thanks so much for your help it worked a treat