Welcome Guest, Not a member yet? Register   Sign In
mysql_escape_string
#1

[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
#2

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

[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
#4

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

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

[eluser]ivantcholakov[/eluser]
@Pavellicus

What version of CodeIgniter your project is based on?
#7

[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__);




Theme © iAndrew 2016 - Forum software by © MyBB