Page 1 of 1

[Solved]No value is being retunred but there is

Posted: Sat Mar 26, 2005 12:25 pm
by shab620
Hye
I'm trying to insert two specific values into a new table from a query i'm perfroming on a different table. I'm attempting to extract two values but neither seem to be inserted. I've tried error reporting on the query and no errors occur

Can somebody give me a hand please, really stuck????
Ther code is as follows. The other values which have been retrieved by the $POST have been inserted correctly.

Code: Select all

<?php
$item_id=$_POST['orderitem3'];
$comments=$_POST['comments'];
$quantity=$_POST['quantity'];
$user_name=$_POST['username'];
$hostname="localhost"; 
$mysql_login="root"; 
$mysql_password="*********"; 
$database="coachhouse"; 
$connect = mysql_connect("$hostname", "$mysql_login" , "$mysql_password");
$table_name = 'item';
mysql_select_db($database);


$result = mysql_query ("SELECT Item_Description, Item_Price from item where item_id = '$item_id'",$connect) 
or die ("There was an error in the query");
while ($row = mysql_fetch_row($result))
{
$item_description=$row['Item_Description'];
$price=$row['Item_Price'];
}
$query = ("INSERT INTO emp_order VALUES ('','$item_description','$quantity','$comments','$user_name','$price','')");
PRINT '<br><font size ="4" colour="blue">';
IF (mysql_query($query))
PRINT "<center>Order Has Been Placed</Center></font><BR><BR>";
PRINT $item_description; 
mysql_close($connect);
?>
Hope somebody can help

Shab

8O 8O

Posted: Sat Mar 26, 2005 12:59 pm
by feyd
mysql_fetch_row() returns an array of numeric indexed values. Switch to mysql_fetch_assoc()

Posted: Sat Mar 26, 2005 2:11 pm
by shab620
hye thats working now, thanks for that Feyd, much appreciated

Shab

:D :D