Unstoppable Domains

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

Spaceship Spaceship
Watch
Impact
111
Hi,

This code:

PHP:
<?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");
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");

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... :?:
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
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.
 
0
•••
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?
 
0
•••
Why is there a LIMIT 1 on your first query?

$q = mysql_query("SELECT * FROM registry WHERE id='$id' LIMIT 1");
 
0
•••
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:
<?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");
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)
  {
  $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($maint, datea, $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 :yell: Lol this is getting on my nerves...

Any help is VERY greatly appreciated! ^_^
 
0
•••
You have a line of code like this:

PHP:
$s = banthisname($maint, datea, $s);

datea should be $datea, but I dont know if that will solve your problem
 
0
•••
Oh. :P that might be it. :p It's 10 PM right now so that might explain something :)

Still not solving the double entry thing :-/
 
0
•••
do you use banthisname() in fns.php?
 
0
•••
Nope.
 
0
•••
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.
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back