Results 1 to 4 of 4

Thread: form help

  1. #1
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default form help

    How come I keep getting this message: "Could not send query: Column count doesn't match value count at row 1"

    <?php

    include 'session.inc.php';
    include 'config.inc.php';
    include 'db.inc.php';


    $link = db_connect();

    $date = $_POST['date'];
    $venue = $_POST['venue'];
    $location = $_POST['location'];
    $information = $_POST['information'];


    $query = "INSERT INTO showdates VALUES ('','$date','$venue','$location','$information')";
    db_query($query, $link);
    db_close(null, $link);

    $link = db_connect();

    db_close($result, $link);

    ?>
    <html>
    <head>
    <title>Show Updates</title>
    <LINK REL="SHORTCUT ICON" HREF="../favicon.ico">
    <link href="../admin/rustedshows.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <center><img src="images/textbanner.gif" border=0></center>
    <br><table border=0 width=55&#37; bgcolor="#BEC9D4" cellpadding=0 cellspacing=0 align=center style="border:1px solid #000;">
    <tr>
    <td style="padding:12px;">Add New Shows
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="Add New Shows">
    <table>
    <tr>
    <td>Date:</td>
    <td><input name="date" type="date" id="date"></td>
    </tr>
    <tr>
    <td>Venue:</td>
    <td><input name="venue" type="text" id="venue"></td>
    </tr>
    <tr>
    <td>Location:</td>
    <td><input name="location" type="text" id="location"></td>
    </tr>
    <tr>
    <td>Information:</td>
    <td><input name="information" type="text" id="information"></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input name="submit" type="submit" id="submit" value="Submit">
    <input name="reset" type="reset" id="reset" value="Reset">
    </div></td>
    </tr>
    </table>
    </form>
    <a href="../admin/?logout">Logout</a>&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;<a href="admin.php">Back to Main Page</a></td>
    </tr>
    </table>
    <p><br><p><br><center>Design &copy; Llora McGrath 2007</center>
    </body>
    </html>
    Last edited by llorax; 03-28-2007 at 05:41 AM. Reason: newer version

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Try to insert null value into your empty column and check whether you are getting the error.

  3. #3
    Join Date
    Mar 2007
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm sorry but I don't understand.

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    On this line:
    Code:
    $query = "INSERT INTO showdates VALUES ('','$date','$venue','$location','$information')";
    try this (codex suggestion):

    Code:
    $query = "INSERT INTO showdates VALUES (null,'$date','$venue','$location','$information')";
    Something else you could try is to assign what values go to what columns like so:

    Code:
    $query = "INSERT INTO showdates (`id`, `date`,`venue`,`location`,`information`) VALUES ('','$date','$venue','$location','$information')";
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •