MsSQL Database selection through PHP
I'm trying to select the m_Inventory string from INVENTORY_TBL but when I use this code:
Code:
$query = mssql_query("SELECT m_Inventory FROM [CHARACTER_01_DBF].dbo.[INVENTORY_TBL] WHERE m_idPlayer='000000ID'");
$fetch = mssql_fetch_row($query);
$result = $fetch[0];
echo $result;
It only returns a part of the full string... I'm not sure how much exactly, I'll add that once I get home.
Does anyone know how I can get the full string fron the Database?
Thanks in advance.
Posted via Mobile Device
Re: MsSQL Database selection through PHP
PHP Code:
$query = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[INVENTORY_TBL] WHERE m_idPlayer='000000ID'");
$result = mssql_fetch_array($query);
echo $result['m_Inventory'];
Try this.
Re: MsSQL Database selection through PHP
Quote:
Originally Posted by
Sedrika
PHP Code:
$query = mssql_query("SELECT * FROM [CHARACTER_01_DBF].dbo.[INVENTORY_TBL] WHERE m_idPlayer='000000ID'");
$result = mssql_fetch_array($query);
echo $result['m_Inventory'];
Try this.
that would get every field. the only problem with his original code, is that he did mssql_fetch_row when it should have been mssql_fetch_array. that simple change should fix it.
Re: MsSQL Database selection through PHP
I typed that from my iPhone so I couldn't really check what I really had.
I don't need every field from that table, I only need the m_Inventory field.
I can successfully get the value of that field, but it does not display the FULL string which is stored in the table, only a part of it.
So basically something like this is stored in m_Inventory:
Code:
0,1242,0,0,0,02502,5025,205,02,562501,0,0,120,0,0,0,0/1,24262,24256,21
,36735,46,236,360,30,60,0,0,0,0,0,0,0/2,0252,62,36,7490,0,0,,,0,0,0,0
,740,0/9,0,0,36,306,163,7340,0,0,0,0,0,,0,0,0,,0/$
But when I retrieve it from the DB using PHP it only displays several characters from the full string, so something like this:
Code:
0,1242,0,0,0,02502,5025,205,02,562501,0,0,120,0,0,0,0/1,24262,24256,21,36735
,46,236,360,30,60,0,0,0,0,0,0,0/2,0252,62,36,7490,0
It does show the correct string for the correct player, but not everything :glare:
It only returns 255 characters of the full string, is there any way to go around this limit?
Re: MsSQL Database selection through PHP
i had to google search for this one cause i didn't know about that 255 char limit.
Read through this link some: Getting around the 255 Char limit with MSSQL
I get 2 options from that.
1. use this: SELECT CAST(MyVarCharField AS TEXT) FROM MyTable
the 255 char limit is on the VARCHAR type. casting it as TEXT type will get around that limit, but at the cost of lower performance.
2. The 255 char limit is caused by the php_mssql.dll driver. You could switch to using an ODBC connection, but since I have no experience with this, I don't know how. All I do know, is it can be used very similarly in PHP. (ex. instead of mssql_connect it's odbc_connect)
Re: MsSQL Database selection through PHP
In the database it showed that the m_Inventory field had a max-length of 6000 so I thought it wasn't that. Well, thanks for helping out, it works now :)
Posted via Mobile Device
Re: MsSQL Database selection through PHP
what I meant is that 255 char limit is caused when the php_mssql.dll driver attempts to retrieve varchar type data. obviously it doesn't have that limit on TEXT type