Sir I have these codes

global $mybalance;

$result2 = sqlsrv_query($con,$query) or die ("Error". sqlsrv_errors($con)) ;  

while($res2 = sqlsrv_fetch_array($result2)) {
echo "<tr>";
echo'Opening Balance='.number_format($mybalance).'<br>';



echo'Opening Balance='.number_format($mybalance);

The codes
PHP Code:
echo'Opening Balance='.number_format($mybalance);
work fine at line 11 but does not work at line 24


Please help

Recommended Answers

All 2 Replies

Member Avatar

This is setting the var to 0 not checking it. If you want to check the value use ==

As diafol stated, a single equals sign is an assignment and a double equals is a comparison. You are resetting the value to zero inside the If statement and THEN checking to make sure it doesn't equal false.

For example, your while statement has an assignment operator in which you are setting a value and then looping as long as it doesn't resolve to false.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.