Deprecated: mysql_escape_string()

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

help?

PHP:
<?PHP
$idas = mysql_escape_string($_GET['idas']);
 

Raggaer

Godly Member
Joined
Jul 25, 2012
Messages
1,556
Best answers
8
Reaction score
893
Location
Spain
mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

However if you use PHP 7 both of these wont work as mysql driver is ded

 
OP
Fortera Global

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

However if you use PHP 7 both of these wont work as mysql driver is ded
php 5, how fix it? I tested use mysql real escape
 
OP
Fortera Global

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
Did real not work? what was the error
Deprecated: mysql_real_escape_string(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO)

Warning: mysql_real_escape_string(): A link to the server could not be established
 

Raggaer

Godly Member
Joined
Jul 25, 2012
Messages
1,556
Best answers
8
Reaction score
893
Location
Spain
Okey so mysql_real_escape_string expects your mysql connection as the second parammetter, try doing that

However it loads the last connection open if its null so it should work. Are you sure your database connection is ok?
 
OP
Fortera Global

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
Okey so mysql_real_escape_string expects your mysql connection as the second parammetter, try doing that

However it loads the last connection open if its null so it should work. Are you sure your database connection is ok?
How I can do it? connection in second parammetter

db connection is ok
 

LordVissie

( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°) ͜ʖ ͡°) ͡°)
Joined
Aug 4, 2015
Messages
1,621
Best answers
2
Reaction score
573
Location
The Earth
The link I posted shows exactly what you need.
 
OP
Fortera Global

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
The link I posted shows exactly what you need.
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /var/www/html/pages/bans.php on line 9
Failed to connect to MySQL: Access denied for user 'root'@'localhost' (using password: YES)
Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /var/www/html/pages/bans.php on line 17
 

LordVissie

( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°) ͜ʖ ͡°) ͡°)
Joined
Aug 4, 2015
Messages
1,621
Best answers
2
Reaction score
573
Location
The Earth
Your database connection is wrong as raggaer said and you are still using the old function.
 
OP
Fortera Global

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
Your database connection is wrong as raggaer said and you are still using the old function.
my db is correctly 100%, I was using old/new versions mentioned above.. complicated
 

LordVissie

( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°) ͜ʖ ͡°) ͡°)
Joined
Aug 4, 2015
Messages
1,621
Best answers
2
Reaction score
573
Location
The Earth
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /var/www/html/pages/bans.php on line 9
Failed to connect to MySQL: Access denied for user 'root'@'localhost' (using password: YES)

This says it isnt correct.
 

messenoire

Active Member
Joined
Sep 26, 2015
Messages
110
Best answers
0
Reaction score
39
Location
/root
First of all, create a user for your server in your database. Don't just use root.
1. open MySQL CLI
2. create user 'forgottenserver'@'localhost' identified by 'passw0rd';
3. grant all privileges on forgottenserver.* to 'forgottenserver'@'localhost';
4. flush privileges;

Then try again but using the user you just created.
Typed from head so look up if the syntax checks out.

Second, use PDO.
 
OP
Fortera Global

Fortera Global

Premium User
Premium User
Joined
Nov 20, 2015
Messages
1,063
Best answers
0
Reaction score
47
First of all, create a user for your server in your database. Don't just use root.
1. open MySQL CLI
2. create user 'forgottenserver'@'localhost' identified by 'passw0rd';
3. grant all privileges on forgottenserver.* to 'forgottenserver'@'localhost';
4. flush privileges;

Then try again but using the user you just created.
Typed from head so look up if the syntax checks out.

Second, use PDO.
This has already been solved, but thank you
 
Top