Trouble inserting values into database

I keep getting an error when i submit my userform. when i delete $value_3 it uploads the rest into the database. i need the column ‘onum’ to accept the submit. please help. here is the code…

[php]<?php

require_once(‘functions.php’);
require_once(‘config.php’);

connect();

$value=$_POST[‘quantity’];
$value_1=$_POST[‘products’];
$value_2=$_POST[‘shippedby’];
$value_3=$_POST[‘onum’];
$value_4=$_POST[‘destination’];

$sql=“INSERT INTO producttest (quantity, products, shippedby, onum, destination) VALUES (’$value’, ‘$value_1’, ‘$value_2’, ‘$value_3’, ‘$value_4’)”;
if (!mysql_query($sql));
{
die('error uploading content: ’ . mysql_error());
}
mysql_close();
?>[/php]

Show the code for the forum to

This is Josh, here is the form code as well…
[php]<?php include('header.php'); ?>

Quantity:

Products:

2 Ply 3 Ply

Shipped by:

Order number:

Destination:

<?php include('footer.php'); ?>[/php]

I am not certain, but I am going to try as many people have helped me on here.

I believe you need to assign an ID to your select menu to reflect the value of your code:

<p>Products: <select name="products"></p>
<option value="2ply">2 Ply</option>
<option value="3ply">3 Ply</option>
</select>

As

<p>Products: <select name="products" id="value_1"></p>
<option value="2ply">2 Ply</option>
<option value="3ply">3 Ply</option>
</select>

Ok ive got it inserting the values into the database, but it still gives me an error, not sure what the problem is.

Form is this:
[php]<?php include('header.php'); ?>

Quantity:

Products:

2 Ply 3 Ply

Shipped by:

Order number:

Destination:

<?php include('footer.php'); ?>[/php]

and process.php is:
[php]<?php

require_once(‘functions.php’);
require_once(‘config.php’);

connect();

$value=$_POST[‘quantity’];
$value_1=$_POST[‘products’];
$value_2=$_POST[‘shippedby’];
$value_3=$_POST[‘onum’];
$value_4=$_POST[‘destination’];

$sql=“INSERT INTO producttest (quantity, products, shippedby, onum, destination) VALUES (’$value’, ‘$value_1’, ‘$value_2’, ‘$value_3’, ‘$value_4’)”;
if (!mysql_query($sql));
{
die('error uploading content: ’ . mysql_error());
}
mysql_close();
?>[/php]

The error is now just my “error uploading content:” but no mysql_error statement.

I think this is your culprit here:
[php]
if (!mysql_query($sql));
[/php]

remove the semi colon

[php]
if (!mysql_query($sql))
[/php]

That worked! I cant believe i overlooked that. Thank you twcast! :slight_smile:

You are very much welcome. I am just happy to be able to assist someone else for a change. :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service