473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

mysql_fetch_array

<?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
3 2835
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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: james | last post by:
I am new to PHP and am trying to run a simple query and display the result, with no luck. Here is the code I am using. <?php //start session session_start(); //store cmpid from querystring...
4
by: Theo | last post by:
hi all this is probably another simple one, but the web doesnt seem to have an answer that I can find. Veeeery simple code. each row has 10 columns. require('db.php'); $query = "SELECT *...
15
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
2
by: Dave Moore | last post by:
Hi All, I've got a simple query hopefully somebody can clear up for me. I need to make a query on a database to select a set of table rows, using something like: $result = mysql_query($query);...
4
by: Marcel Brekelmans | last post by:
Hello, I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example: I have a simple table 'tblName': ID Name 1 Jane 2 Joe 2 Doe
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
3
by: monomaniac21 | last post by:
hi all im querying a db for two rows which are always returned. how can i reference each row and output its contents without using a while loop. ive tried: $row = mysql_fetch_array($result);...
2
by: Karl Groves | last post by:
I'm trying to run mysql_fetch_array with a variable in place of the optional result type constant, like so mysql_fetch_array($result, $rtype) where, obviously, $rtype is one of the three valid...
3
by: Patrick | last post by:
Hi I am trying to write a simple database class to encapsulate all the database functions in one. Howerver I am having problems with while($row = mysql_fetch_array($IsResult,MYSQL_NUM)) line it...
2
by: William Gill | last post by:
given the query: SELECT * FROM customers left join addresses on customer.cusid=addresses.cusid The mysql monitor returns all fields from both tables, including repeating the field matching...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.