NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Why is this inserting another row, but the same value each time?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 10-25-2005, 04:52 PM THREAD STARTER               #1 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)

Question Why is this inserting another row, but the same value each time?


Hi,

This code:

PHP Code:
<?php

include("../fns.php");

if (!
$act || !$id)
{
  
error("Could not find action and/or ID.");
}


$q mysql_query("SELECT * FROM registry WHERE id='$id' LIMIT 1");
????: NamePros.com http://www.namepros.com/programming/134893-why-inserting-another-row-but-same.html
while (
$r mysql_fetch_array($q))
{
  
$name $r['name'];
  
$uid $r['uid'];
}
$name strtolower($name);
$name2 explode("."$name);
$main $name2[0];

$main md5($main);

$datea date("F d, Y");
????: NamePros.com http://www.namepros.com/showthread.php?t=134893

if (
$act == "bd")
{
  
  
mysql_query("DELETE FROM registry WHERE id='$id' LIMIT 1");
  
  
mysql_query("INSERT INTO banned VALUES(NULL, '$main', '$datea')");
  
//Done.
}

if (
$act == "b")
{
 
  
mysql_query("INSERT INTO banned VALUES(NULL, '$main', '$datea')");
  
//Done.
}

if (
$act == "d")
{
  
  
mysql_query("DELETE FROM registry WHERE id='$id' LIMIT 1");
  
//Done.
}
?>
That's the whole file. Why does it insert...

1. A row of the Md5'ed $main variable, like it's supposed to, but then...
2. Another row which has the SAME value for $main EACH TIME I run this script... very odd.

Here are the rows it inserts after I run the script only 2 times:

b2fcb4ba898f479790076dbd5daa133f
d41d8cd98f00b204e9800998ecf8427e
84d72f977c4770ee176911e3165257d1
d41d8cd98f00b204e9800998ecf8427e

As you can see, the second and fourth rows are the same... :
mholt is offline  
Old 10-26-2005, 08:41 AM   #2 (permalink)
NamePros Member
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 127
eagle12 will become famous soon enougheagle12 will become famous soon enough
 



What is in the fns.php file? Your code looks fine that you posted, so I am wondering if there is anything in the fns file that may be having a problem.
eagle12 is offline  
Old 10-26-2005, 02:43 PM THREAD STARTER               #3 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
It's kind of long so I'm not going to post it here, but I can assure you it has NO MySQL insert statements in the file AT ALL. Just an update and a few selects.

Any other ideas?
mholt is offline  
Old 10-26-2005, 03:00 PM   #4 (permalink)
RJ
NamePros Webmaster


 
RJ's Avatar
Join Date: Feb 2003
Posts: 12,930
RJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatnessRJ Has achieved greatness
 



Find Marrow Donors! Cystic Fibrosis Parkinson's Disease
Why is there a LIMIT 1 on your first query?

$q = mysql_query("SELECT * FROM registry WHERE id='$id' LIMIT 1");
__________________
@DomainBuyer facebook
RJ is offline  
Old 10-26-2005, 08:09 PM THREAD STARTER               #5 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
I do that just in case I guess it's not necessary but it makes sure you don't get confusion with other rows if something DOES go wrong. That can't be the problem... can it?

I took out the MD5 and found out that it was just a " " single space character - now I'm confused O.o

After rewriting it a little bit, THIS QUERY:

mysql_query("INSERT INTO banned VALUES(NULL, '$main', '$datea')");

would insert the literal value "datea" into the column - Now I'm REALLLY confused!

I even went as far as setting a variable when it runs the INSERT query, if it isn't already set. This way it should force it from running more than once... but still no change!

Dude my PHP is mutating or something O.o ... lemme post the current file:

PHP Code:
<?php

include("../fns.php");

if (!
$act || !$id)
????: NamePros.com http://www.namepros.com/showthread.php?t=134893
{
  
error("Could not find action and/or ID.");
}


$q mysql_query("SELECT * FROM registry WHERE id='$id' LIMIT 1");
while (
$r mysql_fetch_array($q))
{
  
$name $r['name'];
  
$uid $r['uid'];
}
$name strtolower($name);
$name2 explode("."$name);
$main $name2[0];

//THIS WAY WE CAN READ THE ACTUAL VALUE IN PHPMYADMIN.
//After echoing this value, we get the desired result... hmm...
//$maint = md5($main);

$datea date("F d, Y");

function 
banthisname($maint$datea date("F d, Y"), $s)
{
  if (
$s 1)
????: NamePros.com http://www.namepros.com/showthread.php?t=134893
  {
  
$thequery "INSERT INTO banned VALUES(NULL, '$maint', '$datea') LIMIT 1";
  
mysql_query($thequery);
  
$abc 1;
  return 
$abc;
  }
  else
  {
    return 
0;
  }
}

if (
$act == "bd")
{
  
//Ban and Delete name.
  
mysql_query("DELETE FROM registry WHERE id='$id' LIMIT 1");
  
//Done that... now ban it.
  
$s banthisname($maintdatea$s);
  
//Done.
}

if (
$act == "b")
{
  
//Ban the name.
  
if (!$s)
  {
    
$s banthisname($maint$datea$s);
  }
  
//Done.
}

if (
$act == "d")
{
  
//delete the name.
  
mysql_query("DELETE FROM registry WHERE id='$id' LIMIT 1");
  
//Done.
}
?>
It seems a little desperate, doesn't it.... in fact I wrote that frantically so it may have some obvious logical errors or inefficient coding. Right now I don't care Lol this is getting on my nerves...

Any help is VERY greatly appreciated! ^_^
mholt is offline  
Old 10-26-2005, 09:07 PM   #6 (permalink)
NamePros Regular
Join Date: Feb 2004
Location: Student @ UConn
Posts: 411
gamex has a spectacular aura aboutgamex has a spectacular aura about
 



You have a line of code like this:

PHP Code:
$s banthisname($maintdatea$s); 
????: NamePros.com http://www.namepros.com/showthread.php?t=134893
datea should be $datea, but I dont know if that will solve your problem
__________________
Joe
gamex is offline  
Old 10-26-2005, 09:10 PM THREAD STARTER               #7 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Oh. that might be it. It's 10 PM right now so that might explain something

Still not solving the double entry thing :-/
mholt is offline  
Old 10-26-2005, 10:27 PM   #8 (permalink)
NamePros Regular
 
nick's Avatar
Join Date: Jun 2004
Location: Iowa City
Posts: 705
nick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud ofnick has much to be proud of
 


Save The Children
do you use banthisname() in fns.php?
__________________
formally ninedogger
------
Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends
nick is offline  
Old 10-27-2005, 06:28 AM THREAD STARTER               #9 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Nope.
mholt is offline  
Old 10-28-2005, 02:02 PM THREAD STARTER               #10 (permalink)
DNOA Member
Join Date: May 2004
Posts: 5,040
mholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant futuremholt has a brilliant future
 


Autism Marrow Donor Program 9/11/01 :: Never Forget Multiple Sclerosis Adoption Alzheimer's Lou Gehrig's Disease (ALS)
Ah - fixed it. Not sure why it was doing this, but I discovered it was running the file twice for some reason. I was able to prevent it from happening but do not know what was causing it.
mholt is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
BannersMax Blowout! 50% Off All Banners! $6.98 for 468x60 Banners! Limited Time offer instanet Web Development Wanted 3 07-02-2005 05:10 PM
Actual expiration time? Fork Domain Name Discussion 2 05-27-2005 10:50 AM
Domain and Online Assistance When You Have No Time rak147 For Sale / Advertising Board 2 02-29-2004 08:43 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:37 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger