Jump to content

Double rows? (two rows for every individual value.)


Caliber Mengsk

Recommended Posts

So, I'm working on trying to create a simple get data script right now. The people that worked at this place before me set up a database to get data from at a later time, and didn't set up an interface for doing so. I have no problem programming a few webpages to see everything, problem is, I'm getting results like this:

id: 1
id: 1
Date: Fri Jun 17 05:43:54 2011
Date: Fri Jun 17 05:43:54 2011
Write_transfer_rate_average: 129.25x
Write_transfer_rate_average: 129.25x
Write_transfer_rate_start: 
Write_transfer_rate_start: 
Write_transfer_rate_middle: 
Write_transfer_rate_middle: 
Write_transfer_rate_end: 10.0x
Write_transfer_rate_end: 10.0x

 

As you can see, it's printing out the results twice, even though my code doesn't say to do that. At this point, I'm just doing a select all.

"SELECT * FROM 2011testing"

 

I don't see anything in my php code that would duplicate it, but here is that if it's needed.

 

index.php

<?php
include('db.php');
$conn = db_conn('**TAKEN OUT FOR SECURITY**', '**TAKEN OUT FOR SECURITY**', '**TAKEN OUT FOR SECURITY**', '**TAKEN OUT FOR SECURITY**');
if($conn == false)
{
echo "Didn't connect correctly.";
}else{
$failed = false;
$sql = mysql_query("SELECT * FROM 2011testing") or $failed = true;
if(!$failed)
{
	while($row = mysql_fetch_array($sql))
	{
		$x = 0;
		foreach($row as $r)
		{
			echo mysql_field_name($sql,$x) . ": " . $r . "<br />";
			$x+=.5; //will be 1 instead of .5 after I figure out this problem.
		}
		echo "==================================================================================<br />";

	}
	echo "Completed data collection.";
}else{
	echo "Failed to complete.";
}
}
@db_disconn($conn); //@ comment for if the connection didn't work. I still want to display the rest of the page.
?>

 

db.php

<?php
function db_conn($server, $username, $password, $db)
{
$connected = true;
@$link = mysql_connect($server, $username, $password);
if($link)
{
	mysql_select_db('testing', $link);
}else{
	$connected = false;
}
if($connected)
{
	return $link;
}
}

function db_disconn($link)
{
mysql_close($link);
}
?>

 

 

Lastly, here is the table structure:

2011testing | CREATE TABLE `2011testing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Date` longtext COLLATE utf8_unicode_ci,
  `Write_transfer_rate_average` longtext COLLATE utf8_unicode_ci,
  `Write_transfer_rate_start` longtext COLLATE utf8_unicode_ci,
  `Write_transfer_rate_middle` longtext COLLATE utf8_unicode_ci,
  `Write_transfer_rate_end` longtext COLLATE utf8_unicode_ci,
  `Read_transfer_rate_average` longtext COLLATE utf8_unicode_ci,
  `Read_transfer_rate_start` longtext COLLATE utf8_unicode_ci,
  `Read_transfer_rate_middle` longtext COLLATE utf8_unicode_ci,
  `Read_transfer_rate_end` longtext COLLATE utf8_unicode_ci,
  `Random_seek_time_buffered` longtext COLLATE utf8_unicode_ci,
  `Random_seek_time_cached` longtext COLLATE utf8_unicode_ci,
  `Vendor` longtext COLLATE utf8_unicode_ci,
  `Model` longtext COLLATE utf8_unicode_ci,
  `Firmware` longtext COLLATE utf8_unicode_ci,
  `Serial_Number_External` longtext COLLATE utf8_unicode_ci,
  `Serial_Number_Internal` longtext COLLATE utf8_unicode_ci,
  `Status_Info` longtext COLLATE utf8_unicode_ci,
  `Vendor_Code` longtext COLLATE utf8_unicode_ci,
  `Date_recieved` longtext COLLATE utf8_unicode_ci,
  `User_Changes_Remaining` longtext COLLATE utf8_unicode_ci,
  `Vendor_Resets_Remaining` longtext COLLATE utf8_unicode_ci,
  `Current_Region` longtext COLLATE utf8_unicode_ci,
  `Test_ran` longtext COLLATE utf8_unicode_ci,
  `Note` longtext COLLATE utf8_unicode_ci,
  `Log` longtext COLLATE utf8_unicode_ci,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=341 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

 

I don't see ANY reason why it is outputting duplicate results in either my php or mysql. Can anyone help with this? I do think I've had this problem before, but I just simply don't remember how I went about fixing this. OH! Mysql version is 14.14 Dist 5.1.46, OS is opensuse.

 

Obviously it's not a problem connecting to the database, as I am actually getting results... just to many of them. XD Thanks in advance. I know it's probably something stupid simple, but I just can't figure it out for the life of me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.