![]() |
mysql_real_escape_string?
Heya guys. I am truly puzzled by mysql_real_escape_string.
From what I understand you need to make a database connection before the function will work. I think that I'm doing this. Code:
$link = mysqli_connect( $sql_server, $sql_user , $sql_password ) or die ('Unable to connect to server.'. mysqli_error());Warning: mysql_real_escape_string() expects parameter 2 to be resource... The $password line gives me another error. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in... I would think one of these would work, suggestions?? |
Not sure if this is relevant but on the second error with the password that reference to ODBC makes me wonder if you are using a sql database at all. And in particular a MySQL database.
|
Both errors would suggest that the MySql connection is invalid.
|
Actually a quick test without the mysql_real_escape_string() demonstrated that it worked fine. Data was injected correctly into the database.
|
Well, I found the problem.
It should be: $username = mysqli_real_escape_string($link, $username); Not: $username = mysql_real_escape_string($username, $link); The first statements were mysqli so that was a mistake on my part. The odd thing is that $link comes first with mysqli and second with mysql. |
It might be to make sure you can't accidentally pass one off as the other because they look almost identical.
|
Do you have to specify the link in most of the
mysqli_ functions? My thinking is that MySQLi has the link parameter first because that is essential for MySQLi to work correctly. In the mysql_ functions it didn't matter too much if you didn't specify the link because if only one connection was open, then that was obviously the default.My question, why is the link parameter essential for MySQLi? |
My question, why use the global functions when the OO approach is much prettier?
|
Welcome to mmoggg website to buy RS Gold, offer a lot, of course, Diablo 3 Gold and Cheap RS Gold, to be purchased at any time, at any time shipment, and Diablo 3 Gold Kaufen look forward to your visit!
|
| All times are GMT. The time now is 10:33 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0