secure query string before sending it to mysql

From: Date: Sun, 23 Nov 2003 21:38:39 +0000
Subject: secure query string before sending it to mysql
Groups: php.general 
Request: Send a blank email to php-general+get-170733@lists.php.net to get a copy of this message
Hi, I'm working on a database class of my own. I've got the following method: /** * query() performs a query on the selected database */ function query($dbQuery) { if (is_string($dbQuery)) $this->dbQuery = $dbQuery; else die("The submitted query isn't a string"); $this->queryResult = mysql_query($this->dbQuery) or die("Couldn't perform the query: " . mysql_error()); } In the best of all words, variables that are part of the query string has been validated before going into the query. But if I sometimes forget to verify that user input doesn't contain dangerous code, I want to add some validating mechanism into the method above as well. $dbQuery will be query string like "INSERT INTO $article_table SET a_header = '$a_header'". Is there anything I can do, inside the method, to increase security? -- anders thoresson

« previous php.general (#170733) next »