FYI for anyone writing SQL queries, I'd like to offer the function below and get some feedback.
When ever you have global variables that will be passed to a SQL query you open up the posibility of someone altering the variable and inserting extra sql characters and statements into the query string.
In come cases it may be possible to get mySQL to "dump" the entire contents of the database to the screen.
'Select * FROM s01_Orders WHERE $ ' $ g.searchstring
If someone manages to insert code into g.searchstring, you may not get the results you expected.
Usually encodeentities() is used but in may cases it's overkill because it changes things in the string you may not want change. (for example you want to search for a string that contains '<')
PHP contains mysql_real_escape_string(string)
http://php.net/manual/en/function.my...ape-string.php
It renders hack attempts useless by altering the characters that would be inserted into your global variable.
\x00, \n, \r, \, ', " and \x1a.
A while ago I wrote a variation on the php function which seem very effective. I have not been able to get past it to insert code into a sql string.
When ever you have global variables that will be passed to a SQL query you open up the posibility of someone altering the variable and inserting extra sql characters and statements into the query string.
In come cases it may be possible to get mySQL to "dump" the entire contents of the database to the screen.
'Select * FROM s01_Orders WHERE $ ' $ g.searchstring
If someone manages to insert code into g.searchstring, you may not get the results you expected.
Usually encodeentities() is used but in may cases it's overkill because it changes things in the string you may not want change. (for example you want to search for a string that contains '<')
PHP contains mysql_real_escape_string(string)
http://php.net/manual/en/function.my...ape-string.php
It renders hack attempts useless by altering the characters that would be inserted into your global variable.
\x00, \n, \r, \, ', " and \x1a.
A while ago I wrote a variation on the php function which seem very effective. I have not been able to get past it to insert code into a sql string.
Code:
<MvFUNCTION NAME="SqlEscape" PARAMETERS="string," STANDARDOUTPUTLEVEL=""> <MvCOMMENT> MysqlEscape() \x00, \n, \r, \x1a, ", ', and \ . </MvCOMMENT> <MvFUNCRETURN VALUE="{ glosub(glosub(glosub(glosub(glosub(glosub(glosub(l.string ,asciichar(92),asciichar(92) $ asciichar(92)) ,asciichar(0),asciichar(92) $ asciichar(0)) ,asciichar(10),asciichar(92) $ asciichar(10)) ,asciichar(13),asciichar(92) $ asciichar(13)) ,asciichar(26),asciichar(92) $ asciichar(26)) ,asciichar(34),asciichar(92) $ asciichar(34)) ,asciichar(39),asciichar(92) $ asciichar(39)) }"> </MvFUNCTION>
Comment