Welcome, Guest
  • Author Topic: What is wrong with my INSERT INTO sql statement?  (Read 798 times)

    Xman51

    • Server what's that
    • *
    • Posts: 13
      • AOL Instant Messenger - Mantaco51@aim.co
      • View Profile
      • Area 51
    Hello All,

    I don't understand what is wrong with my INSERT INTO sql statement. Does anyone see the error in my code?

    <?php
    Code: [Select]
    $InsName= $_POST['pName'];
    $InsRace= $_POST['pRace'];
    $InsGender= $_POST['pGender'];
    $InsEyes= $_POST['pEyes'];
    $InsEyeLeftColor= $_POST['pEyeLeftColor'];
    $InsEyeRightColor= $_POST['pEyeRightColor'];
    $InsHeight= $_POST['pHeight'];
    $InsWeight= $_POST['pWeight'];
    $InsAge = $_POST['pAge'];
    $InsHair= $_POST['pHair'];
    $InsHairColor= $_POST['pHairColor'];
    $InsSize= $_POST['pSize'];
    $InsShirt= $_POST['pShirt'];
    $InsShirtColor= $_POST['pShirtColor'];
    $InsPants= $_POST['pPants'];
    $InsPantsColor= $_POST['pPantsColor'];
    $InsShoes= $_POST['pShoes'];
    $InsShoesColor= $_POST['pShoesColor'];
    $InsArmor= $_POST['pArmor'];
    $InsArmorColor= $_POST['pArmorColor'];
    $InsWeapon= $_POST['pWeapon'];
    $InsHitPoints="10";
    $InsAC="10";
    $InsInitiative="0";
    $InsExperience="0";
    $InsLevel="0";


    //Open the connection
    $conn=odbc_connect('Combo','xman51','area51');
    if (!$conn)
    {
    exit("Connection Failed: " . $conn);
    }
    $sql="INSERT INTO Members VALUES('$InsName', '$InsRace', '$InsEyes', '$InsHairColor', '$InsHair',

    '$InsHeight', '$InsWeight', '$InsGender', '$InsAge', '$InsSize', '$InsShirt', '$InsShirtColor',

    '$InsPants', '$InsPantsColor', '$InsShoes', '$InsShoesColor', '$InsHitPoints', '$InsArmor',

    '$InsArmorColor', '$InsWeapon', '$InsAC', '$InsInitiative', '$InsExperience', '$InsLevel');";

    echo $sql;
    ?>

    Thanks in Advance,

    Xman51

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: What is wrong with my INSERT INTO sql statement?
    « Reply #1 on: 07/11/05, 14:47 »
    What's the error output? Probably quantity of data doesn't match quantity of columns

    Jorge

    Xman51

    • Server what's that
    • *
    • Posts: 13
      • AOL Instant Messenger - Mantaco51@aim.co
      • View Profile
      • Area 51
    Re: What is wrong with my INSERT INTO sql statement?
    « Reply #2 on: 07/11/05, 14:56 »
    jorge,

    There is no error output,..it simply does not input the values into the database. I was thinking that the values didn't match the quantity of columns either, but I double checked and it is correct.

    I don't know what else to do...

    Thanks for the reply, I look forward to your response,

    Xman51

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: What is wrong with my INSERT INTO sql statement?
    « Reply #3 on: 07/12/05, 05:49 »
    Copy&paste your insert into phpMyAdmin (or whatever you use to manage mysql) and check if it works

    Jorge

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    Re: What is wrong with my INSERT INTO sql statement?
    « Reply #4 on: 07/13/05, 15:10 »
    Hi,

    looking t the code I find some
    $sql = ....
    followed by
    echo $sql
    Should not there be some statement to execute the sql, too?

    Musicman