PDA

View Full Version : Raw_data question


Trumpcard
03-05-2002, 01:23 AM
Hey,
Im building a php tool for admin'ing the database so a remote GM can make db changes on the fly.

One question though about the items data. Ive mapped out the item structs from the code, so when I retrieve the data via a SQL query, I know where in the array the data is at, so I know where and how to mess with the BLOB.

Now, the value that comes through the query looks is an ACSII character.. Do I just convert that ASCII character back to it's numeric representation, and vice versa to insert it back in, or is there anything special that needs to be done with it?

Any help would be appreciated!

DeletedUser
03-05-2002, 01:15 PM
Hey,
Im building a php tool for admin'ing the database so a remote GM can make db changes on the fly.

One question though about the items data. Ive mapped out the item structs from the code, so when I retrieve the data via a SQL query, I know where in the array the data is at, so I know where and how to mess with the BLOB.

Now, the value that comes through the query looks is an ACSII character.. Do I just convert that ASCII character back to it's numeric representation, and vice versa to insert it back in, or is there anything special that needs to be done with it?

Any help would be appreciated!

I can tell you from making a Player profile editor in php for image (checkout http://www.cyberjunky.net/~hogie/), it is possible to read the binary data. Use the unpack() command to do it since all the data is that way. You will also need a function to give you "clean" strings from the string fields (since they are null terminated).... Here is the one I use


function GetNullTermString($string) {
$string2 = "";
for ($i=0;$i<=strlen($string);$i++) {
if (ord(substr($string,$i,1)) == 0)
return $string2;
else
$string2 = $string2.substr($string,$i,1);
}
return $string2;
}


That function will do wonders for your string names.

To insert back in, you would have to pack() each part of the raw_data back and then insert it as 1 long one.

BTW, so you know, item changes will NOT show up until the zone is reloaded (as in, stopped and started again from command line). The same is true with npc_type and such, those are only read once during bootup.

-Hogie

Trumpcard
03-06-2002, 01:19 AM
Very cool ! Thats exactly what I need...

I had tried using unpack before (just too display the blob into column seperated field), but I have a feeling I was screwing something up in the usage.

Since you did it with the character table, I shouldnt have too much trouble doing it for the items/character table. Just need to do my pack()/unpack() homework a bit.

Thanks a ton Hogie!

If you get the chance, mind sending me a snippet of the code you use too display the data once you nab it from the database, that way I will have a practical example of how unpack's used?

I wrote a few general pages/scripts that will display all tables, and allow you too edit them all. . It's general enough that it will pick up any new tables that are added from release to release, without having to add componets or change anything in the configuration.. It basically grabs all the tables out of the database, gives you a view/add/search option for all of them, then formats those operations based on the indivudual table structure. The only ones it doesnt work for are tables that contain blob structs (char. and items only I think).
I was trying to make a framework that was close to myPhpAdmin , but tailored for the eq database, but general and customizable enough I could use for any database. I have quite a few databases that I run, so wanted to make something I could port over to be a tool for any of the others ones without having to rewrite anything.

DeletedUser
03-06-2002, 07:58 AM
Here's basically what I did:



$query = "SELECT profile FROM character_ WHERE name='$pp'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$lastname = GetNulLTermString(substr($row[0],34,20));


That gets the lastname:)

For inventory slots where I used unpack...


array($inventory);
$inventory = unpack("v30slot",substr($row[0],168,60));


That made:


$inventory["slot1"];
$inventory["slot2"];
$inventory["slot3"];
...
$inventory["slot30"];


Hope this helps

Trumpcard
03-06-2002, 08:26 AM
Ahh.. I see... I got it working when unpacking the item names.. My problem is because its null terminated, my loop is bombing out... I see now Im not going to be able to do it gracefully, Im going to have to specify every column by its array position, and build each one of the strings uniquely..

I was hoping I could unpack the entire string, parse through it by null terminators, then seperate each of those values into a parm list, but I think i will probably have to hand wrap it.

Thanks Hogie! I'll give it a shot when i get home and see what I can yank out..

Trumpcard
03-08-2002, 02:29 AM
Hogie,
Do you mind posting the unpack where you nab an attribute value (like Str or Dex or something)

I am having the hardest time yanking out those int8 values...


Thanks

DeletedUser
03-08-2002, 05:46 AM
Actually, I dont think I used unpack for the stats... :P


array($stats);
$stats['str'] = hexdec(bin2hex(substr($row[0],123,1)));
$stats['sta'] = hexdec(bin2hex(substr($row[0],124,1)));
$stats['cha'] = hexdec(bin2hex(substr($row[0],125,1)));
...


Hope that helps (that was before I found out about pack/unpack)

Trumpcard
03-08-2002, 06:49 AM
Another dumb question... The 'str' values inside the array pointer, is that just an enumeration for the location in the array? Just wondering, get T_PARSE errors using it this way, and cant seem to be able to just set

array($stats);
$stats[0]= bin2hex......

DeletedUser
03-08-2002, 07:14 AM
Yeah, they are just enumations for me. Since $stats is an array made by me, I can do whatever I want:)

Are you sure you did ['str'] ? T_Parse is usually due to mismatched "/' or missing ones...

Trumpcard
03-10-2002, 06:07 PM
Duh, Im an idiot... got it working, my syntax was good, but my logic was bad... Thanks for all the help Hogie!

astreyon
04-13-2002, 06:36 AM
sorry guys, but can anyone tell me why this php code , doesn't return anyhting ?



<?
$host = "localhost";
$user = "root";
$pass = "";
$bdd = "EQDB";

mysql_connect($host,$user,$pass)
or die("Impossible de se connecter