[PHP-DB] Why $row is EMPTY

2008-04-29 Thread Nasreen Laghari
Hi,
Why my program is not going in while loop? When I run the same query in SQL 
cmd, it brings result but here when I print $result gives Resouce ID number 
means $result has data then why $row is empty.
$query = 'SELECT * FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId LEFT 
JOIN venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.' ORDER BY 
gig.gigid';
 
 $result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) 
  {
  echo Program is in While loop;
  $g_name = $row[gig.gigName]; 
      $vname = $row[venue.venueName];
      $genre = $row[genre.name];
      echo(Gig Name: .$g_name);
}   
Regards
Nasreen


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Re: [PHP-DB] Why $row is EMPTY

2008-04-29 Thread Jon L.
I could be wrong, but I don't think table aliases continue to exist in PHP;
only the column names.

  $g_name = $row[gigName];
  $vname = $row[venueName];
  $genre = $row[name];


You may also consider revising the query to only grab the columns you need,
using an alias for at least genre.name.

$query = 'SELECT gig.gigName AS gig, venue.venueName AS venue, genre.name AS
genre FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId LEFT JOIN
venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.' ORDER BY
gig.gigid';

$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
  echo Program is in While loop;
  $g_name = $row[gig];
  $vname = $row[venue];
  $genre = $row[genre];
  echo(Gig Name: .$g_name);
}


- Jon L.


On Tue, Apr 29, 2008 at 1:27 PM, Nasreen Laghari [EMAIL PROTECTED]
wrote:

 Hi,
 Why my program is not going in while loop? When I run the same query in
 SQL cmd, it brings result but here when I print $result gives Resouce ID
 number means $result has data then why $row is empty.
 $query = 'SELECT * FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId
 LEFT JOIN venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.'
 ORDER BY gig.gigid';

  $result = mysql_query($query) or die(mysql_error());
 while ($row = mysql_fetch_array($result))
   {
   echo Program is in While loop;
   $g_name = $row[gig.gigName];
   $vname = $row[venue.venueName];
   $genre = $row[genre.name];
   echo(Gig Name: .$g_name);
 }
 Regards
 Nasreen



  
 
 Be a better friend, newshound, and
 know-it-all with Yahoo! Mobile.  Try it now.
 http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ



Re: [PHP-DB] Why $row is EMPTY

2008-04-29 Thread Ken Keefe
Try doing print_r($row); in your while loop and see what exactly is in
that array.

Ken

On Tue, Apr 29, 2008 at 1:46 PM, Jon L. [EMAIL PROTECTED] wrote:
 I could be wrong, but I don't think table aliases continue to exist in PHP;
  only the column names.

   $g_name = $row[gigName];
   $vname = $row[venueName];
   $genre = $row[name];


  You may also consider revising the query to only grab the columns you need,
  using an alias for at least genre.name.

  $query = 'SELECT gig.gigName AS gig, venue.venueName AS venue, genre.name AS
  genre FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId LEFT JOIN

 venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.' ORDER BY
  gig.gigid';

  $result = mysql_query($query) or die(mysql_error());
  while ($row = mysql_fetch_array($result))
  {
   echo Program is in While loop;
   $g_name = $row[gig];
   $vname = $row[venue];
   $genre = $row[genre];

   echo(Gig Name: .$g_name);
  }


  - Jon L.


  On Tue, Apr 29, 2008 at 1:27 PM, Nasreen Laghari [EMAIL PROTECTED]
  wrote:



   Hi,
   Why my program is not going in while loop? When I run the same query in
   SQL cmd, it brings result but here when I print $result gives Resouce ID
   number means $result has data then why $row is empty.
   $query = 'SELECT * FROM `gig` LEFT JOIN genre ON gig.genreId=genre.genreId
   LEFT JOIN venue ON gig.venueID = venue.vid where gig.gigid = '.$gigDetail.'
   ORDER BY gig.gigid';
  
$result = mysql_query($query) or die(mysql_error());
   while ($row = mysql_fetch_array($result))
 {
 echo Program is in While loop;
 $g_name = $row[gig.gigName];
 $vname = $row[venue.venueName];
 $genre = $row[genre.name];
 echo(Gig Name: .$g_name);
   }
   Regards
   Nasreen
  
  
  

 
   Be a better friend, newshound, and
   know-it-all with Yahoo! Mobile.  Try it now.
   http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
  


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Why $row is EMPTY

2008-04-29 Thread Chris

Nasreen Laghari wrote:

Hi,
Why my program is not going in while loop? When I run the same query in SQL 
cmd, it brings result but here when I print $result gives Resouce ID number 
means $result has data then why $row is empty.


No, it means the query worked. If it wasn't a resource it would be false 
(eg an sql error).


See how many rows are returned:

echo mysql_num_rows($result);

What does that query return when you run it outside of php?

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php