MySQL Integration Error

Hey guys. I am using Smartfox for a server and I wanted to have a MySQL database hold the user information, and so I figured that the best place for a test of that connection would be the login, right? Anyways, I get coding errors just trying to run the program.

Here is the end of the editor file:

-----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/1427772902f551d45840abc7dca4abec.dll

Compilation failed: 8 error(s), 0 warnings

-----CompilerOutput:-stderr----------

Assets/Game/Scripts/LoginGUI.cs(97,48): error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='

Assets/Game/Scripts/LoginGUI.cs(131,22): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration

Assets/Game/Scripts/LoginGUI.cs(132,34): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration

Assets/Game/Scripts/LoginGUI.cs(132,45): error CS1519: Unexpected symbol `10' in class, struct, or interface member declaration

Assets/Game/Scripts/LoginGUI.cs(133,34): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration

Assets/Game/Scripts/LoginGUI.cs(133,45): error CS1519: Unexpected symbol `10' in class, struct, or interface member declaration

Assets/Game/Scripts/LoginGUI.cs(133,81): error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration

Assets/Game/Scripts/LoginGUI.cs(136,9): error CS8025: Parsing error

-----EndCompilerOutput---------------

- Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
Assets/Game/Scripts/LoginGUI.cs(97,48): error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `='
 
(Filename: Assets/Game/Scripts/LoginGUI.cs Line: 97)

Assets/Game/Scripts/LoginGUI.cs(131,22): error CS1519: Unexpected symbol `else' in class, struct, or interface member declaration
 
(Filename: Assets/Game/Scripts/LoginGUI.cs Line: 131)

Assets/Game/Scripts/LoginGUI.cs(132,34): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
 
(Filename: Assets/Game/Scripts/LoginGUI.cs Line: 132)

