Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    2

    Unanswered: MySQL Newbie Getting Errors with PHP to MySQL script.

    Hello,

    I have a script which is supposed to add a number (inputed into a HTML form, and passed to a PHP script) to a MySQL database. The field in the database says this:
    PHP Code:
    Namenumber
    Type
    INT
    Legenth
    3
    Attributes
    Blank
    Null
    not null
    Default: 5
    Extra
    Blank 
    The PHP script looks like this:
    PHP Code:
    <?php
    $housename 
    gryffindor
    $number=$_POST['number'];//get the number from POST 
    settype($number"integer");//make sure it's a number not a string .. 
    $conn mysql_connect ("localhost""PUTDATABASEUSERNAMEHERE""PUTDATABASEPASSWORDHERE"); 
    mysql_select_db ("PUTDATABASENAMEHERE",$conn); 
    $sql "INSERT INTO $housename values ('', number=number+$number)"
    if (
    mysql_query($sql$conn)) { 
    echo 
    "record added!"
    } else { 
        echo 
    "something went wrong"

    ?>

    On my test machine, all it says is "Something Went Wrong". Why is that?

    Also, on my main server, I get a MySQL "Seeking" error. I've never heard of that. What does it mean?

  2. #2
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    You forget to tell mysql which field to use

    insert into table (col, col ...) values ('xx', 'xx', ...)
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

  3. #3
    Join Date
    Dec 2003
    Posts
    2
    Originally posted by omiossec
    You forget to tell mysql which field to use

    insert into table (col, col ...) values ('xx', 'xx', ...)

    So if the table was named "gryffindor" and the field was named "number", how would that look?

Posting Permissions

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