You're not executing the query, or selecting a db. But that's just the tip of the iceberg. If you have more than one "orderid" and more than one "shipping" your queries will return all of them. I'm not sure if this is what you want, but if it is, you really should be using something like mysql_fetch_array() instead of mysql_result(). If you're looking for just one result, you should change your SQL to somethere like this....

SELECT `orderid` FROM `databasename.receipts`
WHERE `some_unique_key` = 'some_unique_identifier'

function get_order_id_receipt($orderid, $shipping)
{
//Get order ID from DB to pass to receipt.
$conn = db_connect();
$query = "select orderid from receipts";
$shippingquery = "select shipping from receipts";

mysql_select_db ( YOUR_DATABASE_NAME );
$orderid_result = mysql_query ( $query );
$orderid = mysql_result($orderid_result);

$shipping = mysql_result($shippingquery);
//return $orderid;
}

Steve Jackson wrote:
Can anyone see why I am having problems with this page.
I'm trying to connect to the DB and display results using the function
get_order_id_receipt.
The DB connection works because I can produce the cart based on the
users session so I don't get why this doesn't work....
<?
include ('products_fns.php');
include ('order_fns.php');
include ('db_fns.php');
include ('output_fns.php');
// The shopping cart needs sessions, so start one
session_start();
do_html_header("Please print out this page for your records.");
function get_order_id_receipt($orderid, $shipping)
{
//Get order ID from DB to pass to receipt.
$conn = db_connect();
$query = "select orderid from receipts";
$shippingquery = "select shipping from receipts";
$orderid = mysql_result($query);
$shipping = mysql_result($shippingquery);
//return $orderid;
}
//debug test
echo mysql_error();
echo "test & $orderid";
echo "test & $shipping";
display_receipt($orderid);
echo "<table width='760' cellpadding='0'
background='images/shopbg.gif'><tr><td>&nbsp;</td></tr></table>";
display_cart($cart, false, 0);
echo "<table width='760' cellpadding='0'
background='images/shopbg.gif'><tr><td>&nbsp;</td></tr></table>";
echo "<table width='760' cellpadding='0'
background='images/shopbg.gif'><tr><td>&nbsp;</td></tr></table>";
display_success_form();
//empty shopping cart
//session_destroy();
do_html_footer();
?>


Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com <http://www.violasystems.com/> [EMAIL PROTECTED]
Mobile +358 50 343 5159





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to