Jump to content

LOSMAN

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Everything posted by LOSMAN

  1. last bit now and i can't do it! the orders are now working but my insert for order_items is wrong and i can't see why. i have echo'd it back to see what is trying to be inserted but it is not valid sql this is the error from the brwoser INSERT INTO Order_items ( 'OrderId' , 'ItemId' , 'qty' , 'price' ) VALUES ( 33,1,3,180.00)Error creating item in addItem Query in process order so i tried entering this into mysql, but it doesn't like it! INSERT INTO Order_items ( 'OrderId' , 'ItemId' , 'qty' , 'price' ) VALUES ( 33,1,3,180.00)
  2. YEY! thankyou! now i just have to sort my inserts out! thanks guys! "Error creating item in addItem Query in process order"
  3. please explian like you would a 5 year old lol!!!! i think you mean i should be defining what $connection is????
  4. im not sure what you mean? i thought you only had to include it at the top?
  5. im not so sure it's my connection.php as it already allows me to pass data into the database with other pages such as registering users and ammending products. any how here's my connection.php P.S. was my insert correct?? i was'nt so sure about it??? <? $host="mysql11.000webhost.com"; // Host name $dbusername="a2944313_1234"; // Mysql username $dbpassword="*****"; // Mysql password $db_name="a2944313_123"; // Database name //Connect to server and select database. mysql_connect("$host", "$dbusername", "$dbpassword")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); ?>
  6. i tried the insert below but gave me the same error, have i written it wrong? $createOrder = "INSERT INTO Orders (' ',id,date,' ',creditcard, expirydate) VALUES (' ',".$_SESSION["id"].",'$date',' ','$creditcard','$expiry'"; PFMaBiSmAd, yeah your right im wasting loads of time waiting for the server but i have no choice at the moment as my uni server is playing up! should i post my connection.php because my connection.php is able to pass data into the DB on other pages such as register.php etc.???
  7. yeah im aware of the rules etc, but this is just for a university project of mine so peoples info won't be at risk. thanks for replying so quickly! here's my database: DROP TABLE IF EXISTS Customer CASCADE; DROP TABLE IF EXISTS Products CASCADE; DROP TABLE IF EXISTS Category CASCADE; DROP TABLE IF EXISTS Orders CASCADE; DROP TABLE IF EXISTS Order_items CASCADE; -- Create a Database table to represent the "Customer" entity. CREATE TABLE Customer( id int(11) NOT NULL auto_increment, username VARCHAR(30) NOT NULL, firstname VARCHAR(25) NOT NULL, secondname VARCHAR(25) NOT NULL, address1 VARCHAR(40) NOT NULL, address2 VARCHAR(30) NOT NULL, city VARCHAR(25) NOT NULL, postcode VARCHAR( NOT NULL, country VARCHAR(15) NOT NULL, mobilenumber VARCHAR(12) NULL, email VARCHAR(50) NOT NULL, password VARCHAR(12) NOT NULL, privledge VARCHAR(1) NOT NULL DEFAULT 1, PRIMARY KEY (id) ); CREATE TABLE Products ( ItemId MEDIUMINT NOT NULL AUTO_INCREMENT, Name VARCHAR(25) NOT NULL, Description VARCHAR(50) NOT NULL, Price DECIMAL(8,2) NOT NULL, ImageName VARCHAR(25) NOT NULL, CategoryId VARCHAR(12) NOT NULL REFERENCES Category(CategoryId), PRIMARY KEY (itemId) ); CREATE TABLE Category( CategoryId VARCHAR( NOT NULL, CategoryType VARCHAR (32) NOT NULL, PRIMARY KEY (CategoryId) ); CREATE TABLE Order_items ( OrderId int(5) NOT NULL, ItemId int(4) NOT NULL, qty int(3), price decimal(5,2), PRIMARY KEY (OrderId,ItemId) ); CREATE TABLE Orders ( OrderId int(5) NOT NULL auto_increment, id int(5) NOT NULL, date varchar(10), instructions varchar(128), creditcard char(16), expirydate char(5), PRIMARY KEY (OrderId) );
  8. ahhhh i see, i'll edit the post now, thanks!
  9. hi, thanks for replying, but what are those? sorry im a noob
  10. hello, im fairly new to php nad have been stuck with this problem for a few days now, im getting a "mysql_query(): supplied argument is not a valid MySQL-Link resource" error at line 39 and have no idea what's up with it, any help would be much appreciated! HERE'S MY ERROR INSERT INTO Orders VALUES id = 3 , date = '1303995318', creditcard = '54645656', expirydate= '12/12/2012' PHP Error Message Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/a2944313/public_html/processOrder.php on line 39 Free Web Hosting Error with Creating order Query in process order HERE'S MY CODE: <?php session_start(); include_once 'functions.php'; //This includes some common functions include_once 'connection.php'; // Check if we have established an authenticated if (!isset($_SESSION["authenticatedUser"])) { $_SESSION["Login_Error"] = "Please Login before you process your order"; header("Location: login.php"); } //Otherwise we know all the details. $errorString = ""; //Get the details from the payment page - validation required $total=$_POST["total"]; $creditcard = trim($_POST["creditcard"]); if (empty($creditcard)) $errorString .="The credit card field cannot be blank."; else if (strlen($creditcard) < 6) $errorString .="<br />Credit card field must be at least 6 characters."; $expiry = trim($_POST["expiry"]); if (empty($expiry)) $errorString .="<br />The expiry date cannot be blank."; //Create a timestamp for the order $date = time(); //Check to see if temporary basket is OK if (!empty($errorString)) { header("Location: payment.php?error=$errorString&total=$total"); } else // Else Update the cust_id for the items { //Update the temporary order to a permanent order by associating a customer id $createOrder = "INSERT INTO Orders VALUES ". "id = ".$_SESSION["id"]." , date = '$date', ". " creditcard = '$creditcard', expirydate= '$expiry' " ; print $createOrder; if (!($result = mysql_query ($createOrder, $connection))) die("Error with Creating order Query in process order"); else $OrderId = mysql_insert_id(); //Now add the basket items to the orders foreach ($_SESSION["basket"] as $basketItemArray) { //Calls the getPrice function in functions.php $itemPrice = getPrice($connection, $basketItemArray["ItemId"]); //Create the query to insert the item $addItem = "INSERT INTO Order_items VALUES (".$OrderId.",".$basketItemArray["ItemId"].",".$basketItemArray["quantity"].",".$itemPrice.")"; if (!($result = mysql_query ($addItem, $connection))) die("Error creating item in addItem Query in process order"); } //Relocate to Receipt header("Location: orderReceipt.php?OrderId=$OrderId"); } //end else 'No errors' ?>
×
×
  • 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.