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);

Edited by timothyarden
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.