-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 ?

4

1 回答 1

0

首先你应该停止使用MYSQL扩展,因为它很快就会被弃用。相反,您应该寻找其他更丰富且更安全的替代方案,例如MySQLior PDO_MySQL

检查mysql_real_escape_string

如上页所示:

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

用过的。另请参阅 MySQL:选择 API 指南和相关的常见问题解答以获取更多信息。此功能的替代方案包括:

    mysqli_real_escape_string()
    PDO::quote()
于 2012-12-16T11:24:21.443 回答