[Solved]No value is being retunred but there is

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shab620
Forum Commoner
Posts: 48
Joined: Tue Jan 18, 2005 7:50 pm

[Solved]No value is being retunred but there is

Post 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
Last edited by shab620 on Sat Mar 26, 2005 2:11 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_fetch_row() returns an array of numeric indexed values. Switch to mysql_fetch_assoc()
shab620
Forum Commoner
Posts: 48
Joined: Tue Jan 18, 2005 7:50 pm

Post by shab620 »

hye thats working now, thanks for that Feyd, much appreciated

Shab

:D :D
Post Reply