Add same name to database application

I am using a candle program with php…Right now you can light a candle and put your name…but I need to be able to put the same name more than once…if I try to add the same name on a cadle it wont let me…I need to rename it so it will post a candle…can anyone look at my php and coding to see what Im doing wrong. Also I would like to be able to post only 20 candles per page and then have a link near the bottom to click on the other pages that hold more candles that were lit. thanks

<?php

	
    $timestamp = gmdate("U");

    $Expires = sprintf("%s %02d %s %04d %02d:%02d:%02d GMT",
        gmdate("D", $timestamp), gmdate("d", $timestamp),
        gmdate("M", $timestamp), gmdate("Y", $timestamp),
        gmdate("H", $timestamp), gmdate("i", $timestamp),
        gmdate("s", $timestamp));

    $LastModified = sprintf("%s %02d %s %04d %02d:%02d:%02d GMT",
        gmdate("D"), gmdate("d"), gmdate("M"), gmdate("Y"),
        gmdate("H"), gmdate("i"), gmdate("s"));

    
    header("Expires: $Expires");
    header("Last-modified: $LastModified");
    header("Cache-Control: no-cache");

    define("DATABASE_HOST", "localhost"); 
    define("DATABASE_USER", "test"); 
    define("DATABASE_PASSWORD", "test"); 
    define("DATABASE_NAME", "test"); 

    
    $DatabaseLink = MySQL_pconnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD) or die (MySQL_error());

   
    MySQL_select_db(DATABASE_NAME) or die(MySQL_error());
    $nume = $_POST['nume'];
?>
<?

          $nume = htmlentities($nume);
                  if($nume != "")
                  {
                           $Query3 = "SELECT ID FROM candle  WHERE Name="$nume"";
                           $DatabaseResult3 = MySQL_query($Query3, $DatabaseLink);
                           if(!($DatabaseRow = MySQL_num_rows($DatabaseResult3)))
                           {

                                    mysql_query("INSERT INTO candle(Name) VALUES("$nume") ") or die(mysql_error());
                           }
                  }

?>
<?
         $Query = "SELECT max(ID) AS Count FROM candle";
         $DatabaseResult = MySQL_query($Query, $DatabaseLink);
         $DatabaseRow = MySQL_fetch_object($DatabaseResult);
         if ($DatabaseRow->Count>0) $TotalCount = $DatabaseRow->Count;
         	else $TotalCount=0;
?>

<html>
<head>
<title>Light a candle </title>
</head>
<body bgcolor="#000000" class="text" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<center><table border="0" cellpadding="0" cellspacing="0">
<tr><td><b><font size="7"><a href="index.php">
	<span style="text-decoration: none">LIGHT CANDLE</span></a></font></b></td></tr></table>
</center>
<br>

<br>
<FONT SIZE="4">
<center><b>"We Love You Kristofer"</center></b></font><br>

<center><form method="post" action="index.php?step=2&Count=<? $submitCount = $TotalCount + 50; print($submitCount); ?>" >
<b>Enter your name</b>  <input type="text" name="nume"> &nbsp<input type="submit" name="submit" value="Light Candle"></center>
</form>
</td>
</tr></table>

<b>Candles Lit for Kristofer:&nbsp;

<?
         print($TotalCount);
         if(!isset($preCount))
         {
                  $preCount = $TotalCount - 10000;
         }
         if(!isset($Count))
         {
                  $Count = $TotalCount + 1000;
         }

?>
</b><br>
<?
if($submit == "Search" || $yes == "yes")
{
        print(" <br>");
         print("Search Result:   <br><br>");
         $Query = "SELECT ID, Name FROM candle WHERE Name LIKE "%$search%" ORDER BY ID DESC";
         $DatabaseResult = MySQL_query($Query, $DatabaseLink);
         while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
         {
        $id = $DatabaseRow->ID + 5;
           print("<a href="index.php?Count=$id">$DatabaseRow->Name</a><br>");
         }

         if(MySQL_num_rows($DatabaseResult) == 0)
         {
                  print("None found.<br><br>");
        print("<a href="index.php?Count=$TotalCount"> Return to Candle Main Page</a><br>");
         }
}else
{

?>

<table cellspacing="16"><tr align="center">
<?

         if($Count > 10000)
         {
                  $preCount = $Count - 10000;
         }
         $interval = 0;
    //$Query = "SELECT ID, Name FROM candle ORDER BY ID ASC";

         $Query = "SELECT ID, Name FROM candle WHERE ID > "$preCount" AND ID < "$Count" ORDER BY ID DESC";
         $DatabaseResult = MySQL_query($Query, $DatabaseLink);
         while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
         {
                  $nume = $DatabaseRow->Name;
                  print("<td><img src="images/candle.gif" width="70" height="79"><br>$nume</td>");
                  $interval++;
                  if($interval == 4)
                  {
                           print("</tr><tr>");
                           $interval = 0;
                  }
         }
?>
<br>
<br>
<br>


<form name=myform>

</form></center></tr></td></table>
<?
}
?>
</td>
    </tr>
  </table>
  </center>
</div>

<script LANGUAGE="JavaScript">
<!--
function WindowOpen1()
{
window.open('copyright.php', 'Window1', 'resizable,height=420,width=400');
}
//-->
</script>



</body>
</html>

could it be that the name is a UNIQUE-index?

seperating the results on pages: use a get variable as LIMIT of the SQL.

could you show me in the code what I need to change? I kinda figured out what I need but I cant find the place to put it. thanks

could u try, and reply it u run into an error?

figured it out…I took out the code if(!($DatabaseRow = MySQL_num_rows($DatabaseResult3)))
and now I can use the same name…I guess it checked my database row and if it found the same name it would not submit it…the easy things are so hard to see when its late…

Sponsor our Newsletter | Privacy Policy | Terms of Service