[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 10-25-2005, 03:52 PM   #1 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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");
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... :
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 10-26-2005, 07:41 AM   #2 (permalink)
NamePros Member
 
Join Date: Nov 2003
Location: Ontario, Canada
Posts: 91
80.80 NP$ (Donate)

eagle12 is on a distinguished road


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, 01:43 PM   #3 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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?
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 10-26-2005, 02:00 PM   #4 (permalink)
RJ
NamePros Founder

Administrator

 
Join Date: Feb 2003
Location: Bay Area, CA
Posts: 13,173
104,451.68 NP$ (Donate)

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
Why is there a LIMIT 1 on your first query?

$q = mysql_query("SELECT * FROM registry WHERE id='$id' LIMIT 1");
RJ is offline  
Old 10-26-2005, 07:09 PM   #5 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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)
{
  
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 Lol this is getting on my nerves...

Any help is VERY greatly appreciated! ^_^
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 10-26-2005, 08:07 PM   #6 (permalink)
NamePros Regular
 
gamex's Avatar
 
Join Date: Feb 2004
Location: Student @ UConn
Posts: 408
73.95 NP$ (Donate)

gamex has a spectacular aura aboutgamex has a spectacular aura about


You have a line of code like this:

PHP Code:
$s = banthisname($maint, datea, $s);
datea should be $datea, but I dont know if that will solve your problem
__________________
Joe
CarrotCash.com
gamex is offline  
Old 10-26-2005, 08:10 PM   #7 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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. :P that might be it. It's 10 PM right now so that might explain something

Still not solving the double entry thing :-/
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 10-26-2005, 09:27 PM   #8 (permalink)
NamePros Regular
 
ninedogger's Avatar
 
Join Date: Jun 2004
Location: Iowa
Posts: 669
31.10 NP$ (Donate)

ninedogger is a name known to allninedogger is a name known to allninedogger is a name known to allninedogger is a name known to allninedogger is a name known to allninedogger is a name known to all

Save The Children
do you use banthisname() in fns.php?
ninedogger is offline  
Old 10-27-2005, 05:28 AM   #9 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Old 10-28-2005, 01:02 PM   #10 (permalink)
DNOA Member
 
mholt's Avatar
 
Join Date: May 2004
Location: Utah
Posts: 5,041
18.01 NP$ (Donate)

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.
__________________
codeboards

A high-quality community of programmers -- Join today and post! We want new members!
mholt is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 04:10 PM
Actual expiration time? Shockt Domain Name Discussion 2 05-27-2005 09:50 AM
Domain and Online Assistance When You Have No Time rak147 For Sale / Advertising Board 2 02-29-2004 07:43 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:41 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85