How to edit inventory through PHP?

Results 1 to 2 of 2
  1. #1
    Member ndrhk is offline
    MemberRank
    Jun 2011 Join Date
    62Posts

    sad How to edit inventory through PHP?

    I made a few codes, but i am not able to edit the database at all...

    What i made:

    string1 = mssql_fetch_row(mssql_query("select inventory from Character where Name=...."));

    Ok, so it returned me an unreadable code, so i've conveted it to hex using:

    $string2 = bin2hex($string1[0]);

    That returned me a code exactly like when we request it by the query analiser.

    So i manage all the string, separating it in sections, editing the area i want and then put it all back togheter.
    Until here everything is fine. (I've already check this hex code and it is they way that i want)

    My main problem its to put this all back to the database, i already have the final hex code and i need to place it back in the inventory table, how can do it?

    Things i tried:

    [With strings]
    - $string4 = bin2hex($string3); (converting back to binary)
    - $string4 = pack('H*hex', $string3);
    - using the normal hex string ($string3)

    [With the query]
    - using this command: (convert(varbinary(1728),$string3~4) -> (actually i dont know if its 1728 bytes, and i dont know how to look how many bytes it is, im using IA JULIA Season 4)
    mssql_query("UPDATE Character set Inventory=convert(varbinary(1728),$string4) where Name=...");
    - using the normal command:
    mssql_query("UPDATE Character set Inventory=$string3~4 where Name=...");

    The only time i was "successful" into inserting it to the database, it became a code like 0x64646464... and not the hex code i was using.

    Please help me.
    Thanks.

    PS: I've searched on the database and found that the inventory has 1728 bytes, and its varbinary. (I was not sure before)
    Last edited by ndrhk; 02-11-15 at 10:26 PM.


  2. #2
    Member ndrhk is offline
    MemberRank
    Jun 2011 Join Date
    62Posts

    Re: How to edit inventory through PHP?

    Problem solved :)

    For anyone who wants to try it, just forget about this (convert(varbinary(1728) thing... That isnt necessary at all...

    Just insert the normal hex code, but dont forget the "0x", like:

    mssql_query("UPDATE Character set Inventory=$string4 where Name=...");
    being $string4 = "0x".$stringwithyourfinalhexcode;



Advertisement