MySQL Forums
Forum List  »  Newbie

INSERT query failure
Posted by: john.mcclean
Date: July 11, 2005 06:24AM

Hi, just started with MYSQL, have a problem that I can't figure out.

I've got a table of items from which the user adds a quantity to a 'basket' (the table Order). The fields stored are the item code and the quantity.

However, when I try to run the following, it returns "Could not execute query!" - this happens even when I replace '$code' and '$qty' with integers. It seems there is something wrong with the INSERT query.

(Note that when using phpMyadmin, I can put the integers in fine - it just will not work with the code below). Any help would be much appreciated.



<html>

<head>
<title></title>
</head>

<body>

<?php

$code = $_POST['code'];
$qty = $_POST['qty'];

echo "$code <br><br>";
echo "$qty <br><br>";

$user="jbmcc85_admin";
$host="localhost";
$password="******";
$database="jbmcc85_RiceBowl";
$connection = mysql_connect($host, $user, $password)
or die("Could not connect to server.");
$db = mysql_select_db($database,$connection)
or die("Could not select database.");

$query = "INSERT INTO 'Order' ('code', 'qty') VALUES ('$code', '$qty')";

$result = mysql_query($query)
or die("Could not execute query!");

?>


</body>

</html>

Options: ReplyQuote


Subject
Written By
Posted
INSERT query failure
July 11, 2005 06:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.