473,231 Members | 1,791 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,231 software developers and data experts.

query error

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

Similar topics

8
by: Polar | last post by:
I am having troubles finding the parse error in this script. I've been checking for weeks. I am too new to the subject I guess. I am trying to show a readord and them have a form at the bottom...
10
by: johnnyboy10017 | last post by:
I am having a hell of a time with what I think is a very simple query: It won't actually insert a new record into the specified table, but returns no error, in fact it returns "1" (or true) that...
2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
3
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
2
by: Mattyboy | last post by:
Guys I have built a database with saved queries that runs fine in Access but when I call it from the web using ASP, an exception occurs. I have tried multiple ways of testing the databases with...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
4
by: deko | last post by:
When using OutputTo with a query, the 'File name' window in the 'Output To' dialog gets populated with the name of the query by default. This makes the exported file self-describing if the query...
11
by: Arpan | last post by:
I have always been working with SQL Server 2005 for ASP.NET apps but due to some reasons, had to revert back to MS-Access 2000. When I try to insert/update a MS-Access DB table (MDB), ASP.NET...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.