Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: double insert

  1. #1
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts

    double insert

    i dont know why but my script is inserting the record then a blank record. i dont know why, please help

    PHP Code:
    <?php

    include("connect.php");
    $feedname $_POST['feedname'];
    $feedurl $_POST['feedurl'];

    $query "INSERT INTO feeds (id, feedname, feedurl)
    VALUES ('', '$feedname', '$feedurl')"
    ;

    $results mysql_query($query) or die 
    (
    "Could not execute query : $query." mysql_error());

    if (
    $results)
    {
    echo 
    "Details added.";
    }
    mysql_close();
    ?>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Are you using a javascript submit() function call from an input having type="submit" ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    this is the form code:

    Code:
    <form id="FormName" action="addFeed.php" method="post" name="FormName">
    <table width="448" border="0" cellspacing="2" cellpadding="0">
    <tr>
    <td width = "150">
    <div align="right">
    <label for="feedname">feedname</label>
    </div>
    </td>
    <td>
    <input id="feedname" name="feedname" type="text" size="25" value="" maxlength="255">
    </td>
    </tr>
    <tr>
    <td width = "150">
    <div align="right">
    <label for="feedurl">feedurl</label>
    </div>
    </td>
    <td>
    <input id="feedurl" name="feedurl" type="text" size="25" value="" maxlength="255">
    </td>
    </tr>
    <tr>
    <td width="150">
    </td>
    <td>
    <input type="submit" name="submitButtonName" value="Add">
    </td>
    </tr>
    </table>
    </form>

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,107
    Thanks
    2
    Thanked 326 Times in 318 Posts
    Is the form and the php form processing code in the same file? If so, show that whole file so that the program flow can be seen.

    Also, are you doing any url rewriting in a .htaccess file or are you doing any redirecting?
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    Regular Coder the-dream's Avatar
    Join Date
    Mar 2007
    Location
    Northamptonshire, UK
    Posts
    477
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Different files, no redirect, no .htaccess


  •  

    Posting Permissions

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