Jump to content

[SOLVED] trouble inserting information in to my DB


aebstract

Recommended Posts

if (!isset($var1)) {

$content .= "
<a href=\"/prices/add/\">Add New Part</a>
";

} else {


if ($var1 == add) {

if(isset($_POST['submit'])) {

$machine = $_POST['machine'];
$partnum = $_POST['partnum'];
$partname = $_POST['partname'];
$description = $_POST['description'];
$cnc = $_POST['cnc'];
$dwg = $_POST['dwg'];
$date = date('F j, Y');
$price = N/A;


mysql_connect("localhost","berryequipment","gU8Kso8Y") or die(mysql_error());
mysql_select_db("berryequipment_net_db");

$query = MYSQL_QUERY("INSERT INTO part_pricing (date_entered, price, machine, partnum, partname, description, cnc, dwg)".
"VALUES ('$date', '$price', '$machine', '$partnum', '$partname', '$description', '$cnc', '$dwg')");

header("Location: /prices/");



}




$content .= "

<form action=\"/prices/add/\" method=\"post\">
Machine: <input type=\"text\" size=\"15\" name=\"machine\" value=\"\" /> <br />
Part #: <input type=\"text\" size=\"15\" name=\"partnum\" value=\"\" /> <br />
Part Name: <input type=\"text\" size=\"15\" name=\"partname\" value=\"\" /> <br />
Description: <input type=\"text\" size=\"15\" name=\"description\" value=\"\" /> <br />
CNC #: <input type=\"text\" size=\"15\" name=\"cnc\" value=\"\" /> <br />
DWG #: <input type=\"text\" size=\"15\" name=\"dwg\" value=\"\" /> <br />
<input type=\"submit\" name=\"submit\" value=\"Add Part\" />
</form>

";

}


 

 

For some reason my information will not insert in to my database and I am not sure why, hopefully someone can see an issue here and help out. Thanks!

Try

$query = mysql_query("INSERT INTO part_pricing (date_entered, price, machine, partnum, partname, description, cnc, dwg)".
"VALUES ('$date', '$price', '$machine', '$partnum', '$partname', '$description', '$cnc', '$dwg')") or die(mysql_error());

 

and see if there's an error, if there isn't echo your query to make sure it looks okay.

Maybe it wants a space in between the ) and VALUES

 

"...dwg)VALUES ('..."

 

$query = mysql_query("INSERT INTO part_pricing (date_entered, price, machine, partnum, partname, description, cnc, dwg) ".
"VALUES ('$date', '$price', '$machine', '$partnum', '$partname', '$description', '$cnc', '$dwg')") or die(mysql_error());

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.