I have done a sample to insert and retrieve data from MySQL in unity.Now I need to insert and retrieve image from MYSQL in unity. The images are files selected by the user from their filesystem.
Can anybody please help me?
Below is the sample code for inserting data
<?php
$database = mysql_connect('localhost', 'root', 'amma') or die('Failed to connect: ' . mysql_error());
mysql_select_db('igrms_db') or die('Failed to access database');
$query="INSERT INTO igrmsdata(id,name,description) VALUES('$id','$name','$description');";
//$query="INSERT INTO igrmsdata(id,name,description) VALUES('100','Tippu','Welcome to Tippu');";
$result=mysql_query($query);
echo "DataEntered";
?>
Unity code for inserting data
string IGRMSDataEntryCode="http://192.168.173.243/IGRMSDataEntry.php";
public InputField artifactidField;
public InputField artifactnameField;
public InputField artifactdescriptionField;
public Text messagebox;
public static string artifactid="";
public static string artifactname="";
public static string artifactdescription="";
void Start () {
}
// Update is called once per frame
void Update () {
}
public void IGRMSDataEntryDetailsDB()
{
artifactid=artifactidField.text;
artifactname=artifactnameField.text;
artifactdescription=artifactdescriptionField.text;
if(artifactidField.text=="" || artifactnameField.text=="" || artifactdescriptionField.text=="")
{
messagebox.text="All fields are mandatory";
}
else {
StartCoroutine(AddArtifacts(artifactid,artifactname,artifactdescription));
}
}
public void IGRMSDataReset()
{
artifactidField.text="";
artifactnameField.text="";
artifactdescriptionField.text="";
messagebox.text="";
}
IEnumerator AddArtifacts(string id,string name,string description)
{
//string register_url = getscoreCode + "?name=" + user + "&score=" + scor;
string register_url = IGRMSDataEntryCode + "?id=" + id + "&name=" + WWW.EscapeURL(name) + "&description=" + WWW.EscapeURL(description);
WWW entereddata = new WWW (register_url);
yield return entereddata;
messagebox.text="Data Uploaded Successfully";
artifactidField.text="";
artifactnameField.text="";
artifactdescriptionField.text="";
}