I am developing a web application using the zend framework. For select statements, I used the following path.
Example:
public function getData($name)
{
$sql = "SELECT * from customer where Customer_Name = '$name'";
return $this->objDB->getAdapter()->fetchAll ($sql);
}
It works great. But if I send the client name as:, the colvin placerequest failed. And I know that because of a single quote.
I used to use addlashes PHP function. But I saw that this is not a very good way to do this. This time I used the mysql_real_escape_stringPHP function .
The problem is the following warning.
Warning</b>: mysql_real_escape_string() [<a href='function.mysql-real-escape-string'>function.mysql-real-escape-string</a>]: Access denied for user 'ODBC'@'localhost' (using password: NO)
This is due to the feature mysql_real_escape_stringrequires a connection to the database being opened mysql_connect. My question is how can I use this with * Zend_DB * classes. I need to always use custom select queries. Please rate your other suggestions, if available.
thank