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

php/mysql echoing same thing twice--help!

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.