Loading an image from a blob stored in a database

I’m trying to load an image from my database and display it on an image in the current scene. I echo the blob from the database as a byte array and I can see the byte array displayed in my Unity Debugging. When I use that byte array to initialize an image however, I get a red question mark on a white background. I think this means that the image can’t be found. I’m not sure where to go from here though. First, here is the php code for retrieving the image.

	$name= $_POST["namePost"];


//make a connection
$connection = new mysqli($servername, $username, $password, $dbName);

//Check the connection
if(!$connection)
{
	die("Connection Failed".mysqli_connect_error());
}

$sql = "SELECT level, lastgame, gameswon, kills, deaths, score, picture, description FROM Users WHERE username= '".$name."'";
$result = mysqli_query($connection, $sql);

if(mysqli_num_rows($result)){
	while($row = mysqli_fetch_assoc($result)){
		echo "Level" .$row['level'] . "|LastGame" .$row['lastgame'] . "|GamesWon" .$row['gameswon'] . "|Kills" .$row['kills'] . "|Deaths" .$row['deaths'] . "|Score" .$row['score'] . "|Description" .$row['description'] . "|Picture" .base64_encode($row['picture']) . ';';
	}
}

here is my C# Code for where I take the byte data retrieved and loading into an image.

	Texture2D tex = new Texture2D(256, 256, TextureFormat.RGBA32, false);
	tex.LoadImage(System.Text.Encoding.UTF8.GetBytes(getDataValue(profileData, "Picture")));
	tex.Apply();
	profilePicture.sprite = Sprite.Create(tex, new Rect(0, 0, 8, 8), new Vector2(0f, 0f));

public string getDataValue(string data, string key)
{
	string value = data.Substring(data.IndexOf(key) + key.Length);
	if (value.Contains("|"))
	{
		value = value.Remove(value.IndexOf("|"));
	}
	Debug.Log(value);
	return value;
}

I’d be happy to provide more information if you will just let me know what you need from me. Thanks!

You did base64 encode the image in your php code but you don’t decode it on the Unity side. You can use System.Convert.FromBase64