Problems with IEnumerator

Hi,
I am trying to post and retrieve data from a mysql database, I am doing this using php rather than connecting to mysql directly through unity because I think I read that it is more secure to do it this way so my first question is is that true because I would prefer to just use unity?

My second question is a problem with having 2 IEnumerator in the same script, here is my script:

using UnityEngine;
using System.Collections;

public class DatabaseManager : MonoBehaviour {
	string postDataURL = "http://localhost/postPosition.php";
    string retrieveDataURL = "http://localhost/retrievePosition.php";
	
	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	public IEnumerator PostPosition()
    {
		WWW post = new WWW(postDataURL);
        yield return post;
 
        if (post.error != null)
        {
            Debug.Log("There was an error posting the building positions: " + post.error);
        }
		else {
			Debug.Log("Post");
		}
    }
	
	public IEnumerator RetrievePosition()
    {
		WWW retrieve = new WWW(retrieveDataURL);
        yield return retrieve;
 
        if (retrieve.error != null)
        {
            print("There was an error retrieving the building positions: " + retrieve.error);
        }
		else {
			Debug.Log("Retrieve");
		}
    }
}

this script works if I call either IEnumerator from the start method:

// Use this for initialization
void Start () {
	StartCoroutine(PostPosition());	
}

but I run into problems if I call them from another script:

// Use this for initialization
void Start () {
DatabaseManager dbScript = GameObject.Find("DatabaseManager").GetComponent<DatabaseManager>();
		
StartCoroutine(dbScript.RetrievePosition());
}

I get the following error:

There was an error getting the post positions: <url> malformed
UnityEngine.MonoBehaviour:print(Object)

Can anybody explain why this is happening?

Also If I split the two IEnumerator into 2 scripts and call them from their respective script it works but I was wanting all database connections in one script

Thanks

odd error, there is a very simple workaround for it. Simply make a method in the DatabaseManager that starts the coroutine, and call that method, not the coroutine.

You can also use this method to set and move objects in the scene as a byproduct. DoRetrievePosition(gameObject); // this would use the name of the gameObject in the coroutine, get its position and then could be used to set its position later to the database position.

Thanks, that has solved my problem and is probably a better way of doing it.