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

query error

P: n/a
Wm
I have a query that I expect to return 3 or 4 entries -- but I seem to be
getting only the most recent entry, repeated 4 times. What am I doing wrong
here?

$query="SELECT artistID,email,city,state,country from artists WHERE
email='$email'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
if (mysql_num_rows($result) > 0){
$alreadylisted = "1";
echo "<CENTER>$email is already in our database. Are you listed
below?</CENTER><BR>";
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$email = $row['email'];
$city = $row['city'];
$state = $row['state'];
$country = $row['country'];
echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
sans-serif\">
<A HREF=\"javascript:;\"
onClick=\"openProfile('artist.php?artistID=".$arti stID.

"','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
".$lastname."</A><BR>"
.$city.", ".$state." ".$country."</FONT><BR></CENTER>";
}
echo "<HR><CENTER>If you are already listed above,
congratulations!<BR>
If needed, you may edit your listing using the link at
left.</CENTER>";
mysql_free_result($result);
}
Thanx,
Wm

Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
try echoing your query to screen so you can read exactly what is being sent
to the database beforehand.

--

Warren Butt
-- Custom web design, cheap like cheese
"Wm" <LA*******@hotmail.com> wrote in message
news:1h*********************@news.easynews.com...
I have a query that I expect to return 3 or 4 entries -- but I seem to be
getting only the most recent entry, repeated 4 times. What am I doing wrong here?

$query="SELECT artistID,email,city,state,country from artists WHERE
email='$email'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
if (mysql_num_rows($result) > 0){
$alreadylisted = "1";
echo "<CENTER>$email is already in our database. Are you listed
below?</CENTER><BR>";
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$email = $row['email'];
$city = $row['city'];
$state = $row['state'];
$country = $row['country'];
echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
sans-serif\">
<A HREF=\"javascript:;\"
onClick=\"openProfile('artist.php?artistID=".$arti stID.

"','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
".$lastname."</A><BR>"
.$city.", ".$state." ".$country."</FONT><BR></CENTER>";
}
echo "<HR><CENTER>If you are already listed above,
congratulations!<BR>
If needed, you may edit your listing using the link at
left.</CENTER>";
mysql_free_result($result);
}
Thanx,
Wm

Jul 16 '05 #2

P: n/a
Wm
"DjDrakk" <Dj*****@drakkradio.servemp3.com> wrote in message
news:vj************@corp.supernews.com...
try echoing your query to screen so you can read exactly what is being sent to the database beforehand.

Warren Butt
-- Custom web design, cheap like cheese

echo "Query result = ".$result;

yields this output:

ArrayQuery result = Resource id #21

I'm not sure where the word "Array" is coming from, nor what the "Resource
id #21" is.....????

Wm

"Wm" <LA*******@hotmail.com> wrote in message
news:1h*********************@news.easynews.com...
I have a query that I expect to return 3 or 4 entries -- but I seem to be getting only the most recent entry, repeated 4 times. What am I doing

wrong
here?

$query="SELECT artistID,email,city,state,country from artists WHERE
email='$email'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
if (mysql_num_rows($result) > 0){
$alreadylisted = "1";
echo "<CENTER>$email is already in our database. Are you listed
below?</CENTER><BR>";
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$email = $row['email'];
$city = $row['city'];
$state = $row['state'];
$country = $row['country'];
echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
sans-serif\">
<A HREF=\"javascript:;\"
onClick=\"openProfile('artist.php?artistID=".$arti stID.

"','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
".$lastname."</A><BR>"
.$city.", ".$state." ".$country."</FONT><BR></CENTER>";
}
echo "<HR><CENTER>If you are already listed above,
congratulations!<BR>
If needed, you may edit your listing using the link at
left.</CENTER>";
mysql_free_result($result);
}
Thanx,
Wm


Jul 16 '05 #3

P: n/a
Wm
"Trent Stith" <tr****@airmail.net> wrote in message
news:bg********@library2.airnews.net...
You need to echo the query itself, not the result of the query.

