Deleting a Record.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob

    Deleting a Record.

    Thanks for the Help on the other problems...all resolved.
    One last (hopefullly) problem I can't seem to get around for this
    program...why isn't this deleting the row i want? It does nothing. Now error
    messages either. HELP!

    $link = mysql_connect(" localhost");
    if(! $link)
    die("Could not connect to MySQL");

    $database = "PC_Store";
    mysql_select_db ($database)
    or die ("could not open $database: ".mysql_err or() );

    $result = mysql_query("DE LETE FROM inventorydata VALUES('$Produc tID')");

    The $ProductID variable is brought in from a menu choice on a diffrent page,
    it is also the primary of the table...so it should delete the whole row
    right?

    Thanks again,
    Rob


  • Jochen Daum

    #2
    Re: Deleting a Record.

    Hi Rob!

    On Sun, 23 Nov 2003 19:06:41 -0700, "Rob" <talon2lm@yahoo .com> wrote:
    [color=blue]
    >Thanks for the Help on the other problems...all resolved.
    >One last (hopefullly) problem I can't seem to get around for this
    >program...wh y isn't this deleting the row i want? It does nothing. Now error
    >messages either. HELP!
    >
    >$link = mysql_connect(" localhost");
    >if(! $link)
    > die("Could not connect to MySQL");
    >
    >$database = "PC_Store";
    >mysql_select_d b($database)
    > or die ("could not open $database: ".mysql_err or() );
    >
    >$result = mysql_query("DE LETE FROM inventorydata VALUES('$Produc tID')");
    >
    >The $ProductID variable is brought in from a menu choice on a diffrent page,
    >it is also the primary of the table...so it should delete the whole row
    >right?[/color]

    Try

    "delete from inventorydata where field = '".$ProductID." '"

    Have a look at www.mysql.com for sql syntax

    HTH, Jochen
    --
    Jochen Daum - CANS Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

    Comment

    • Rob

      #3
      Re: Deleting a Record.

      Still nothing....
      Not even an error message...

      Thanks,
      Rob
      "Jochen Daum" <jochen.daum@ca ns.co.nz> wrote in message
      news:86q2sv8ld0 302f1rq9tj59ivs uf20po5m7@4ax.c om...[color=blue]
      > Hi Rob!
      >
      > On Sun, 23 Nov 2003 19:06:41 -0700, "Rob" <talon2lm@yahoo .com> wrote:
      >[color=green]
      > >Thanks for the Help on the other problems...all resolved.
      > >One last (hopefullly) problem I can't seem to get around for this
      > >program...wh y isn't this deleting the row i want? It does nothing. Now[/color][/color]
      error[color=blue][color=green]
      > >messages either. HELP!
      > >
      > >$link = mysql_connect(" localhost");
      > >if(! $link)
      > > die("Could not connect to MySQL");
      > >
      > >$database = "PC_Store";
      > >mysql_select_d b($database)
      > > or die ("could not open $database: ".mysql_err or() );
      > >
      > >$result = mysql_query("DE LETE FROM inventorydata VALUES('$Produc tID')");
      > >
      > >The $ProductID variable is brought in from a menu choice on a diffrent[/color][/color]
      page,[color=blue][color=green]
      > >it is also the primary of the table...so it should delete the whole row
      > >right?[/color]
      >
      > Try
      >
      > "delete from inventorydata where field = '".$ProductID." '"
      >
      > Have a look at www.mysql.com for sql syntax
      >
      > HTH, Jochen
      > --
      > Jochen Daum - CANS Ltd.
      > PHP DB Edit Toolkit -- PHP scripts for building
      > database editing interfaces.
      > http://sourceforge.net/projects/phpdbedittk/[/color]


      Comment

      • Jochen Daum

        #4
        Re: Deleting a Record.

        Hi!

        [color=blue]
        >Still nothing....
        >Not even an error message...
        >[/color]

        Can you do:

        - error_reporting (E_ALL);

        $sql = "delete from ....."
        print $sql;

        $result = mysql_query("DE LETE FROM inventorydata
        VALUES('$Produc tID')");

        var_dump($resul t);
        var_dump(mysql_ error());
        var_dump(mysql_ rows_affected() );

        HTH, Jochen
        [color=blue]
        >Thanks,
        >Rob
        >"Jochen Daum" <jochen.daum@ca ns.co.nz> wrote in message
        >news:86q2sv8ld 0302f1rq9tj59iv suf20po5m7@4ax. com...[color=green]
        >> Hi Rob!
        >>
        >> On Sun, 23 Nov 2003 19:06:41 -0700, "Rob" <talon2lm@yahoo .com> wrote:
        >>[color=darkred]
        >> >Thanks for the Help on the other problems...all resolved.
        >> >One last (hopefullly) problem I can't seem to get around for this
        >> >program...wh y isn't this deleting the row i want? It does nothing. Now[/color][/color]
        >error[color=green][color=darkred]
        >> >messages either. HELP!
        >> >
        >> >$link = mysql_connect(" localhost");
        >> >if(! $link)
        >> > die("Could not connect to MySQL");
        >> >
        >> >$database = "PC_Store";
        >> >mysql_select_d b($database)
        >> > or die ("could not open $database: ".mysql_err or() );
        >> >
        >> >$result = mysql_query("DE LETE FROM inventorydata VALUES('$Produc tID')");
        >> >
        >> >The $ProductID variable is brought in from a menu choice on a diffrent[/color][/color]
        >page,[color=green][color=darkred]
        >> >it is also the primary of the table...so it should delete the whole row
        >> >right?[/color]
        >>
        >> Try
        >>
        >> "delete from inventorydata where field = '".$ProductID." '"
        >>
        >> Have a look at www.mysql.com for sql syntax
        >>
        >> HTH, Jochen
        >> --
        >> Jochen Daum - CANS Ltd.
        >> PHP DB Edit Toolkit -- PHP scripts for building
        >> database editing interfaces.
        >> http://sourceforge.net/projects/phpdbedittk/[/color]
        >[/color]

        --
        Jochen Daum - CANS Ltd.
        PHP DB Edit Toolkit -- PHP scripts for building
        database editing interfaces.
        Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

        Comment

        • Rob

          #5
          Re: Deleting a Record.

          Hi Jochen,

          Here's the exact code I ran

          </HEAD>
          <BODY BGCOLOR=RED>
          <?php

          $link = mysql_connect(" localhost");
          if(! $link)
          die("Could not connect to MySQL");

          $database = "PC_Store";
          mysql_select_db ($database)
          or die ("could not open $database: ".mysql_err or() );

          - error_reporting (E_ALL);

          $sql = "DELETE FROM inventorydata VALUES('$Produc tID')";

          print $sql;

          $result = mysql_query("DE LETE FROM inventorydata

          VALUES('$Produc tID')");

          var_dump($resul t);
          var_dump(mysql_ error());
          var_dump(mysql_ rows_affected() );


          ?>
          <BR>
          Entry Deleted
          </FORM>
          <FORM METHOD=POST ACTION = "PC_Store1.php" >
          <INPUT TYPE = "submit" VALUE ="Return To Main Menu">
          </FORM>

          And here is the Exact output...

          DELETE FROM inventorydata VALUES('40')boo l(false) string(66) "You have an
          error in your SQL syntax near 'VALUES('40')' at line 1"
          Fatal error: Call to undefined function: mysql_rows_affe cted() in
          c:\apache\htdoc s\pcsdelpexein. php on line 23

          I'm not sure what the syntax error is.... 40 is the product Id for the row I
          want to delete.
          The Fatal error is way beyond me....I appreciate your help!

          Rob


          Comment

          • J0hn Sm1th

            #6
            Re: Deleting a Record.

            $sql = 'DELETE FROM inventorydata WHERE productid = '. $ProductID;

            This is basic SQL!


            Rob wrote:
            [color=blue]
            > Hi Jochen,
            >
            > Here's the exact code I ran
            >
            > </HEAD>
            > <BODY BGCOLOR=RED>
            > <?php
            >
            > $link = mysql_connect(" localhost");
            > if(! $link)
            > die("Could not connect to MySQL");
            >
            > $database = "PC_Store";
            > mysql_select_db ($database)
            > or die ("could not open $database: ".mysql_err or() );
            >
            > - error_reporting (E_ALL);
            >
            > $sql = "DELETE FROM inventorydata VALUES('$Produc tID')";
            >
            > print $sql;
            >
            > $result = mysql_query("DE LETE FROM inventorydata
            >
            > VALUES('$Produc tID')");
            >
            > var_dump($resul t);
            > var_dump(mysql_ error());
            > var_dump(mysql_ rows_affected() );
            >
            >
            > ?>
            > <BR>
            > Entry Deleted
            > </FORM>
            > <FORM METHOD=POST ACTION = "PC_Store1.php" >
            > <INPUT TYPE = "submit" VALUE ="Return To Main Menu">
            > </FORM>
            >
            > And here is the Exact output...
            >
            > DELETE FROM inventorydata VALUES('40')boo l(false) string(66) "You have an
            > error in your SQL syntax near 'VALUES('40')' at line 1"
            > Fatal error: Call to undefined function: mysql_rows_affe cted() in
            > c:\apache\htdoc s\pcsdelpexein. php on line 23
            >
            > I'm not sure what the syntax error is.... 40 is the product Id for the row I
            > want to delete.
            > The Fatal error is way beyond me....I appreciate your help!
            >
            > Rob
            >
            >[/color]

            Comment

            • Rob

              #7
              Re: Deleting a Record.

              [color=blue]
              >
              > This is basic SQL!
              >[/color]

              LOL..that would explain that!

              Thanks for the help gents...but I got it!!!!!

              Thank god for http://sqlzoo.net/howto/mysqltip903137.htm

              Here's the line I ended up using...simple eh?

              $result = mysql_query("DE LETE FROM inventorydata Where
              ProductID=$Prod uctID");

              It's always the little things.....

              Rob


              Comment

              • Geoff Berrow

                #8
                Re: Deleting a Record.

                I noticed that Message-ID: <xcGdnaItnvbWF1 yiRVn-vA@comcast.com> from Rob
                contained the following:
                [color=blue]
                >$result = mysql_query("DE LETE FROM inventorydata Where
                >ProductID=$Pro ductID");
                >
                >It's always the little things.....[/color]

                It is. Remember, never, ever delete without a where clause (very easy
                to delete the whole lot) Also do not delete from a simple link, other
                wise spiders may delete your database for you.

                --
                Geoff Berrow (put thecat out to email)
                It's only Usenet, no one dies.
                My opinions, not the committee's, mine.
                Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                Comment

                Working...