corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Building some workshop software/website.


New Topic

New Poll
  <<  1    2  >> Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Building some workshop software/website.
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
17th Jul 11 at 15:19   View User's Profile U2U Member Reply With Quote

It's the $query variable that it's falling over on - it's not defined anywhere.

Try this instead for your PHP file:

<?php

mysql_connect("localhost", "admin", "password") or die(mysql_error());

echo "Connected to MySQL<br />";

mysql_select_db("planner") or die(mysql_error());

$customer = $_POST["customer"];

$reg = $_POST["reg"];

$query = mysql_query("INSERT INTO vehicle (customer, reg) VALUES('$customer', '$reg' ) ") or die(mysql_error());

$result = mysql_fetch_array($query);

?>

Bold bits are what I've changed/added.
Dan
Premium Member

Avatar

Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
17th Jul 11 at 15:29   View Garage View User's Profile U2U Member Reply With Quote

Thanks sam

I'll try that when I get home. If it cures it what will happen on the page once I've submitted?

What does the result line you added do?


Adult GiftsClick here to vist us
ed
Member

Registered: 10th Sep 03
User status: Offline
17th Jul 11 at 16:01   View User's Profile U2U Member Reply With Quote

Nothing, you don't need it if you're doing an insert on a table. If you're doing a select on the table, it will put the results of the query into an array called $result.
Sam
Moderator
Premium Member


Registered: 24th Dec 99
Location: West Midlands
User status: Offline
17th Jul 11 at 16:09   View User's Profile U2U Member Reply With Quote

Oh yes, didn't notice the INSERT bit of the query!

Keep the $query line and remove the $result line in this case.

*needs more sleep*
Dan
Premium Member

Avatar

Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
17th Jul 11 at 16:46   View Garage View User's Profile U2U Member Reply With Quote

So When I run this now will it just come up connected to mysql and then the rest of the page blank? Or will it say data inserted or similar ?

Never done anything like this and I was so chuffed to see the data from my form get added to the database




Adult GiftsClick here to vist us
Dan
Premium Member

Avatar

Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
17th Jul 11 at 17:20   View Garage View User's Profile U2U Member Reply With Quote

Works like a dream

Thanks for the help! Now i can add some more fields to the form and crack on with getting the inital page done.




Adult GiftsClick here to vist us

  <<  1    2  >>
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Website building software JKGSI Geek Day 10 1258
9th Jul 04 at 09:40
by PaulW
 
website building software Robin Geek Day 5 620
13th Oct 07 at 21:26
by James
 
new workshop :) daymoon General Chat 55 2739
16th Nov 08 at 23:28
by Haimsey
 
Building a workshop in the back garden..any legal size restrictions? l15ter House Day 17 2418
27th Jul 12 at 15:43
by Rob_Quads
 
website building day bubble Geek Day 18 1402
21st Jul 10 at 12:17
by ed
 

Corsa Sport » Message Board » Off Day » Geek Day » Building some workshop software/website. 29 database queries in 0.0142961 seconds