Okay, here goes. Learning PHP and am having trouble building a program that would let a client insert inventory in the database without having any knowledge of MySQL or PHP.

Here is what I have so far:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add A Piece To The Inventory!</title>


<form action="upload.php" method="post">

<input type="text" name="name" maxlength="60" />Name<br>&nbsp;<br>
<input type="text" name="category" maxlength="20" />Category<br>&nbsp;<br>
<input type="text" name="type" maxlength="20" />Type<br>&nbsp;<br>
<input type="text" name="description" maxlength="80" />Description<br>&nbsp;<br>
<input type="text" name="price" maxlength="10" />Price<br>&nbsp;<br>
<input type="submit" value="Upload New Item" />



Okay so that's what they are going to see and that works fine...now here's upload.php

$cxn = mysqli_connect ("localhost","orbit","******","storeinventory")
or die ("Could not connect"); ?>

$name = $_POST;
$category = $_POST;
$type = $_POST;
$description = $_POST;
$price = $_POST;

$query = 'INSERT INTO `productlists` (`prod_number`, `name`, `category`, `type`, `description`, `price`, `pix`) VALUES (\'\', \'name\', \'category\', \'type\', \'description\', \'price\', \'\') WHERE (name="$name",category="$category",type="$type",description="$description",price="$price")';
$result = mysqli_query($cxn,$query)
or die("Couldn't execute query");


echo "Hit the BACK button to insert another item"

I get the "Couldn't execute query" everytime I try this. Please help. Yes, I know I missing something. Yes I have done something wrong. What is it though? I have tried for about 18 hours to figure this out.

10 Years
Discussion Span
Last Post by Sulley's Boo
$con = mysql_connect("localhost","root","");
if (!$con)
  die('Connection Error ' . mysql_error());

mysql_select_db("my_db", $con);

$sql="INSERT INTO productlists (prod_number, name, category, type, description, price, pix)
('$_POST[prod_number]','$_POST[name]','$_POST[category]','$_POST[type]','$_POST[description]','$_POST[price]', '$_POST[pix]')";

if (!mysql_query($sql,$con))
  die('Error: ' . mysql_error());
echo ""Hit the BACK button to insert another item"";


:?: try this .. I don't know why you used all these single quotes, slashes .. but what i know is that your code should look something like this .. give it a try ..

all the best ..

Votes + Comments
ah! moti ! tum kabse php forum visit karne lagi ! moti with glasses! lol..that would be funny!

Thank you so much! After toying with your code for about twenty seconds it works perfectly! Again thanks and you all will probably see me back here asking more questions!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.