Jump to content

Can't Insert Items Into MYSQL


brucegregory

Recommended Posts

This is probably some obvious error I have made, but I cannot figure it out. I have made a few pages and now I am debugging them. My first page is called insert_purchase_order.php; on this page a person will enter some data in fields and hit the insert button. Then, the data is passed to another page, but when I try to insert into mysql it does not give me any errors, but I have no new rows either. The code for my 2nd page:

 

<?php
session_start();
$action=$_GET[action];
if ($action==insert){

$randid=$_POST['randid'];
$vendor=$_POST["vendor"];
$purchase_order_date=$_POST["purchase_order_date"];
$ship=$_POST["ship"];
$fob=$_POST["fob"];
$terms=$_POST["terms"];
$buyer=$_POST["buyer"];
$freight=$_POST["freight"];
$req_date=$_POST["req_date"];
$confirming_to=$_POST["confirming_to"];
$remarks=$_POST["remarks"];
$tax=$_POST["tax"];


$con = mysql_connect("localhost","root","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("main", $con);

mysql_query("INSERT INTO purchase_order (randid, vendor, purchase_order, ship, fob, terms, buyer, freight, req_date, confirming_to, remarks, tax)
VALUES ($randid, $vendor,$purchase_order_date,$ship, $fob, $terms, $buyer, $freight, $req_date, $confirming_to, $remarks, $tax)");

mysql_close($con);

echo 'Data Accepted...'; 
echo '<br/>';
echo 'P.O. Inserted Successfully';


}else{
echo 'Error... Please Contact Bruce.';
echo 'Bruce, no data was passed from the insert_purchase_order.php page.';
}


?>
<a href="http://localhost/insert_purchase_order_items.php?po= <?php echo $randid; ?>">Insert Purchase Order Items</a>

 

I have permissions and everything.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/262533-cant-insert-items-into-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.