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

php and MySQL error

Hello,

I am using php and MySQL and have following as part of the code

while ($row[] = mysql_fetch_array($result)) {
printf("<td valign='top'><strong>Venue</strong></td><td _
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);

etc etc

but with more than one hit it does not work, I just get a repeat of
the first set of data but not using the table formatting.

Ideas please?

Cheers

Geoff
Mar 6 '07 #1
7 1644
gcox freeuk.com wrote:
Hello,

I am using php and MySQL and have following as part of the code

while ($row[] = mysql_fetch_array($result)) {
printf("<td valign='top'><strong>Venue</strong></td><td _
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);

etc etc

but with more than one hit it does not work, I just get a repeat of
the first set of data but not using the table formatting.

Ideas please?

Cheers

Geoff
This:
while ($row[] = mysql_fetch_array($result)) {
should be
while($row = mysql_fetch_array($result)) {

This:
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);
Should be:
valign='top'>%s &nbsp;</td></tr>",$row["venue"]);
Hendri
Mar 6 '07 #2
On Tue, 06 Mar 2007 11:56:26 +1100, Hendri Kurniawan
<as****@email.comwrote:
>gcox freeuk.com wrote:
>Hello,

I am using php and MySQL and have following as part of the code

while ($row[] = mysql_fetch_array($result)) {
printf("<td valign='top'><strong>Venue</strong></td><td _
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);

etc etc

but with more than one hit it does not work, I just get a repeat of
the first set of data but not using the table formatting.

Ideas please?

Cheers

Geoff

This:
while ($row[] = mysql_fetch_array($result)) {
should be
while($row = mysql_fetch_array($result)) {

This:
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);
Should be:
valign='top'>%s &nbsp;</td></tr>",$row["venue"]);
Hendri,

Thanks for the above - that almost works! I do now get the 2 hits but
the second one does not have the <table format?!

Cheers

Geoff
>

Hendri
Mar 6 '07 #3
Rik
gcox<add the at symbol in <"here>freeuk.com"wrote:
Thanks for the above - that almost works! I do now get the 2 hits but
the second one does not have the <table format?!
Look at the generated HTML source, you forgot to create a new <tr>.

--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel
Mar 6 '07 #4
On Tue, 06 Mar 2007 08:15:10 +0100, Rik <lu************@hotmail.com>
wrote:
>gcox<add the at symbol in <"here>freeuk.com"wrote:
>Thanks for the above - that almost works! I do now get the 2 hits but
the second one does not have the <table format?!

Look at the generated HTML source, you forgot to create a new <tr>.
Rik,

Too true! I had put the create a table line outside the while loop.

Cheers

Geoff
Mar 6 '07 #5
On Tue, 06 Mar 2007 08:15:10 +0100, Rik <lu************@hotmail.com>
wrote:
>gcox<add the at symbol in <"here>freeuk.com"wrote:
>Thanks for the above - that almost works! I do now get the 2 hits but
the second one does not have the <table format?!

Look at the generated HTML source, you forgot to create a new <tr>.
Rik,

just as a matter of interest! I have the

while ($row[] = mysql_fetch_array($result)) {
printf("<td valign='top'><strong>Venue</strong></td><td _
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);

ie $row[] and
$row[0]["venue"]

typeof code on another web site and it seems to work OK. What is the
difference between thie above and using

$row and $row["venue"] ??

Cheers

Geoff

Mar 6 '07 #6
Rik
gcox<add the at symbol in <"here>freeuk.com"wrote:
just as a matter of interest! I have the

while ($row[] = mysql_fetch_array($result)) {
printf("<td valign='top'><strong>Venue</strong></td><td _
valign='top'>%s &nbsp;</td></tr>",$row[0]["venue"]);

ie $row[] and
$row[0]["venue"]

typeof code on another web site and it seems to work OK. What is the
difference between thie above and using

$row and $row["venue"] ??
$row[] = will add the result as an array to the array $row.

So if the result of mysql_fetch_array() is:
array('id' ='123','venue' ='the shed');

$row[] = mysql.... will result in $row being:

array(
0 =array('id' ='123','venue' ='the shed'));
(and running is again would result in $row being:
array(
0 =array('id' ='123','venue' ='the shed')
1 =array('id' ='456','venue' ='under the couch'));
$row = mysql.... will result in $row being:
array('id' ='123','venue' ='the shed'));

And overwrite $row with the following results on every loop.

The [] is often used when the result has to be looped several times, or
the entire resultset has to be passed as an array to another piece of code.

Using $row[0]["venue"] is only usefull if you're only interested in the
first result (in which case the while loop is unneccesary overhead).
--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel
Mar 6 '07 #7
On Tue, 06 Mar 2007 08:50:09 +0100, Rik <lu************@hotmail.com>
wrote:
>Using $row[0]["venue"] is only usefull if you're only interested in the
first result (in which case the while loop is unneccesary overhead).
Thanks Rik for this and the other info. The above explains why the
code worked OK on the other site as there was always just one result.

Cheers

Geoff
Mar 6 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Cathy Hui | last post by:
Do u know why do i get the following message when trying to build the MySql-Python (1.2.0) on my Solaris 8 system? (with mysql 4.0.21 and python 2.4). thanks! error mesg: ld: fatal:...
0
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary...
0
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
0
by: Dennis Francis B. Tutanes | last post by:
$B$*@$OC$K$J$C$F$*$j$^$9!#(B $B%D%?%M%9(B@TSTI$B$G$9!#(B SEND-PR: -*- send-pr -*- SEND-PR: Lines starting with `SEND-PR' will be removed automatically, as SEND-PR: will all comments (text...
4
by: Adam Smith | last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting site. They have done some default installations, presumably from the CVS ports package ??. Herein lies the problem, "I do not...
3
by: Pugi! | last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get the following problem when connecting to mysql through a browser (phpMyAdmin): : #2002 Can't connect to local MySQL...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
8
by: sundeep.kumara | last post by:
hi all, I am a newbie .....I have compiled the source code of mysql-4.1.9 on PPC-Linux Its not giving any errors during configure,make or make install. But,when i try to start the server...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.