The delete does not want to work.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • webandwe
    New Member
    • Oct 2006
    • 142

    #1

    The delete does not want to work.

    Hi For some reason the delete function does not want to work..

    What I have is a from field where you put in the ID no you want to delete, this must then delete the row in mysql.

    Database name = db2
    table = contacts
    row = ino

    Please not I wrote mypass, user just for here..I did not forget to write it. All this is on one page.


    [HTML]
    <form action="d4.php" method="post" name="example" id="delete">
    <span class="style1 style4">Delete by ID No :</span>
    <input type="text" name="delete" />
    <br />
    <input name="submit" type="submit" value="delete" />
    </form>[/HTML]
    [PHP] <?php
    $con = mysql_connect(" localhost","myu ser","mypass") ;
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db ("mydb_-_db2", $con);


    if($_POST['delete']){ $query = "DELETE FROM contacts WHERE ino='" . $_POST['delete'] . "'"; mysql_query($qu ery); }



    mysql_close($co n);
    ?> [/PHP]

    Kind Regards
    Louwrens
    Last edited by webandwe; Mar 6 '07, 09:38 AM. Reason: forgot something
  • webandwe
    New Member
    • Oct 2006
    • 142

    #2
    Never mind go it working.

    Kind Regards
    Webandwe

    Comment

    • gauravgmbhr
      New Member
      • Feb 2007
      • 107

      #3
      Originally posted by webandwe
      Never mind go it working.

      Kind Regards
      Webandwe

      the row is not getting delete because u r putting ino in 'ino' which makes it a string

      use:
      delete something
      from some table
      Where ino=$_post['delete'];

      and don't use
      delete something
      from some table
      Where ino=' $_post['delete'] ';

      because putting integer in quotes make it a string
      so the condition is not met
      and the row do not delete

      Comment

      Working...