Sam
Moderator Premium Member
Registered: 24th Dec 99
Location: West Midlands
User status: Offline
|
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
Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
|
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
|
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
|
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
Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
|
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
Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
|
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
|