View Single Post
  #1 (permalink)  
Old 2006-05-15, 11:33 AM
freshrod freshrod is offline
Junior Member
 
Join Date: Feb 2006
Posts: 4
freshrod
Default Query is double posting results?

I thought I had some problem with my PHP code at first, but then I took my code down to the bare essentials and I'm still getting this weird result.
When I run this simple query it prints out each field from the table twice and then moves on to the next field.
(i.e. userId, userId, userName, userName, userInfo, userInfo, etc, etc...)

Here's the code:

<?php

if (!($connection = mysql_connect("localhost", "root", "may1968")))
die ("Cannot Connect to DB!");

if (!(mysql_select_db("mhs", $connection)))
showerror();

function showerror() {
die ("Error " . mysql_errno() . " : " . mysql_error());

$result = mysql_query ("SELECT * FROM users WHERE userId = 1");

while ($row = mysql_fetch_array ($result))
{
foreach ($row as $stuff)
print "{$stuff} ";
print "\n";
}

?>

I've checked and double checked the DB with the MySQL Command Line Client and the table looks fine to me... no doubles there. Any ideas?
Reply With Quote