add item on the site

Results 1 to 13 of 13
  1. #1
    Account Upgraded | Title Enabled! 00niels00 is offline
    MemberRank
    Sep 2008 Join Date
    The NetherlandsLocation
    1,041Posts

    add item on the site

    Becuase my gunz server is opened 4 days now i want to give the first players a gift.
    Wizkidje helped me. But i get an error. I dont know what i do wrong.

    This is the script:
    Code:
    <?php
    //Made by Wizkid.
    //Removing my copyright is stupid.
    	
    //Let us connect the database.
    //Yeah yeah, ODBC this time.
    $host = "Servername";
    $user = "sa";
    $pass = "secret";
    $dbname = "GunzDB";
    
    $connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");
    
    //Anti SQL injection
    function antisql($sql)
    {
    // Remove words that contain SQL syntax
    $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql);
    $sql = trim($sql); //Cleans up spaces
    $sql = strip_tags($sql);//Php and html tags strip
    $sql = addslashes($sql);//Adds backslashes to one string
    return $sql;
    }
    
    //The num_rows() function for ODBC since the default one always returns -1.
    function num_rows(&$rid) {
    
    //We can try it at least, right?
    $num= odbc_num_rows($rid);
    if ($num >= 0) {
    return $num;
    }
    
    if (!odbc_fetch_row($rid, 1)) {
    odbc_fetch_row($rid, 0);
    return 0;
    }
    
    if (!odbc_fetch_row($rid, 2)) {
    odbc_fetch_row($rid, 0);
    return 1;
    }
    
    $lo= 2;
    $hi= 8192000;
    
    while ($lo < ($hi - 1)) {
    $mid= (int)(($hi + $lo) / 2);
    if (odbc_fetch_row($rid, $mid)) {
    $lo= $mid;
    } else {
    $hi= $mid;
    }
    }
    $num= $lo;
    odbc_fetch_row($rid, 0);
    return $num;
    }
    
    //GET the act and do the stuff.
    if (isset($_GET['act']) AND $_GET['act'] == "do")
    {
    //Let's get the charname.
    $charname = antisql($_POST['charname']);
    
    //No charname entered... the bastard.
    if (empty($charname))
    {
    	die("No shit.");
    }
    
    //Let us get the CID.
    
    $query = odbc_exec($connect,"SELECT CID FROM Character WHERE Name = '$charname'");
    $count = num_rows($query);
    
    //Charname doesn't exist into the table or does exist multiple times.
    if ($count != 0)
    {
    	die("Shit happened or you can't type.");
    }
    
    odbc_fetch_row($query);
    $CID = odbc_result($query, 1);
    
    //The real part. Edit the ItemID eventually.
    odbc_exec($connect,"INSERT INTO CharacterItem (CID, ItemID) VALUES ('$CID', '50042')");
    echo "$cid<br><br>";
    }
    ?>
    <form action='<?=$_SERVER['PHP_SELF']?>?act=do' method='POST'>
    Text shit goes here.<br><br>
    <table width='250'>
    <tr>
    <td width='50%'><b>Charactername:</b></td>
    <td width='50%'><input type='text' name='charname'></td>
    </tr>
    <tr>
    <td width='50%'></td>
    <td width='50%'><input type='submit' value='Welcome!'></td>
    </tr>
    </table>
    </form>
    <br><br>
    <font size='1'>Made by Wizkid.</font>
    I get this error:
    Dutch:
    Code:
    Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]De INSERT-instructie heeft tot een conflict geleid met de FOREIGN KEY-beperking Character_CharacterItem_FK1. Het conflict is opgetreden in database GunZDB, tabel dbo.Character, column 'CID'., SQL state 23000 in SQLExecDirect in C:\wamp\www\beginner\free2.php on line 87
    translated to english:

    Code:
    Warning: odbc_exec () [function.odbc-exec]: SQL error: [Microsoft] [ODBC SQL Server Driver] [SQL Server] The INSERT statement has led to a conflict with the FOREIGN KEY mitigation Character_CharacterItem_FK1. The conflict occurred in database GunZDB, dbo.Character table, column 'CID'., SQL state 23000 in SQLExecDirect in C: \ WAMP \ www \ beginner \ free2.php on line 87


  2. #2
    Status: Pooping eele is offline
    MemberRank
    Jul 2008 Join Date
    The NetherlandsLocation
    915Posts

    Re: add item on the site

    ligt aan je database of een fout bij de insert statement in het PHP Script.
    [mod] Speak English [/mod]
    Last edited by Rotana; 26-11-08 at 07:01 PM.

  3. #3
    Account Upgraded | Title Enabled! 00niels00 is offline
    MemberRank
    Sep 2008 Join Date
    The NetherlandsLocation
    1,041Posts

    Re: add item on the site

    beetje precieser aub
    [mod] Speak English [/mod]
    Last edited by Rotana; 26-11-08 at 07:01 PM.

  4. #4
    Status: Pooping eele is offline
    MemberRank
    Jul 2008 Join Date
    The NetherlandsLocation
    915Posts

    Re: add item on the site

    tabel dbo.Character, column 'CID' Lees de Error.

    odbc_exec($connect,"INSERT INTO CharacterItem (CID, ItemID) VALUES ('$CID', '50042')");
    FF kijke weet niet precies hoe je het moet fixe xD maarjah zal vast niet supermoeilijk zijn:P
    [mod] Speak English [/mod]
    Last edited by Rotana; 26-11-08 at 07:01 PM.

  5. #5
    Account Upgraded | Title Enabled! 00niels00 is offline
    MemberRank
    Sep 2008 Join Date
    The NetherlandsLocation
    1,041Posts

    Re: add item on the site

    I have tryed it again but now i get error "Shit happened or you can't type."
    But i typ it right

  6. #6
    Account Upgraded | Title Enabled! 00niels00 is offline
    MemberRank
    Sep 2008 Join Date
    The NetherlandsLocation
    1,041Posts

    Re: add item on the site

    <bump> sorry for bump but i really need help.

  7. #7
    Unleashed jumparound is offline
    MemberRank
    Feb 2008 Join Date
    UtrechtLocation
    499Posts

    Re: add item on the site

    i help bumping you, but speak english next time even when youre both dutch.

  8. #8
    Account Upgraded | Title Enabled! 00niels00 is offline
    MemberRank
    Sep 2008 Join Date
    The NetherlandsLocation
    1,041Posts

    Re: add item on the site

    translated:
    Eele:It's your datebase er an error in the insert statement.
    Niels: How do you fix it?
    Eele:tabel dbo.Character, column 'CID' Read the Error.

    odbc_exec($connect,"INSERT INTO CharacterItem (CID, ItemID) VALUES ('$CID', '50042')");
    I think this problem is easy.

    This is translated.

    Errors i get:
    Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]De INSERT-instructie heeft tot een conflict geleid met de FOREIGN KEY-beperking Character_CharacterItem_FK1. Het conflict is opgetreden in database GunZDB, tabel dbo.Character, column 'CID'., SQL state 23000 in SQLExecDirect in C:\wamp\www\beginner\free2.php on line 87

    Or

    Shit happend

  9. #9
    Enthusiast .xxx-mikey-xxx. is offline
    MemberRank
    Apr 2007 Join Date
    EarthLocation
    27Posts

    Re: add item on the site

    Ik heb het geprobeerd, Je moet je charachter niet invullen maar je inlog account..

  10. #10
    Unleashed jumparound is offline
    MemberRank
    Feb 2008 Join Date
    UtrechtLocation
    499Posts

    Re: add item on the site

    omg talk english!

  11. #11
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: add item on the site

    Quote Originally Posted by jumparound View Post
    omg talk english!
    His answer wasn't even helpfull in any way.

  12. #12
    Unleashed jumparound is offline
    MemberRank
    Feb 2008 Join Date
    UtrechtLocation
    499Posts

    Re: add item on the site

    well if he talked english at least everyone could see it wasnt the good answer

  13. #13
    Dying for MMORPGs... :( ilovepie is offline
    MemberRank
    Jul 2008 Join Date
    SingaporeLocation
    216Posts

    Re: add item on the site

    Code:
    Warning: odbc_exec () [function.odbc-exec]: SQL error: [Microsoft] [ODBC SQL Server Driver] [SQL Server] The INSERT statement has led to a conflict with the FOREIGN KEY mitigation 
    Character_CharacterItem_FK1. The conflict occurred in database GunZDB, dbo.Character table, column 'CID'., SQL state 23000 in SQLExecDirect in C: \ WAMP \ www \ beginner \ free2.php on 
    line 87

    Hope the picture helps...
    Attached Thumbnails Attached Thumbnails 2.jpg  



Advertisement