-2

Possible Duplicate:
Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in PHP

Hello I am trying to design a web page in php to implement session and concept like login and logout.Below is my basic code.

<?php    
session_start();    
$host = "localhost";    
$username = "USERNAME";    
$password = "PASSWORD";    
$db = "test";    
@mysql_connect($host,$username,$password) or die ("error");    
@mysql_select_db($db) or die("error");    
?> 

I am getting an error as unexpected_T_CONSTANT_ENCAPSED_STRING on line 3.Please help to remove this error.Is it anything wrong with SOL injection ?

Community
  • 1
  • 1
prakash_d22
  • 1,153
  • 5
  • 21
  • 34

1 Answers1

0

First of all you should stop using MYSQL extension as it is going to be deprecated soon. Instead you should be looking into other alternatives which are rich and safer such as MySQLi or PDO_MySQL.

Check mysql_real_escape_string

As found in above page:

This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be

used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:

    mysqli_real_escape_string()
    PDO::quote()
Ghazanfar Mir
  • 3,493
  • 2
  • 26
  • 42