php - multiple connections to database
I have a login page that gets the username and pwd and sanitises them before passing them to DB.
this is done through a function:
function make_safe($text) {
open_db_connection(); //this opens another connection!
if(get_magic_quotes_gpc()) {
$text = stripslashes($text);
}
$text = mysql_real_escape_string($text);
return $text;
}
this function is called from a script that already has an open connection, but still, I found that I have to open another connection INSIDE ´make___safe()´ to make it work (otherwise I get a "Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user blablabla@localhost ..."
I was wondering:
1) when I call make_safe, I already have an open connection - why is it not enough??
2) w开发者_运维百科hat are the problems in opening multiple connections?
thanks, patrick
I think you may need to supply the second argument to mysql_real_escape_string.
精彩评论