mysql_fetch_array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert

    mysql_fetch_array

    <?php
    echo "HI " . $name;
    $result = mysql_query("SE LECT * FROM album WHERE username='{$nam e}'");

    while ($next_row = mysql_fetch_arr ay($result)) {
    $album_name = $next_row['name'];

    echo "<a href=\"main.php ?album=$album_n ame\"><font size=\"+1\"
    color=\"#FFFFFF \">

    $album_name

    </font></a><br/>";
    }
    ?>

    This gives me a Warning that mysql_fetch_arr ay 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


  • Daniel Tryba

    #2
    Re: mysql_fetch_arr ay

    Robert <gtg463g@mail.g atech.edu> wrote:[color=blue]
    > $result = mysql_query("SE LECT * FROM album WHERE username='{$nam e}'");
    > while ($next_row = mysql_fetch_arr ay($result)) {[/color]
    [snip][color=blue]
    > }
    > ?>[/color]

    Is this the entire script you are using?
    [color=blue]
    > This gives me a Warning that mysql_fetch_arr ay 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?[/color]

    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

    Comment

    • Pedro

      #3
      Re: mysql_fetch_arr ay

      Robert wrote:[color=blue]
      > This gives me a Warning that mysql_fetch_arr ay 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?[/color]

      use error-checking.

      $sql = "select ...";
      mysql_query($sq l) 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.

      Comment

      • Robert

        #4
        Re: mysql_fetch_arr ay


        "Daniel Tryba" <news_comp.lang .php@canopus.nl > wrote in message
        news:bnkhu3$lcc $1@news.tue.nl. ..[color=blue]
        > Robert <gtg463g@mail.g atech.edu> wrote:[color=green]
        > > $result = mysql_query("SE LECT * FROM album WHERE username='{$nam e}'");
        > > while ($next_row = mysql_fetch_arr ay($result)) {[/color]
        > [snip][color=green]
        > > }
        > > ?>[/color]
        >
        > Is this the entire script you are using?
        >[color=green]
        > > This gives me a Warning that mysql_fetch_arr ay isn't getting a valid[/color][/color]
        MySQL[color=blue][color=green]
        > > resource, but it has the right value in $name and doesn't have an[/color][/color]
        obvious[color=blue][color=green]
        > > problem, any debugging insight?[/color]
        >
        > 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
        >[/color]

        I was connecting, it was a selection problem. Thanks guys.


        Comment

        Working...