Re: Problem with query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 23, 2013 at 8:31 PM, Ethan Rosenberg, PhD <
erosenberg@xxxxxxxxxxxxxxxxxxxx> wrote:

> Dear List -
>
> There is an error in my query, and I cannot find it.
>
> This fails:
>
> $_SESSION['Cust_Num'] = $_REQUEST['cnum'];
> $_SESSION['CustNum'] = $_REQUEST['cnum'];
>
> echo "session<br />"; //this has the proper values
> print_r($_SESSION);
>
> $sql10 = "select Balance, Payments, Charges, Date from Charges where
> Cust_Num = $_SESSION[Cust_Num] order by Date";
> echo $sql10; //echos the correct query
> $result10 = mysqli_query($cxn, $sql10);
> var_dump($result1); // this returns NULL
> echo "<center><strong>Current Results</strong></center>";
> echo "<center>";
> echo "<table border='4' cellpadding='5' cellspacing='55' rules='all'
> frame='box'>";
> echo "<tr class='heading'>";
> echo "<th>Balance</th>";
> echo "<th>Payments</th>";
> echo "<th>Charges</th>";
> echo "<th>Date</th>";
> echo "</tr>";
> echo "row1<br />";
>

$row10 is undefined here, so:
$row10 = mysqli_fetch_row($result10); ?

I would suggest using
while (($row1 = mysqli_fetch_row($result1))!= 0 ) { ... }

instead of
do { ... } while (($row1 = mysqli_fetch_row($result1))!= 0 );

This avoids the need of the extra mysqli_fetch_row before the do-while loop.

- Matijn

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux