The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 08:34:49 AM

Login with username, password and session length


Pages: 1 [2]
  Print  
Author Topic: Perk's MySQL Connection Class Updated  (Read 3432 times)
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #15 on: May 27, 2009, 08:57:48 PM »

never has errored on me.

i would be suprised if it did. the dump comes out from the DB, so why wouldnt it go in?
Unless I guess you are putting it into a new DB, not set up the same exact way?
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #16 on: June 01, 2009, 10:55:31 PM »

Any hint as to why this wont work? I am adding a "safe" function to the class, and I am not sure why this wont work for me???

Code:
function safe($string)
{
return mysql_real_escape_string($string, $this->__myConnection);
}

but yet It throws an error:
Warning: mysql_real_escape_string() expects parameter 2 to be resource, object given in /var/www/sites/yeagernorth.com/management/_mysqlconnection.class.php on line 143

which is the return line above.

the connection should be open immediately since I am instantiating with:
$db = new dbConnection($GLOBALS['dbhost'], $GLOBALS['dbuser'], $GLOBALS['dbpass'], $GLOBALS['dbdatabase'],true);
echo $db->safe("asdadsdasd");

i dont get it... now of course, I have about 16 hours of work under my belt already on mind numbing stuff and am tired, so who knows.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9896



View Profile
« Reply #17 on: June 01, 2009, 11:11:43 PM »

Nuts - have you tried modifying the code to protect itself and behave like other functions? I know it shouldn't matter at all, but I put this in front of everything to make sure I'm connected before I try anything that requires a connection:

if (!$this->__connected) { $this->connect(); }

... you could debug by trying to print_r this->__myConnection (it wont, but if there is one, it should say something like "Resource Handle" or something)

I've had trouble in the past with mysql_real_escape_string and using a connection handle that is a member of a class, but I don't remember what it all looked like. It is an older function, so maybe you need to explicitly pass the handle by reference? (mysql_real_escape_string($str, &$this->__myConnection))

Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #18 on: June 02, 2009, 08:59:35 PM »

GAH!!!!!!!!!!!!

I hate convention changes!!!!!

mysql_real_escape_string($string, $resourcehandle);
is now....
mysqli_real_escape_string($resourcehandle,$string);

its not the change of function name, which of course was the issue to begin with because I am retarded.
but then It still wouldnt work because...

the params are in OPPOSITE ORDER!!!!!


DAMN YOU PHP DEVS!!!!
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9896



View Profile
« Reply #19 on: June 03, 2009, 01:17:09 AM »

Whoooboy... then what's with this manual entry?

http://uk2.php.net/manual/en/function.mysql-real-escape-string.php

where did you read that the params are switched?
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #20 on: June 03, 2009, 07:31:57 AM »

but your using mysqli
                           i
                           i

compared to mysql functions, the mysqli functions put the connection first then the other params.
original mysql funcs put the connection last in the param list.

http://us2.php.net/mysql_real_escape_string
VS
http://us2.php.net/mysqli_real_escape_string

this all came from the fact that i didnt notice you using the I-funcs instead of the originals.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 9896



View Profile
« Reply #21 on: June 03, 2009, 02:46:13 PM »

 D'oh!

 Applause

What a CharlieFoxtrot. Spot on.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: 1 [2]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!