473,722 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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','dbo ard_mbr','pa1ss 2wo3rd');

mysql_select_db ('kp_dboard',$c on_id);

echo join(mysql_fetc h_array($theque ry=mysql_query( 'select * from
threads',$con_i d)),' --- ') . '<br>';

echo join(mysql_fetc h_array($theque ry),' --- ') . '<br>';

echo join(mysql_fetc h_array($theque ry),' --- ');
?>
-----------------------------------------------------------------------

Help would be appreciated--thanks.

Keith
Jul 17 '05 #1
2 2102
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','dbo ard_mbr','pa1ss 2wo3rd');

mysql_select_db ('kp_dboard',$c on_id);

echo join(mysql_fetc h_array($theque ry=mysql_query( 'select * from
threads',$con_i d)),' --- ') . '<br>';

echo join(mysql_fetc h_array($theque ry),' --- ') . '<br>';

echo join(mysql_fetc h_array($theque ry),' --- ');
?>
-----------------------------------------------------------------------

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','dbo ard_mbr','pa1ss 2wo3rd');

mysql_select_db ('kp_dboard',$c on_id);

echo join(mysql_fetc h_array($theque ry=mysql_query( 'select * from
threads',$con_i d)),' --- ') . '<br>';

echo join(mysql_fetc h_array($theque ry),' --- ') . '<br>';

echo join(mysql_fetc h_array($theque ry),' --- ');
?>
-----------------------------------------------------------------------

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
3673
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 resource even though if I echo the query to the browser and cut and paste it into the command line I get valid results.
6
1671
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 database a "pointer" that says something like $MyString, but in the PHP $MyString is given a URL of an image. So every time during the while() command it comes across the text $MyString it instead substitutes it for the URL instead of echoing...
1
3120
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 file to populate a table. I have a table named groups with two fields: groups_id auto-increment primary groups_name
1
2020
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 takes that \n as literal. Meaning, when I retrieve the records, they show up like "hello \n world".
19
2146
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 the info inserted into the table even though I'm not getting any connection errors, etc. Since my method is identical, I'm wondering if there's some 'rule' I am unaware of. TIA
5
9069
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) or die(mysql_error()); } is throwing this error: Couldn't run query: You have an error in your SQL syntax near 'index =
6
3279
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 PHP/MySQL connectivity on a Windows XP machine requires three configuration edits. These are: 1. In php.ini, enable php_mysql.dll by uncommenting "extension=php_mysql.dll". 2. In php.ini, set "extension_dir" to the folder containing
3
13956
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: The problem here is PHP not MySQL, in MySQL everything works just fine. Here is the query that I wrote for getting the number of how much
10
1817
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'); Although I'm sure the connection to the database is ok, I sometimes get an error of this kind: *Warning*: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in ... This does not happen every time i run the script, only...
0
8863
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9238
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2602
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.