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

php/mysql echoing same thing twice--help!

I'm just learning php and set up a sample mysql db to practice with. I
have the following script and cannot for the life of me figure out why
it is printing each field of the row twice? I checked my db and it only
contains the entries once. What is causing this?!

-----------------------------------------------------------------------
<?php
$con_id = mysql_connect('localhost','dboard_mbr','pa1ss2wo3r d');

mysql_select_db('kp_dboard',$con_id);

echo join(mysql_fetch_array($thequery=mysql_query('sele ct * from
threads',$con_id)),' --- ') . '<br>';

echo join(mysql_fetch_array($thequery),' --- ') . '<br>';

echo join(mysql_fetch_array($thequery),' --- ');
?>
-----------------------------------------------------------------------

Help would be appreciated--thanks.

Keith
Jul 17 '05 #1
2 2075
TheKeith wrote:
I'm just learning php and set up a sample mysql db to practice with. I
have the following script and cannot for the life of me figure out why
it is printing each field of the row twice? I checked my db and it only
contains the entries once. What is causing this?!

-----------------------------------------------------------------------
<?php
$con_id = mysql_connect('localhost','dboard_mbr','pa1ss2wo3r d');

mysql_select_db('kp_dboard',$con_id);

echo join(mysql_fetch_array($thequery=mysql_query('sele ct * from
threads',$con_id)),' --- ') . '<br>';

echo join(mysql_fetch_array($thequery),' --- ') . '<br>';

echo join(mysql_fetch_array($thequery),' --- ');
?>
-----------------------------------------------------------------------

Help would be appreciated--thanks.

Keith

oh by the way I only entered the echo statement 3 times because there
are 3 records in the db. I should have taken out two of them for the
example.
Jul 17 '05 #2
TheKeith wrote:
I'm just learning php and set up a sample mysql db to practice with. I
have the following script and cannot for the life of me figure out why
it is printing each field of the row twice? I checked my db and it only
contains the entries once. What is causing this?!

-----------------------------------------------------------------------
<?php
$con_id = mysql_connect('localhost','dboard_mbr','pa1ss2wo3r d');

mysql_select_db('kp_dboard',$con_id);

echo join(mysql_fetch_array($thequery=mysql_query('sele ct * from
threads',$con_id)),' --- ') . '<br>';

echo join(mysql_fetch_array($thequery),' --- ') . '<br>';

echo join(mysql_fetch_array($thequery),' --- ');
?>
-----------------------------------------------------------------------

Help would be appreciated--thanks.

Keith

nevermind--I got it. You're supposed to indicate whether you want an
array with numeric indeces or associative indices, otherwise it returns
both--doubling all fields.
Jul 17 '05 #3

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

Similar topics

6
by: jerrygarciuh | last post by:
Hi all, I am iterating through a result set to generate a second set of queries but no matter what I do I get the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...
6
by: Dariusz | last post by:
I have a database where I use the while() command to iterate through each row and their resultant arrays to populate a table as the while() command is executed. I would like to have in the...
1
by: Ward B | last post by:
Greetings. I'm somewhat new to this whole MySQL/PHP thing and need a little help. My web hosting service uses phpMyAdmin and at the bottom of the screen iis an area where I can upload a text...
1
by: el chupacabra | last post by:
I'm using mysqldb module and python 2.4. I'm a newbie. Thanks in advance. 1. Output desired: "hello" "world" I know that MySQL takes \n and \t and what not. But my python script, it...
19
by: cover | last post by:
Is there a restriction to the number of fields you can work with in a PHP to MySQL connection? I'd used as many as 15 quite a few times and now I have a form with 34 fields and can't seem to get...
5
by: php coder | last post by:
Sorry, this is simple... but i'm going cross-eyed trying to find the error: This code: $delete_query = "DELETE FROM $tablename WHERE index = '$index'"; if($delete){ mysql_query($delete_query) ...
6
by: TonyB | last post by:
I'm running the zip'd version of PHP (PHP 5.1.2 zip package) downloaded from here: http://www.php.net/downloads.php. PHP won't connect with MySQL. >From docs and threads, it seems enabling...
3
by: auron | last post by:
Hi there, I have a really stupid and banal problem with showing the results of a MySQL query in PHP, preciselly with MySQL count() function that gives to a variable in PHP the result. NOTE:...
10
by: Caffeneide | last post by:
I'm using a php script which performs three xml queries to other three servers to retrieve a set of ids and after I do a query to mysql of the kind SELECT * FROM table WHERE id IN ('set of ids');...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.