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

0 Members and 1 Guest are viewing this topic.

Offline IGCAssassinTopic starter

  • Irregular
    • 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
  • 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
    • View Profile
How would I know what variable my connection information is stored in.

Offline revraz

  • Freak!
  • Gender: Male
  • Problems Resolved: 295
    • 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.

Offline Nightslyr

  • Guru
  • Addict
  • *
  • 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');
Things you should know before posting:
1. The rules
2. How to use CODE tags

In most cases, the code I provide hasn't been tested.  Keep that in mind if it doesn't work 100% correctly the first time.

Offline IGCAssassinTopic starter

  • Irregular
    • 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
  • 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)

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.