Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

PHP5 - Infinit loop by WHILE

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

PHP5 - Infinit loop by WHILE

Postby sina14 » Tue Jul 23, 2013 1:19 am

Friends, :D

I'm using PHP 5.4.10 and when I'm trying to read data from a MS SQL database server, I get the first record repeated unlimited!

my codes is:

Code: Select all
$res_Total = mssql_fetch_array(mssql_query($query_Total));
while ($res_Total){
print $Total = $res_Total[0]." - ";



Help me please!
sina14
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Jul 23, 2013 1:17 am

Re: PHP5 - Infinit loop by WHILE

Postby macek » Wed Jul 31, 2013 10:53 pm

Code: Select all

$res_Total = mssql_query($query_Total));
while ($Total = mssql_fetch_array($res_Total)) {
  print_r( $Total );
 echo '<hr />';


User avatar
macek
php-forum Active User
php-forum Active User
 
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am

Re: PHP5 - Infinit loop by WHILE

Postby johnj » Fri Aug 02, 2013 2:15 am

Code: Select all
$i = 0;
$res_Total = mssql_fetch_array(mssql_query($query_Total));
while (count($res_Total) > 0 && $i < count($res_Total))
{
print $Total = $res_Total[0]." - ";
$i = $i + 1;

johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.