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
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];
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.