One problem I have now which I can't find any advice on it is converting a string into a multidimensional array. Below is my code and how I want it to work...
public string queryServerURI(string uri)
{
WebClient wc = new WebClient();
byte[] data =
wc.DownloadData("http://***.***.**.*/*****/adminconsole.php?user=" + username + "&pass=" + password + uri);
string response = Encoding.ASCII.GetString(data);
return response;
}
(username + password are declared previously in the code)
This first bit of code is my server query method, the PHP page it's pulling a string from works fine and returns data how needed. I call this function like so (for the problem)...
queryServerURI("&query=SELECT%S*%SFROM%SUsers);
The PHP script then returns...
19%FKruithne%Fcensored%Fcensored%Fcensored%F1%F1%F0%F32777%F1%F0%F%F500%F0%F0%F1%F%F#00FF00%F#0000FF%F%F%F0%F%R20%FBoogers%Fcensored%Fcensored%Ftest@test.com%F0%F%F%F0%F0%F0%F%F0%F0%F0%F0%F%F#00FF00%F#0000FF%F%F%F0%F%R21%FTester%Fcensored%Fcensored%Ftest2@hotm.com%F0%F%F%F0%F0%F0%F%F0%F0%F0%F0%F%F#00FF00%F#0000FF%F%F%F0%F%R22%FTesterzx%Fcensored%Fcensored%Ftest3@hotm.com%F0%F%F%F0%F0%F0%F%F0%F0%F0%F0%F%F#00FF00%F#0000FF%F%F%F0%F%R23%FTestex%Fcensored%Fcensored%Ftest43@hotm.com%F0%F%F%F0%F0%F0%F%F0%F0%F0%F0%F%F#00FF00%F#0000FF%F%F%F0%F
%F = divides fields
%R = divides rows
Table has 23 cols and 5 rows.
The way I have tried to get this to work is by splitting the rows into a normal array ...
string response = queryServerURI("&query=SELECT%S*%SFROM%SUsers);
string[] rows = Regex.Split(response, "%R");
As far as I can see this does not work and I'm unsure why/how to check. I tried to print rows[0] into a text field and nothing happened.
The below code is just a rough plan of what I am trying to achieve with the entire thing but I am very unsure of how to set this out and what to use.
string response = queryServerURI("&query=SELECT%S*%SFROM%SUsers);
string[] rows = Regex.Split(response, "%R"); // splits rows into normal array
string[,] results; // creates multidimensional array to hold it all
foreach(string row in rows) // gets the non-split fields for each array ...
{
string[] fields = Regex.Split(row, "%F"); // makes normal array with the fields
fields.CopyTo(results, 0); // this is where im lost(er) .. want to apply the fields to the multid array so it's like {{fields},{fields},{fields}}
// something like results = new string[,]{ fields } dosn't work either.
}
If anyone could help me out or point me in the right direction of a code to make what i'm trying to achieve easier I would be really grateful! If you need anymore information about my code please ask below. Thanks in advance!

New Topic/Question
Reply




MultiQuote





|