hey gang ): error CS0029: Cannot implicitly convert type `void' to `string'

hey gang was messing around watching tutorials and stuff on mysql and trying to display my data from a database but I’m running into:

): error CS0029: Cannot implicitly convert type void' to string’
Lines 68-91

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Logincheck : MonoBehaviour {

	public string StatsURL = "http://gmame/stats.php";
	public string Username = "";
	public string[] items;
	public Text User;

	public string SG;
	public string Xp;
	public string RS;
	public string LVL;
	public string Ship01;
	public string Ship02;
	public string Ship03;
	public string Ship04;
	public string Ship05;
	public string Ship06;

	public string Ship001;
	public string Ship002;

	public string Ship0001;
	public string Ship0002;
	public string Ship0003;
	public string Ship0004;

	public string Ship00001;
	public string Ship00002;

	public string Ship000001;
	public string Ship000002;
	public string Ship000003;
	public string Ship000004;

	public string SkillsA01;
	public string SkillsA02;
	public string SkillsA03;
	public string SkillsA04;
	public string SkillsA05;

	public string SkillsR01;
	public string SkillsR02;
	public string SkillsR03;
	public string SkillsR04;
	public string SkillsR05;

	public void LoginButton(){
		Username = User.text.ToString ();

	IEnumerator  LogintoDB(string Username, string Password){
		WWWForm form = new WWWForm ();
		form.AddField ("usernamepost", Username);
		WWW www = new WWW(StatsURL, form);
		yield return www;
		string Itemsdata = www.text;
		print (Itemsdata);
		items = Itemsdata.Split(';');

		Username = GetDataValue(items[1], "Username");
		SG = GetDataValue(items[3], "SG");
		Xp = GetDataValue(items[4], "XP");
		RS = GetDataValue(items[5], "RS");

		Ship01 = GetDataValue(items[6], "Ship01");
		Ship02 = GetDataValue(items[7], "Ship02");
		Ship03 = GetDataValue(items[8], "Ship03");
		Ship04 = GetDataValue(items[9], "Ship04");
		Ship05 = GetDataValue(items[10], "Ship05");
		Ship06 = GetDataValue(items[11], "Ship06");

		Ship001 = GetDataValue(items[12], "Ship001");
		Ship002 = GetDataValue(items[13], "Ship002");

		Ship0001 = GetDataValue(items[14], "Ship0001");
		Ship0002 = GetDataValue(items[15], "Ship0002");

		Ship00001 = GetDataValue(items[16], "Ship00001");
		Ship00002 = GetDataValue(items[17], "Ship00002");

		Ship000001 = GetDataValue(items[18], "Ship0000001");
		Ship000002 = GetDataValue(items[19], "Ship0000002");
		Ship000003 = GetDataValue(items[20], "Ship0000003");

	void GetDataValue (string data, string index){
		string value = data.Substring(data.IndexOf(index)+index.Length);
		if(value.Contains("|"))value = value.Remove(value.IndexOf("|"));
		return value;


void GetDataValue (string data, string index)
should be

string GetDataValue (string data, string index)

On line 95 change the “void” to “string”.

This error happens because your method is of type void and isn’t supposed to return a value although your intention is to return a string.

The void field means that the method doesn’t return anything.

To let the method return a type of variable (in this case a string but it counts for any variable type even your own variable types) you swap the void for the variable type (in this case string).