aconite Posted March 14, 2007 Share Posted March 14, 2007 im running a mysql query in php the result of the query is saved in $bal_account.in the next line i want to display the value (string) of this variable. i have tried echo $bal_account but this displays the resource id# wht shld i do??? Quote Link to comment https://forums.phpfreaks.com/topic/42633-solved-how-to-display-value-of-a-mysql-resource-id/ Share on other sites More sharing options...
Greaser9780 Posted March 14, 2007 Share Posted March 14, 2007 Could you please show some code on this? Quote Link to comment https://forums.phpfreaks.com/topic/42633-solved-how-to-display-value-of-a-mysql-resource-id/#findComment-206865 Share on other sites More sharing options...
aconite Posted March 14, 2007 Author Share Posted March 14, 2007 $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. Quote Link to comment https://forums.phpfreaks.com/topic/42633-solved-how-to-display-value-of-a-mysql-resource-id/#findComment-206875 Share on other sites More sharing options...
shoz Posted March 14, 2007 Share Posted March 14, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/42633-solved-how-to-display-value-of-a-mysql-resource-id/#findComment-206946 Share on other sites More sharing options...
aconite Posted March 14, 2007 Author Share Posted March 14, 2007 it worked.thanx a lot Quote Link to comment https://forums.phpfreaks.com/topic/42633-solved-how-to-display-value-of-a-mysql-resource-id/#findComment-207178 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.