Jump to content

[SOLVED] Driving me crazy --


elentz

Recommended Posts

I must not be seeing the forest for the trees!  I have a query that works fine in phpmyadmin.  I use phpmyadmin to create the php code.  When I run the query all I get is an output of the query.  I know this is incredibly simple but I just can't see the error.  Thanks for looking at this.

<?//**********************Database Connection*************

      $conn = mysql_connect("localhost", "admin", "9axmy425");
      mysql_select_db ('vtigercrm50',$conn);

//******************************************************





$sql = 'SELECT SUM((vtiger_inventoryproductrel.quantity) * (vtiger_inventoryproductrel.listprice))'
        . ' from vtiger_inventoryproductrel'
        . ' where vtiger_inventoryproductrel.id = \'17193\'';
$result = mysql_query($sql,$conn);
Echo "$sql";
?>

Link to comment
https://forums.phpfreaks.com/topic/76860-solved-driving-me-crazy/
Share on other sites

You didn't fetch a result set and mysql returns the row as an numerically indexed array, so call the element by the index

<?php
//**********************Database Connection*************

      $conn = mysql_connect("localhost", "admin", "9axmy425");
      mysql_select_db ('vtigercrm50',$conn);

//******************************************************

$sql = 'SELECT SUM((vtiger_inventoryproductrel.quantity) * (vtiger_inventoryproductrel.listprice))'
        . ' from vtiger_inventoryproductrel'
        . ' where vtiger_inventoryproductrel.id = \'17193\'';
$result = mysql_query($sql,$conn);
$row = mysql_fetch_row($result);
echo $row[0];
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.