Function Not Working In Sending Inboxes [RESOLVED]

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.

Re: Function Not Working In Sending Inboxes

Postby KyleMassacre » Wed Oct 01, 2014 5:37 pm

Man, I'm on a roll. I was using mysqli so just change it to mysql
Skype: KyleMassacre
My NWE Modules
User avatar
KyleMassacre
 
Posts: 572
Joined: Wed Nov 27, 2013 7:42 am
Has thanked: 19 times
Been thanked: 36 times

Re: Function Not Working In Sending Inboxes

Postby Epiales » Wed Oct 01, 2014 5:40 pm

KyleMassacre wrote:Man, I'm on a roll. I was using mysqli so just change it to mysql


Okay changed...
Code: Select all
Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in C:\xampp\htdocs\login2\includes\functions.php on line 48

Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in C:\xampp\htdocs\login2\includes\functions.php on line 48

Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in C:\xampp\htdocs\login2\includes\functions.php on line 48

Message Sent Successfully!


But message didn't sent lol... Here's what I have for the function

Code: Select all
<?php
function protect
($i,$output=true) {
    global $db_conx;
    $i = trim($i);
    $i = stripslashes($i);
    if($output == true) {
        $i = htmlentities($i, ENT_COMPAT, 'UTF-8');
    }
    $i = mysql_real_escape_string($i,$db_conx);
   
    return $i
;
}
?>
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Re: Function Not Working In Sending Inboxes

Postby Sim » Wed Oct 01, 2014 9:53 pm

Looks like your server is preparing for the future. They are getting ready to remove MySQL. Or its a sign.. ::winkity winkity:: Who is your server? You could always write your own MySQL_real_escape_string(). Its not that hard.
oRPG Creator - Make Your Own Browser Game
oRPG Creator on Facebook
Sim
 
Posts: 412
Joined: Sat Dec 26, 2009 12:37 pm
Location: Baltimore
Has thanked: 39 times
Been thanked: 13 times
Blog: View Blog (1)

Re: Function Not Working In Sending Inboxes

Postby MikuzA » Thu Oct 02, 2014 4:08 am

Epiales wrote:
KyleMassacre wrote:Man, I'm on a roll. I was using mysqli so just change it to mysql


Okay changed...
Code: Select all
Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in C:\xampp\htdocs\login2\includes\functions.php on line 48

Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in C:\xampp\htdocs\login2\includes\functions.php on line 48

Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in C:\xampp\htdocs\login2\includes\functions.php on line 48

Message Sent Successfully!


But message didn't sent lol... Here's what I have for the function

Code: Select all
<?php
function protect
($i,$output=true) {
    global $db_conx;
    $i = trim($i);
    $i = stripslashes($i);
    if($output == true) {
        $i = htmlentities($i, ENT_COMPAT, 'UTF-8');
    }
    $i = mysql_real_escape_string($i,$db_conx);
   
    return $i
;
}
?>


The problem here is that the $db_conx is presumably a mysqli-resource and not a mysql-resource, what it is expecting.

Anyways,
try doing this again with mysqli_real_escape_string($db_conx, $i)
(Swapping connection with the string)

A good one is to check PHP.net for function related usage if something seems a bit fishy,

Code: Select all
Procedural usage:
string mysqli_real_escape_string ( mysqli $link , string $escapestr )

Source: http://php.net/manual/en/mysqli.real-escape-string.php
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
MikuzA
 
Posts: 395
Joined: Thu Aug 08, 2013 3:57 am
Location: Helsinki, Finland
Has thanked: 0 time
Been thanked: 21 times

Re: Function Not Working In Sending Inboxes

Postby Epiales » Thu Oct 02, 2014 6:28 am

MikuzA wrote:
The problem here is that the $db_conx is presumably a mysqli-resource and not a mysql-resource, what it is expecting.

Anyways,
try doing this again with mysqli_real_escape_string($db_conx, $i)
(Swapping connection with the string)

A good one is to check PHP.net for function related usage if something seems a bit fishy,

Code: Select all
Procedural usage:
string mysqli_real_escape_string ( mysqli $link , string $escapestr )

Source: http://php.net/manual/en/mysqli.real-escape-string.php


Awesome! I changed it to this and it works. tytyty

Code: Select all
<?php
    
function protect($i,$output=true) {
        global 
$db_conx;
        
$i trim($i);
        
$i stripslashes($i);
        if(
$output == true) {
            
$i htmlentities($iENT_COMPAT'UTF-8');
        }
        
$i mysqli_real_escape_string($db_conx$i);
       
        return 
$i;
    }
?>
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
 
Posts: 1119
Joined: Wed Aug 14, 2013 8:38 pm
Has thanked: 62 times
Been thanked: 6 times

Previous

Return to Beginner Help and Support

Who is online

Users browsing this forum: No registered users and 1 guest

x