Jump to content

Explanation why this error is occurring.


Carlton

Recommended Posts

I'm getting a strange error for this code, but i'm unable to find out what's wrong, the error is below:

 

Parse error: parse error, expecting `'&'' or `T_VARIABLE' in  on line 12

 

Here's the code:

 


function CMySQL_Create($Username, $Password, bool:$md5 = true) {
switch($md5) {
	case false: {
		mysql_query("INSERT INTO " . $ACCOUNT_TABLE . " (" . $USERNAME_FIELD . ", " . $PASSWORD_FIELD . ") VALUES('" . mysql_real_escape_string($Username) . "', '" . mysql_real_escape_string($Password) . "')") or die(mysql_error());
	}
	case true: {
		mysql_query("INSERT INTO " . $ACCOUNT_TABLE . " (" . $USERNAME_FIELD . ", " . $PASSWORD_FIELD . ") VALUES('" . mysql_real_escape_string($Username) . "', md5('" . mysql_real_escape_string($Password) . "'))") or die(mysql_error());	
	}
}
}

 

The line of this error is:

 

function CMySQL_Create($Username, $Password, bool:$md5 = true) {

 

Any clue?

Link to comment
https://forums.phpfreaks.com/topic/211320-explanation-why-this-error-is-occurring/
Share on other sites

Sorry, short reply at first.  If you want to force it boolean then type cast and use something like:

 

switch( (bool) $MD5 ) {

 

Or throw an exception and use something like:

 

if(!is_bool($MD5)) { throw new Exception('Parameter three must be boolean!'); }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.