Jump to content

Gem

Members
  • Posts

    129
  • Joined

  • Last visited

Posts posted by Gem

  1.   <?php
    $con = mysql_connect("host","user","pw");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }mysql_select_db("bssql", $con);$sql="INSERT INTO name (firstname, lastname,)
    VALUES
    ('$_POST[firstname]', '$_POST[lastname])'";if (!mysql_query($sql,$con))
      {
      die('Error: ' . " $sql " . mysql_error());
      }
    echo "1 record added";mysql_close($con)
    ?>

     

    Hey Keith - thanks for your help mate ...

     

    Which comma is it that shouldnt be there? Please...

     

    XXX

  2. Error: INSERT INTO name (firstname, lastname,) VALUES ('roger', 'wilson') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('roger', 'wilson')' at line 1

     

    New error message ...

     

    Still doesnt mean anything to me though  :-[

  3. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('roger', 'wilson')' at line 1

     

    Same error but with a space between the 2 values ...

     

    Is it possible there is a setting in the table on the server or the database that isnt right or something??

    x

     

  4. Hi all, I'm new to this forum so be nice lol :)

     

    I'm also very new to the whole MySQL and PHP thing, and its only taken me 3 days to connect to my webserver, so things are looking good.

     

    Anyway, I'm finally in ... and I'm experimenting with INSERT. I got this code from a tutorial, added my details and kind of hoped it would work, but it doesn't.

     

    The connection is fine, it's not that ...

     

    The DB is called "bssql", the table is called "name" and has 2 columns, "firstname" and "lastname" CHAR(20).

     

    I'm using the following form:

     

    <form action="insert.php" method="post">

    Firstname: <input type="text" name="firstname" />

    Lastname: <input type="text" name="lastname" />

    <input type="submit" />

     

    and the following for "insert.php"

     

    <?php

    $con = mysql_connect("host","user","password");

    if (!$con)

      {

      die('Could not connect: ' . mysql_error());

      }mysql_select_db("bssql", $con);$sql="INSERT INTO name (firstname, lastname,)

    VALUES

    ('$_POST[firstname]','$_POST[lastname]',)";if (!mysql_query($sql,$con))

      {

      die('Error: ' . mysql_error());

      }

    echo "1 record added";mysql_close($con)

    ?>

     

    and I get this responce ...

     

    "Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('Roger','Wilson',)' at line 1"  

     

    Roger Wilson is the name I was trying to insert into the table.

     

    I hope this is enough information for some to help me ...

     

    I'd really appreciate it if someone could point out where i'm going wrong please ...

     

    Many Thanks, and Kind Regards

     

    Gem

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.