This is a discussion on mysql_fetch_array within the PHP Language forums, part of the PHP Programming Forums category; <?php echo "HI " . $name; $result = mysql_query("SELECT * FROM album WHERE username='{$name}'"); while ($next_row = mysql_fetch_array($...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
<?php
echo "HI " . $name; $result = mysql_query("SELECT * FROM album WHERE username='{$name}'"); while ($next_row = mysql_fetch_array($result)) { $album_name = $next_row['name']; echo "<a href=\"main.php?album=$album_name\"><font size=\"+1\" color=\"#FFFFFF\"> $album_name </font></a><br/>"; } ?> This gives me a Warning that mysql_fetch_array isn't getting a valid MySQL resource, but it has the right value in $name and doesn't have an obvious problem, any debugging insight? Thanks, RG |
|
|||
|
Robert <gtg463g@mail.gatech.edu> wrote:
> $result = mysql_query("SELECT * FROM album WHERE username='{$name}'"); > while ($next_row = mysql_fetch_array($result)) { [snip] > } > ?> Is this the entire script you are using? > This gives me a Warning that mysql_fetch_array isn't getting a valid MySQL > resource, but it has the right value in $name and doesn't have an obvious > problem, any debugging insight? YOu'r not checking if the query returns a valid response. Implement some flow control: eg replace the $result line with: $result=..........'{$name}'") or die(mysql_error()); And that might give you a usefull hint (like the fact that you forgot to open a connection to a database). -- Daniel Tryba |
|
|||
|
Robert wrote:
> This gives me a Warning that mysql_fetch_array isn't getting a valid MySQL > resource, but it has the right value in $name and doesn't have an obvious > problem, any debugging insight? use error-checking. $sql = "select ..."; mysql_query($sql) or die(mysql_error() . " in [$sql]"); I couldn't recreate the error you got. -- I have a spam filter working. To mail me include "urkxvq" (with or without the quotes) in the subject line, or your mail will be ruthlessly discarded. |
|
|||
|
"Daniel Tryba" <news_comp.lang.php@canopus.nl> wrote in message news:bnkhu3$lcc$1@news.tue.nl... > Robert <gtg463g@mail.gatech.edu> wrote: > > $result = mysql_query("SELECT * FROM album WHERE username='{$name}'"); > > while ($next_row = mysql_fetch_array($result)) { > [snip] > > } > > ?> > > Is this the entire script you are using? > > > This gives me a Warning that mysql_fetch_array isn't getting a valid MySQL > > resource, but it has the right value in $name and doesn't have an obvious > > problem, any debugging insight? > > YOu'r not checking if the query returns a valid response. Implement some > flow control: eg replace the $result line with: > > $result=..........'{$name}'") or die(mysql_error()); > > And that might give you a usefull hint (like the fact that you forgot to > open a connection to a database). > > -- > > Daniel Tryba > I was connecting, it was a selection problem. Thanks guys. |