3

I have created the following snippet in sublime text 2 but when I use it within a Php script it automatically removes all variables(not their values).

<snippet>
<content><![CDATA[

include 'constants.php';

// Defining connection

$connection = mysqli_connect(HOST, USERNAME, PASSWORD);

// If unable to connect

if(!$connection)
{
$error = 'Unable to connect to database server';
echo $error;
exit();
}

// Checking the encoding

if(!mysqli_set_charset($connection, 'utf8'))
{
$error =  'Unable to set database connection decoding';
echo $error;
exit();
}

// Selecting Database

if (!mysqli_select_db($connection, DATABASE))
{
$error = 'Unable to locate the .'. DATABASE;    
echo $error;    
exit();
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>phpMysqlConnection</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.php</scope> -->
</snippet>

Whats really happening ?

1
  • removes all '$connection' and '$error' variables Commented Aug 8, 2012 at 14:10

2 Answers 2

21

You need to escape each "$" with a backslash "\".

\$error;
Sign up to request clarification or add additional context in comments.

Comments

3

Put a \ character infront of variables, since sublime text used the $ sign for placeholders.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.