1
votes

Hello all i have coded following Program to secure the application. But after executing , i am getting following error Check here PHP code

http://pastebin.com/cgG5ezeg

Output :

Deprecated: Function sql_regcase() is deprecated in /home/admin/public_html/test/protect.php on line 6

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'root'@'localhost' (using password: NO) in /home/admin/public_html/test/protect.php on line 9

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/admin/public_html/test/protect.php on line 9

As well as please suggest me more secure way !

Thanks in advance

2
Please, don't use mysql_* functions to write new code. They are no longer maintained and the community has begun deprecation process. See the red box? Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide which, this article will help you. If you pick PDO, here is good tutorial. Also see Why shouldn't I use mysql functions in PHP? - NullPoiиteя

2 Answers

1
votes

regarding the sql_regcase function: it was deprecated in PHP V5.3.0 and shouldn't be used any longer.

Look at the PCRE extension.

note: use of mysql_* function is deprecated too so use pdo or mysqli

0
votes

Don't use deprecated functions.

The second warning is due to database connection failure. You had set "no" in the place of database password. change this and give your database password. it will work.