Jump to content

Parse error: syntax error, unexpected '$error' (T_VARIABLE) in... on line 30


timothyarden

Recommended Posts

Hi Everyone,

This should just be a quick fix but I can't find what I have done wrong - Parse error: syntax error, unexpected '$error' (T_VARIABLE) in... on line 30.

 

Here is the code

class database_action {
function __construct($value, $ssl = false){
$mysql_credentials = array('host' => "localhost", 'database_username' => "root", 'database_password' => "", 'database_name' => "test", 'table_name' => "test");

// New MySQLi Connection Object
if(isset($ssl) && $ssl == true){ $mysqli = new mysqli("https://".$mysql_credentials['host'],$mysql_credentials['database_username'],$mysql_credentials['database_password'],$mysql_credentials['database_name']); } else { $mysqli = new mysqli($mysql_credentials['host'],$mysql_credentials['database_username'],$mysql_credentials['database_password'],$mysql_credentials['database_name']); }

// Check for MySQLi Error
if($mysqli -> connect_error()){ exit('MySQL Connection Error: ('.$mysqli -> connect_errno().')'.$mysqli -> connect_error()); $error = $mysqli -> connect_errno().' - '.$mysqli -> connect_error(); }

// MySQLi Query
$sql_statement = $mysqli -> stmt_init();
if($sql_statement = $mysqli -> prepare('INSERT INTO test VALUES(`?`)')){
$sql_statement -> bind_param('s',$value);
$sql_statement -> execute();

if(isset($sql_statement -> $error) || isset($sql_statement -> $errno)){
$sql_error = $sql_statement -> $errno.' - '.$sql_statement -> $error;
}

$sql_statement -> close();
} else {
$sql_error = $sql_statement -> $errno.' - '.$sql_statement -> $error;
}

$mysqli -> close();

// Return $errors or $sql_error if set otherwise return success
if(isset($this -> $error)){ return $this -> $error; } elseif(isset($this -> $sql_error)){ return $this -> $sql_$error } else { return true; }
}
}

 

Thanks,

Timothy

 

$value = 'test';

new database_action($value);

Thanks for the reply.

 

Yes I can, its just in my editor - Notepad ++ it is all indented. However when I copy across the clip-boarded code it is all un-indented. If I then try to indent it in the editor here on phpfreaks when I post it it it shows up as

- which is even worse.

 

Figured out the problem before though - and so marked it solved.
:)

 

Timothy

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.