Jump to content

[SOLVED] how to display value of a mysql resource id


aconite

Recommended Posts

$bal_dest=mysql_query("select balance FROM account where account2='$theDest'");

 

$credit=($bal_dest+$theAmmount);

 

echo"destination  :";

echo'$bal_dest';

 

mysql_query("update account set balance= $credit where account2=  $theDest");

 

 

 

the output i get is

destination :Resource id #6

 

now i want to add $theAmmount(i.e.=20) to the integer/float value of $bal_dest.but i get

$credit=26 i.e. it adds 20 and 6

 

 

the balance filed in account table is float type and has the value 100 for this particular account.

There are 2 posts in the FAQ/Code Snippet Repository that deal with retrieving info from MYSQL.

 

Post1 Post2

 

In your example you could do something similar to

 

<?php
$result = mysql_query("select balance FROM account where account2='$theDest'");
$row = mysql_fetch_assoc($result);
$bal_dest = $row['balance'];
$credit=($bal_dest+$theAmmount);

echo "bal dest: $bal_dest <br />\ncredit: $credit";
?>

 

You should be shown some examples of how to display query errors in one of the Faq Posts. If you have additional PHP problems similar to this one they should be directed to the PHP-Help forum.

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.