Author Topic: Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given  (Read 4037 times)

0 Members and 1 Guest are viewing this topic.

Offline IGCAssassinTopic starter

  • Irregular
  • Posts: 7
    • View Profile
Pls help not sure how to fix: I put the 410 just to mark the line in question Thanks In Advance

    function sql_escapestring($string)
    {
        return $this->sql_addq($string);
    }
    function sql_addq($string)
    {
        static $magic_quotes;
        if (!isset($magic_quotes)) $magic_quotes = get_magic_quotes_gpc();
        if ($magic_quotes) $string = stripslashes($string);
410   return (version_compare(phpversion(), '4.3.0', '>=')) ? mysqli_real_escape_string($string) : mysqli_escape_string($string);

    }
    function sql_error($query_id = 0)
    {
        return array('message' => @mysqli_error($this->db_connect_id), 'code' => @mysqli_errno($this->db_connect_id));
    }
    function sql_ufetchrow($query = "", $type=SQL_BOTH)
    {
        $query_id = $this->sql_query($query, true);
        $result = $this->sql_fetchrow($query_id, $type);
        $this->sql_freeresult($query_id);
        return $result;

Offline Bendude14

  • Enthusiast
  • Posts: 411
  • Gender: Male
  • Live for Today
    • View Profile
    • Mandurah Web Designs
mysqli_real_escape_string($string) ...


this needs to have 2 params the other parameter is your database connection so something like this

mysqli_real_escape_string($dbc, $string)

This is presuming your connection information is stored in a variable called $dbc

Offline IGCAssassinTopic starter

  • Irregular
  • Posts: 7
    • View Profile
How would I know what variable my connection information is stored in.

Offline revraz

  • Freak!
  • Posts: 6,866
  • Gender: Male
  • Problems Resolved: 352
    • View Profile
You set it when you make the connection.
If I can't make it better, then I'll make it worse, but it definitely won't be the same.

Online KevinM1

  • Global Moderator
  • Fanatic
  • *
  • Posts: 3,900
  • Gender: Male
    • View Profile
How would I know what variable my connection information is stored in.

Presumably, you have something like the following somewhere in your code:
$dbc mysql_connect('host''user''password');
Don't go to w3schools.  Here's why
Every time a PHP coder uses 'global' a kitten dies.

Offline IGCAssassinTopic starter

  • Irregular
  • Posts: 7
    • View Profile
This is the only line i can find thats close to that.

$this->db_connect_id = @mysqli_connect($this->server, $this->user, $this->password);

Offline Bendude14

  • Enthusiast
  • Posts: 411
  • Gender: Male
  • Live for Today
    • View Profile
    • Mandurah Web Designs
yer thats the line you are looking for.

i could do with seeing more of your code but this could work i think if its in the right place

mysqli_real_escape_string($this->db_connect_id, $string)