Calling a variable in a mysql_query SELECT statement
Posted: Thu Aug 14, 2008 7:19 am
Hi
I have the following:
<?php
$code_link=mysql_connect('localhost', 'username', 'password');
if (!$code_link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('database', $code_link);
$zv_orders_id = (isset($_SESSION['order_number_created']) && $_SESSION['order_number_created'] >= 1) ? $_SESSION['order_number_created'] : $orders_id;
$code_ordered = mysql_query("SELECT products_id FROM orders_products WHERE orders_products_id = ' " .$zv_orders_id. " ' ");
echo $code_ordered;
if ($code_ordered == "192")
{
$code_quantity = mysql_query("SELECT products_quantity FROM orders_products WHERE orders_products_id = ' " .$zv_orders_id. " ' ");
echo $code_quantity;
}
else
echo "None orderd";
?>
The problems are in the lines in red.
Where am I wrong?
Thanks
G
I have the following:
<?php
$code_link=mysql_connect('localhost', 'username', 'password');
if (!$code_link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('database', $code_link);
$zv_orders_id = (isset($_SESSION['order_number_created']) && $_SESSION['order_number_created'] >= 1) ? $_SESSION['order_number_created'] : $orders_id;
$code_ordered = mysql_query("SELECT products_id FROM orders_products WHERE orders_products_id = ' " .$zv_orders_id. " ' ");
echo $code_ordered;
if ($code_ordered == "192")
{
$code_quantity = mysql_query("SELECT products_quantity FROM orders_products WHERE orders_products_id = ' " .$zv_orders_id. " ' ");
echo $code_quantity;
}
else
echo "None orderd";
?>
The problems are in the lines in red.
Where am I wrong?
Thanks
G