Assets/Game/Scripts/LoginGUI.cs(132,45): error CS1519: Unexpected symbol `10' in class, struct, or interface member declaration
 
(Filename: Assets/Game/Scripts/LoginGUI.cs Line: 132)

Assets/Game/Scripts/LoginGUI.cs(133,34): error CS1519: Unexpected symbol `(' in class, struct, or interface member declaration
 
(Filename: Assets/Game/Scripts/LoginGUI.cs Line: 133)

And here is the Code:

using UnityEngine;
using System;
using System.Collections;
using SmartFoxClientAPI;
using SmartFoxClientAPI.Data;
using SmartFoxClientAPI.Util;
using System.Data.SqlClient;

public class LoginGUI : MonoBehaviour {
	private SmartFoxClient smartFox;
	private bool shuttingDown = false;

	private string serverIP = "69.166.66.75";
	private string serverPort = "9339";
	public string zone = "simpleChat";
	public bool debug = true;

	public GUISkin gSkin;

	private string username = "";
	private string loginErrorMessage = "";

	/************
     * Unity callback methods
     ************/

	void OnApplicationQuit() {
		shuttingDown = true;
	}

	private bool connectionAttempt = false;

	
	//
	
	
	
	//
	void Awake() {
		Application.runInBackground = true;

		if ( SmartFox.IsInitialized() ) {
			smartFox = SmartFox.Connection;
		} else {
			try {
				smartFox = new SmartFoxClient(debug);
				smartFox.runInQueueMode = true;
			} catch ( Exception e ) {
				loginErrorMessage = e.ToString();
			}
		}

		// Register callback delegate
		SFSEvent.onConnection += OnConnection;
		SFSEvent.onConnectionLost += OnConnectionLost;
		SFSEvent.onLogin += OnLogin;
		SFSEvent.onRoomListUpdate += OnRoomList;
		SFSEvent.onDebugMessage += OnDebugMessage;

	}
	
	void FixedUpdate() {
		smartFox.ProcessEventQueue();
	}

	void OnGUI() {

		GUI.skin = gSkin;
		GUI.Label(new Rect(2, -2, 680, 70), "", "SFSLogo");	
		//connectionAttempt = true;
	//smartFox.Connect(serverIP, Convert.ToInt32(serverPort));

		if (!connectionAttempt) {
			GUI.Label(new Rect(10, 116, 100, 100), "IP: ");
			serverIP = GUI.TextField(new Rect(100, 116, 200, 20), serverIP, 25);
			
			GUI.Label(new Rect(10, 136, 100, 100), "Port: ");
			serverPort = GUI.TextField(new Rect(100, 136, 200, 20), serverPort, 25);
			
			if (GUI.Button(new Rect(100, 166, 100, 24), "Connect")  || (Event.current.type == EventType.keyDown  Event.current.character == '\n')) {
				connectionAttempt = true;
				smartFox.Connect(serverIP, Convert.ToInt32(serverPort));
			}
		
		}
		else if (smartFox.IsConnected()) {
			// Login
			GUI.Label(new Rect(10, 116, 100, 100), "Username: ");
			username = GUI.TextField(new Rect(100, 116, 200, 20), username, 25);
			
			GUI.Label(new Rect(10, 116, 100, 140), "Password: ");
			password = GUI.TextField(new Rect(100, 116, 200, 80), password, 25);

			GUI.Label(new Rect(10, 218, 100, 100), loginErrorMessage);

			if ( GUI.Button(new Rect(100, 166, 100, 24), "Login")  || (Event.current.type == EventType.keyDown  Event.current.character == '\n'  username != ""  password != "")) {
				function Start () {
					//Connects to the MySQL Database
					var dbcon = IDbConnection;
					var connectionString = String =
						"Server=http://64.120.203.67;" +
						"Database=outbr144_neill;" +
						"User ID=outbr144_client;" +
						"Password=asd123;";
					dbcon = new SqlConnection(connectionString);
					dbcon.Open();
					
					//Pulls the password on file with the database
					var dbcmd = IDbCommand = dbcon .CreateCommand();
					var cmdSQL = String = "SELECT pass FROM outbr144_neill.accounts WHERE user= username";
					dbcmd.CommandText = cmdSQL;
					var reader = IDataReader = dbcmd.ExecuteReader();
					
					//turn the column we now have into a string
					while(reader .Read()) {
						var mypass = String = reader ["pass"].ToString();
						
					}	
				
				
				//Checks that the user has typed in the correct password
					if(password = mypass) {
						smartFox.Login(zone, username, "");
					}
					else {
						GUI.Label(new Rect(10, 150, 100, 100), loginErrorMessage);
					}
				}
			}

		} else {
			GUI.Label(new Rect(10, 150, 100, 100), "Waiting for connection");
			GUI.Label(new Rect(10, 218, 100, 100), loginErrorMessage);
			}
		
	}

	/************
	 * Helper methods
	 ************/

	private void UnregisterSFSSceneCallbacks() {
		// This should be called when switching scenes, so callbacks from the backend do not trigger code in this scene
		SFSEvent.onConnection -= OnConnection;
		SFSEvent.onConnectionLost -= OnConnectionLost;
		SFSEvent.onLogin -= OnLogin;
		SFSEvent.onRoomListUpdate -= OnRoomList;
		SFSEvent.onDebugMessage -= OnDebugMessage;
	}

	/************
	 * Callbacks from the SFS API
	 ************/

	void OnConnection(bool success, string error) {
		if ( success ) {
			SmartFox.Connection = smartFox;
		} else {
			loginErrorMessage = error;
		}
	}

	void OnConnectionLost() {
		loginErrorMessage = "Connection lost / no connection to server";
	}

	public void OnDebugMessage(string message) {
		Debug.Log("[SFS DEBUG] " + message);
	}

	public void OnLogin(bool success, string name, string error) {
		if ( success ) {
			// Lets wait for the room list

		} else {
			// Login failed - lets display the error message sent to us
			loginErrorMessage = error;
		}
	}

	void OnRoomList(Hashtable roomList) {
		// When room list is updated we are ready to move on to the island
		UnregisterSFSSceneCallbacks();
		Application.LoadLevel("Room_1");
	}
}

Help? Thanks a lot.
-Sudo.

Its just some syntax errors…in line 97 you wrote “function Start () {” wich is the way you declare methods in js not in C#. I recommend that you declare the connection and setting up of the database outside the OnGUI event.

Also I’m not so sure if this “var connectionString = String =” works in C#, using just “var connectionString” should by fine.