SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    my php is a little rusty, and I can't problem solve this code

    Below is a script, which can be tested at http://dky.sytes.net/golesnew/cat/rhscategories.php and what its supposed to do is if you add a category/table, it either is supposed to give an error as to why its not able to add it, or give a "you successfully added category $name" But all it seems that its doing is refreshing the page, and I can't figure out why.


    PHP Code:
    <html><head><title>Add/Remove a Category</title>
    <style type="text/css">
    <!--Basically, the trick is to position a div at 50%, 50% and then set its margin-left to negative
    width/2 and its margin-top to negative height/2.-->
      <!--
        DIV.outer
          {
          position:absolute;
          left:50%;
          top:50%;
          width:602px;
          height:224px;
          margin-left:-301px; 
          margin-top:-112px;
          background-color:#003300;
          }
          
        DIV.inner
          {
          position:absolute;
          left:50%;
          top:50%;
          width:600px;
          height:222px;
          margin-left:-300px; 
          margin-top:-111px;
          background-color:#ffffff;
          }
          
        DIV.returnouter
          {
          position:absolute;
          left:50%;
          top:50%;
          width:602px;
          height:76px;
          margin-left:-301px; 
          margin-top:-38px;
          background-color:#003300;
          }
          
        DIV.returninner
          {
          position:absolute;
          left:50%;
          top:50%;
          width:600px;
          height:74px;
          margin-left:-300px; 
          margin-top:-37px;
          background-color:#ffffff;
          }
          
       -->
        </style>
        <LINK HREF="catalog.css" REL="STYLESHEET">
        </head><body>

    <?
    require("connect.php");
    database_connect();
    display_tables();

    /* begining of php for the category naming part of the form */

    if ($_POST["Submit"])
    {
    $makecategory       $_POST["category"];
    $makecategory       stripslashes($makecategory);
    $makecategoryquery  "CREATE TABLE $makecategory (
    Product_Number  INT(20)UNSIGNED  AUTO_INCREMENT, 
    Picture         LONGBLOB, 
    Thumbnail       LONGBLOB,
    Item_Name       VARCHAR(60),
    Description     VARCHAR(255),
    Price           VARCHAR(40),
    PRIMARY KEY (Product_Number) )"
    ;
    $makecategoryresult           mysql_query($makecategoryquery);
    if (!
    $makecategoryresult)
    {
        
    $mcrmessage mysql_error();
         echo 
    "<div class='returnouter'><div class='returninner'><p align='center'><font id='headers'>";
         echo 
    "$mcrmessage<br>";
         echo 
    '<a href="rhscategories.php">Click the link to return to the category page.</a>';
         echo 
    "</font></div></div></body></html>";
         echo 
    "</body></html>";
         die();

    else
       {
         echo 
    "<div class='returnouter'><div class='returninner'><p align='center'><font id='headers'><br>
         You have successfully added a new category named '
    $makecategory'<br><br><a href='rhscategories.php'>
         Click the link to return to the category page.</a></font></div></div></body></html>"
    ;
         exit();
       }
    }

    /* end of category naming php */

     

    /* begining of php for the deleting category part of the form */

    $deletecategory  =  $_POST["delete_category"];
    if (
    $deletecategory == "SelectaCategorytoDelete")
    {
    echo 
    "Please Select a Category";    
    }
    else
    {
    if (
    $_POST["Delete"])
    {
    $deletecategoryquery  "DROP TABLE $deletecategory";
    $deletecategoryresult           mysql_query($deletecategoryquery);
    if (!
    $deletecategoryresult)
    {
        
    $mcrmessage mysql_error();
         echo 
    "<div class='returnouter'><div class='returninner'><p align='center'><font id='headers'>";
         echo 
    "$mcrmessage<br>";
         echo 
    '<a href="rhscategories.php">Click the link to return to the category page.</a>';
         echo 
    "</font></div></div></body></html>";
         echo 
    "</body></html>";
         die();

    else
       {
         echo 
    "<div class='returnouter'><div class='returninner'><p align='center'><font id='headers'>";
         echo 
    "<br>You have successfully removed the category named '$deletecategory'<br><br><a href='rhscategories.php'>Click the link to return to the category page.</a>";
         echo 
    "</font></div></div></body></html>";
         exit();
       }
    }
    }

    /* end of delete category php */

    database_disconnect();

    ?>

    <div class="outer"><div class="inner"><FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="makecategory">
       <br><CENTER>
          <P ALIGN=CENTER>
           <TABLE WIDTH="250" bordercolor="black" CELLPADDING="0" CELLSPACING="0" BORDER="0">
            <TR>
            
            <TD style="border-bottom-style: solid; border-bottom-width:1"
            style="border-right-style: solid; border-right-width: 1"
            style="border-top-style: solid; border-top-width:1"
            style="border-left-style: solid; border-left-width: 1"
            WIDTH="100%" BGCOLOR="#CCD6CD" VALIGN=center id='headers'>&nbsp;Make a New Category:</TD>
            </TR>
            <TR>
          
            <TD WIDTH="100%" VALIGN=TOP><p align="center">
               <input type="text" name="category" size=40></p></TD>
            </TR>
                </TABLE>
               <p>
                <input type="submit" name="Submit" value="Save New Category">
               </p>
    </form>


    <FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="deletecategory">
       <CENTER>
          <P ALIGN=CENTER>
           <TABLE WIDTH="250" bordercolor="black" CELLPADDING="0" CELLSPACING="0" BORDER="0">
            <TR>
            
            <TD style="border-bottom-style: solid; border-bottom-width:1"
            style="border-right-style: solid; border-right-width: 1"
            style="border-top-style: solid; border-top-width:1"
            style="border-left-style: solid; border-left-width: 1"
            WIDTH="100%" BGCOLOR="#CCD6CD" VALIGN=center id='headers'>&nbsp;Delete the Category:</TD>
            </TR>
            <TR>
          
            <TD WIDTH="100%" VALIGN=TOP><p align="center">
              <?
              
    echo "<select name='delete_category'>";?>
              <option value="SelectaCategorytoDelete">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select a Category to Delete&nbsp;&nbsp;
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <?
              
    while($rowmysql_fetch_array($result))
              {
                 echo 
    "<option>".$row[0]."<br>";
              }
              echo 
    "</select>";?>

        </p></TD>
            </TR>
                </TABLE>
              <p>
                <input type="submit" name="Delete" value="Delete Category">
              </p>
    </form></div></div>

     


    </body></html>

  2. #2
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nevermind, needed to upgrade php on my server

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Southern Maine
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, just for the hell of it what was the error?
    Working on a new CSS site for RKS and PHP driven?

    Looking for staff, tutorial site for coding, and photshop. PM me.

  4. #4
    SitePoint Addict RapidGaming's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lacrosse
    lol, just for the hell of it what was the error?
    Read the first bit again, it didn't give an error.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Southern Maine
    Posts
    95
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, my bad.
    Working on a new CSS site for RKS and PHP driven?

    Looking for staff, tutorial site for coding, and photshop. PM me.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •