Question by
playbarbados · Jan 08, 2016 at 04:02 PM ·
wwwwwwformwww.texturewww.error
How to get image from server folder through its reference in mysql database
Hi everyon.. here is my setup and problem.. I have a website that users can register and upload their avatar to. I have a unity app that is hooked to the websites database (mysql).
I am trying to retrieve the users avatar from my website folder by accessing its reference (filename in jpg) in the database. I am already familiar with retrieving an image directly from [the example giving in the unity docs][1]...
When i hit play in unity... the texture of the object I wish to apply the avatar to shows up with a question mark...
Here is my unity code:
using UnityEngine;
using System.Collections;
// Get the latest webcam shot from outside "Friday's" in Times Square
public class loadface : MonoBehaviour {
public string LoadFacePHP_URL = "http://www.mysite.com/unity/bl_LoadAvatar.php";
public string m_UserName = "";
IEnumerator Start() {
WWWForm mForm = new WWWForm();
m_UserName = GameObject.Find("PlayerInfo").GetComponent<bl_SaveInfo>().m_UserName;
mForm.AddField("username", m_UserName);
WWW www = new WWW(LoadFacePHP_URL, mForm);
Debug.Log("Processing...");
yield return www ;
// assign texture
Renderer renderer = GetComponent<Renderer>();
renderer.material.mainTexture = www.texture;
}
}
Here is my php code:
<?php
include("bl_Common.php");
$link=dbConnect();
$name = $_POST['name'];
$check = mysql_query("SELECT `user_picture` FROM users WHERE `user_name` ='$name' ") or die(mysql_error());
while($image = mysql_query($check))
{
echo '<img src="http://www.mysite.com/content/uploads/'.$image.' "> ';
}
mysql_close($link);
?>
I'd really appreciate any help pointing in the right direction...
Comment