Why $row is EMPTY
am 29.04.2008 20:27:57 von Nasreen Laghari
--0-1985342345-1209493677=:88426
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,=0AWhy my program is not going in while loop? When I run the same query =
in SQL cmd, it brings result but=A0here when I print $result gives Resouce =
ID number means $result has data then why $row is empty.=0A$query =3D 'SELE=
CT * FROM `gig` LEFT JOIN genre ON gig.genreId=3Dgenre.genreId LEFT JOIN ve=
nue ON gig.venueID =3D venue.vid where gig.gigid =3D '.$gigDetail.' ORDER B=
Y gig.gigid';
$result =3D mysql_query($query) or die(mysql_error=
());=0Awhile ($row =3D mysql_fetch_array($result))
=A0{
=
echo "Program is in While loop";
=A0$g_name =3D $ro=
w["gig.gigName"];
=A0 $vname =3D $row["venue.venueName"];=
$genre =3D $row["genre.name"];
echo("G=
ig Name:=A0".$g_name);=0A}
Regards=0ANasreen
=0 A _____=
____________________________________________________________ _______________=
____=0ABe a better friend, newshound, and =0Aknow-it-all with Yahoo! Mobile=
.. Try it now. http://mobile.yahoo.com/;_ylt=3DAhu06i62sR8HDtDypao8Wcj9tAc=
J
--0-1985342345-1209493677=:88426--
Re: Why $row is EMPTY
am 29.04.2008 20:46:56 von jonllmsed
------=_Part_5538_22229125.1209494816374
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
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
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
>
------=_Part_5538_22229125.1209494816374--
Re: Why $row is EMPTY
am 29.04.2008 20:52:27 von 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. 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
> 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: Why $row is EMPTY
am 30.04.2008 02:01:52 von dmagick
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