snowweb
01-18-2006, 01:06 AM
I am a PHP and MySQL newbie, so please be gentle with me.
I have made a database and a .php page which reads it and displays the data, however, I am having difficulty getting my page which inserts data to the database, to work.
This is the code for the form which accepts the data:
<form action="insert.php" method="get">
<input type="Submit" name="submit" /> <br />
Name/Model: <input type="text" name="namemodel" /><br />
Manufacturer: <input type="text" name="manufacturer" /><br />
Tagline: <input type="text" name="tagline" /><br />
Ed Summary: <textarea cols="20" rows="10" name="ed_summary"></textarea><br />
Main Editorial: <textarea cols="20" rows="20" name="ed_main"></textarea><br />
Features: <textarea cols="20" rows="20" name="features"></textarea><br />
Specs: <textarea cols="20" rows="10" name="specs"></textarea><br />
Options: <textarea cols="20" rows="10" name="options"></textarea><br />
Thumbnail Picture: <input type="text" name="pic_thumb_100x100" /><br />
Picture 1: <input type="text" name="pic_1" /><br />
Picture 2: <input type="text" name="pic_2" /><br />
Cost Price: <input type="text" name="costprice" /><br />
Retail Price: <input type="text" name="retailprice" /><br />
Supplier ID: <input type="text" name="supplierid" /><br />
Current Stock: <input type="text" name="curr_stock" /><br />
Minimum Stock: <input type="text" name="minstock" /><br />
Maximum Stock: <input type="text" name="maxstock" /><br />
<input type="Submit" name="submit" />
</form>
and this is the page called ‘insert.php’ which should insert the data to the database:
<?php
$username="removed for forum";
$password="removed for forum";
$database="myodbc_store";
$NameModel=$_GET['namemodel'];
$Manufacturer=$_GET['manufacturer'];
$Tagline=$_GET['tagline'];
$Ed_Summary=$_GET['ed_summary'];
$Ed_Main=$_GET['ed_main'];
$Features=$_GET['features'];
$Specs=$_GET['specs'];
$Options=$_GET['options'];
$Pic_Thumb_100x100=$_GET['pic_thumb_100x100'];
$Pic_1=$_GET['pic_1'];
$Pic_2=$_GET['pic_2'];
$CostPrice=$_GET['costprice'];
$RetailPrice=$_GET['retailprice'];
$SupplierID=$_GET['supplierid'];
$Curr_Stock=$_GET['curr_stock'];
$MinStock=$_GET['minstock'];
$MaxStock=$_GET['maxstock'];
$conn1=odbc_connect($database,$username,$password);
$query = ("INSERT INTO products VALUES ('', '$NameModel', '$Manufacturer', '$Tagline', '$Ed_Summary', '$Ed_Main', '$Specs', '$Features', '$Options', '$Pic_Thumb_100x100', '$Pic_1', '$Pic_2', '$CostPrice', '$RetailPrice', '$SupplierID', '$Curr_Stock', '$MinStock', '$MaxStock')");
?>
My testing has led me to believe that the data is being received by insert.php but is for some reason, not being stored in the database.
There is no error message.
Thanks for your time
pete
I have made a database and a .php page which reads it and displays the data, however, I am having difficulty getting my page which inserts data to the database, to work.
This is the code for the form which accepts the data:
<form action="insert.php" method="get">
<input type="Submit" name="submit" /> <br />
Name/Model: <input type="text" name="namemodel" /><br />
Manufacturer: <input type="text" name="manufacturer" /><br />
Tagline: <input type="text" name="tagline" /><br />
Ed Summary: <textarea cols="20" rows="10" name="ed_summary"></textarea><br />
Main Editorial: <textarea cols="20" rows="20" name="ed_main"></textarea><br />
Features: <textarea cols="20" rows="20" name="features"></textarea><br />
Specs: <textarea cols="20" rows="10" name="specs"></textarea><br />
Options: <textarea cols="20" rows="10" name="options"></textarea><br />
Thumbnail Picture: <input type="text" name="pic_thumb_100x100" /><br />
Picture 1: <input type="text" name="pic_1" /><br />
Picture 2: <input type="text" name="pic_2" /><br />
Cost Price: <input type="text" name="costprice" /><br />
Retail Price: <input type="text" name="retailprice" /><br />
Supplier ID: <input type="text" name="supplierid" /><br />
Current Stock: <input type="text" name="curr_stock" /><br />
Minimum Stock: <input type="text" name="minstock" /><br />
Maximum Stock: <input type="text" name="maxstock" /><br />
<input type="Submit" name="submit" />
</form>
and this is the page called ‘insert.php’ which should insert the data to the database:
<?php
$username="removed for forum";
$password="removed for forum";
$database="myodbc_store";
$NameModel=$_GET['namemodel'];
$Manufacturer=$_GET['manufacturer'];
$Tagline=$_GET['tagline'];
$Ed_Summary=$_GET['ed_summary'];
$Ed_Main=$_GET['ed_main'];
$Features=$_GET['features'];
$Specs=$_GET['specs'];
$Options=$_GET['options'];
$Pic_Thumb_100x100=$_GET['pic_thumb_100x100'];
$Pic_1=$_GET['pic_1'];
$Pic_2=$_GET['pic_2'];
$CostPrice=$_GET['costprice'];
$RetailPrice=$_GET['retailprice'];
$SupplierID=$_GET['supplierid'];
$Curr_Stock=$_GET['curr_stock'];
$MinStock=$_GET['minstock'];
$MaxStock=$_GET['maxstock'];
$conn1=odbc_connect($database,$username,$password);
$query = ("INSERT INTO products VALUES ('', '$NameModel', '$Manufacturer', '$Tagline', '$Ed_Summary', '$Ed_Main', '$Specs', '$Features', '$Options', '$Pic_Thumb_100x100', '$Pic_1', '$Pic_2', '$CostPrice', '$RetailPrice', '$SupplierID', '$Curr_Stock', '$MinStock', '$MaxStock')");
?>
My testing has led me to believe that the data is being received by insert.php but is for some reason, not being stored in the database.
There is no error message.
Thanks for your time
pete