By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,471 Members | 722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,471 IT Pros & Developers. It's quick & easy.

mysql_fetch_array

P: n/a
<?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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Robert <gt*****@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

Jul 17 '05 #2

P: n/a
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.
Jul 17 '05 #3

P: n/a

"Daniel Tryba" <ne****************@canopus.nl> wrote in message
news:bn**********@news.tue.nl...
Robert <gt*****@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.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.