CodeIgniter Forums
mysql_escape_string - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: mysql_escape_string (/showthread.php?tid=59907)



mysql_escape_string - El Forum - 12-08-2013

[eluser]Pavellicus[/eluser]
my colleague is making some tests with the new version of php(5.4.22) on our server and when i try to use my project in codeigniter i receve this message ..


Code:
A PHP Error was encountered

Severity: 8192

Message: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead.

Filename: mysql/mysql_driver.php

Line Number: 319


what i can do?

thanks


mysql_escape_string - El Forum - 12-08-2013

[eluser]xtremer360[/eluser]
I think the message is pretty self explanatory. Change mysql_escape_string to mysql_real_escape_string.


mysql_escape_string - El Forum - 12-09-2013

[eluser]Pavellicus[/eluser]
[quote author="xtremer360" date="1386532479"]I think the message is pretty self explanatory. Change mysql_escape_string to mysql_real_escape_string.[/quote]


really?n what way?
tell me please because i try and i have the same problem with mysql_real_escape_string


mysql_escape_string - El Forum - 12-09-2013

[eluser]noideawhattotypehere[/eluser]
Switch driver to PDO


mysql_escape_string - El Forum - 12-09-2013

[eluser]Pavellicus[/eluser]
in what way?


mysql_escape_string - El Forum - 12-09-2013

[eluser]ivantcholakov[/eluser]
@Pavellicus

What version of CodeIgniter your project is based on?


mysql_escape_string - El Forum - 12-09-2013

[eluser]Pavellicus[/eluser]
SOLVED!

if you change version of PHP from 5.3 to 5.4 you must change the hostname

config/database.php

from
Code:
$db['default']['hostname'] = 'localhost';
to
Code:
$db['default']['hostname'] = '127.0.0.1';

if you need to undestand better your problem use this code inside the page


Code:
database.php
...
...

echo '<pre>';
  print_r($db['default']);
  echo '</pre>';

  echo 'Connecting to database: ' .$db['default']['database'];
  $dbh=mysql_connect
  (
    $db['default']['hostname'],
    $db['default']['username'],
    $db['default']['password'])
    or die('Cannot connect to the database because: ' . mysql_error());
    mysql_select_db ($db['default']['database']);

    echo '<br />   Connected OK:'  ;
    die( 'file: ' .__FILE__ . ' Line: ' .__LINE__);