echo "<pre>";
echo $query;

that will return what your query is actually doing it may shed some light.

I pasted the lines above in after the query and got this result output to
the browser:

"Array
ad*****@hotmail.com is already in our database. Are you listed below?"

I'm still not sure why I'm getting the word "Array" output, nor why I don't
see the query that I'm trying to verify. And I'm still getting the same info
output 4 times rather than 4 separate listings, but I'm sure that's a
different problem... <groan>

Thanx,
Wm
************************************************** ********
ORIGINAL MESSAGE(S):
************************************************** ******** "Wm" <LA*******@hotmail.com> wrote in message
news:oL***********************@news.easynews.com.. .
"DjDrakk" <Dj*****@drakkradio.servemp3.com> wrote in message
news:vj************@corp.supernews.com...
try echoing your query to screen so you can read exactly what is being

sent
to the database beforehand.

Warren Butt
-- Custom web design, cheap like cheese


echo "Query result = ".$result;

yields this output:

ArrayQuery result = Resource id #21

I'm not sure where the word "Array" is coming from, nor what the "Resource id #21" is.....????

Wm

"Wm" <LA*******@hotmail.com> wrote in message
news:1h*********************@news.easynews.com...
> I have a query that I expect to return 3 or 4 entries -- but I seem to
be
> getting only the most recent entry, repeated 4 times. What am I

doing wrong
> here?
>
> $query="SELECT artistID,email,city,state,country from artists WHERE > email='$email'";
> $result=mysql_query($query) or die(mysql_error("Could not execute
> query."));
> if (mysql_num_rows($result) > 0){
> $alreadylisted = "1";
> echo "<CENTER>$email is already in our database. Are you listed > below?</CENTER><BR>";
> while($row = mysql_fetch_array($result)) {
> $artistID = $row['artistID'];
> $email = $row['email'];
> $city = $row['city'];
> $state = $row['state'];
> $country = $row['country'];
> echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica, > sans-serif\">
> <A HREF=\"javascript:;\"
> onClick=\"openProfile('artist.php?artistID=".$arti stID.
>
> "','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
> ".$lastname."</A><BR>"
> .$city.", ".$state." ".$country."</FONT><BR></CENTER>";
> }
> echo "<HR><CENTER>If you are already listed above,
> congratulations!<BR>
> If needed, you may edit your listing using the link at
> left.</CENTER>";
> mysql_free_result($result);
> }
>
>
> Thanx,
> Wm
>
>
>



Jul 16 '05 #4

P: n/a
Ok insert the echo "$query" line in the following places where indicated
with 'echo', that's how you should isolate the problem to one line of code:
"Wm" <LA*******@hotmail.com> wrote in message
news:1h*********************@news.easynews.com...
I have a query that I expect to return 3 or 4 entries -- but I seem to be
getting only the most recent entry, repeated 4 times. What am I doing wrong here?

echo
$query="SELECT artistID,email,city,state,country from artists WHERE
email='$email'";
echo
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
echo
if (mysql_num_rows($result) > 0){
$alreadylisted = "1";
echo "<CENTER>$email is already in our database. Are you listed
below?</CENTER><BR>";
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$email = $row['email'];
$city = $row['city'];
$state = $row['state'];
$country = $row['country'];
echo "<CENTER><HR><FONT size=\"2\" face=\"Arial, Helvetica,
sans-serif\">
<A HREF=\"javascript:;\"
onClick=\"openProfile('artist.php?artistID=".$arti stID.

"','Artist','resizable=yes,width=600,height=300')\ ">".$firstname."
".$lastname."</A><BR>"
.$city.", ".$state." ".$country."</FONT><BR></CENTER>";
}
echo "<HR><CENTER>If you are already listed above,
congratulations!<BR>
If needed, you may edit your listing using the link at
left.</CENTER>";
mysql_free_result($result);
}
Thanx,
Wm

Jul 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.