开发者

error while using mysql_real_escape_string()

my code-

require 'database.php';

$title = mysql_real_escape_string($_POST['title']);  //line 48
$cat = $_POST['cat'];
$txtart = mysql_real_escape_string($_POST['artbody']); //line 50
$date = date("d-m-y");

$q = "INSERT INTO tblarticle (art_title, art_cat, art_des, art_date) VALUES ('$title', '$cat', '$txtart', '$date')";

ERROR-->

Warning: mysql_real_escape_string() [function.mysql-real-escape-stri开发者_StackOverflow中文版ng]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\shizin\admin\newArticle.php on line 48

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\shizin\admin\newArticle.php on line 48

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\shizin\admin\newArticle.php on line 50

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\shizin\admin\newArticle.php on line 50

But data is getting saved in DB but null titile and artbody fields


mysql_real_escape_string tries to connect to the local database, so it can fetch the settings it needs to escape the string correctly for that system.

You can tell the function which connection to use by passing in a link identifier as a second argument:

mysql_real_escape_string($string, $link)


Please check your MySQL username and password and make sure you're entering them properly in mysql_connect. According to the error you didn't run mysql_connect with a password, which may be causing these problems.


Check database.php connection strings, and the MySQL server is running as mysql_real_escape_string needs a valid open database connection to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