好吧我首先要说的是我对php一无所知,我只是善于连接点,我正在尝试使用mssql转换为php脚本到sqlsrv,第一部分很简单,mssql_close只是sqlsrv_close等等,直到我发现这个令人讨厌的野兽:mssql_escape_string
现在有人对此一无所知,并试图改变这一点:
$username = mssql_escape_string( $_POST['username'] );
$password = mssql_escape_string( $_POST['password'] );
$password2 = mssql_escape_string( $_POST['password2'] );
$email = mssql_escape_string( $_POST['email'] );
$email2 = mssql_escape_string( $_POST['email2'] );
$age = mssql_escape_string( $_POST['age'] );
if ( strlen( $username ) > 25 || strlen( $username ) < 3 ) $errors[] = 'Username must be at least 3 characters long and no longer than 15 characters';
if ( preg_match( '[^A-Za-z0-9]' , $username) ) $errors[] = 'Username must be alphanumeric';
if ( strlen( $password ) > 15 || strlen( $password ) < 7 ) $errors[] = 'Password must be at least 7 characters long and no longer than 15 characters';
if ( $password != $password2 ) $errors[] = 'Passwords do not match';
if ( strlen( $email ) > 90 || strlen( $email ) < 5 ) $errors[] = 'Email must be at least 5 characters long and no longer than 90 characters';
if ( strpos($email, '@') == false) $errors[] = 'You have entered an invalid email address';
if ( $email != $email2 ) $errors[] = 'Emails do not match';
if ( strlen( $age ) > 2 || strlen( $age ) < 1 ) $errors[] = 'Age must be higher than 0 and no larger than 2 digits.';
if ( preg_match( '[^0-9]' , $age) ) $errors[] = 'Age may only contain numbers';
在这样的事情中(请注意这是使用sqlsrv的不同脚本的一部分,我不知道它是什么,我只是把各个部分放在一起):
public function Escape( $str )
{
$str = str_replace( "'", "''", $str );
return trim( $str );
}
没有使世界崩溃几乎是不可能的。
所以我不知道如何将A转入B,因为它看起来甚至不相似,我希望我到目前为止不知道它是什么,这足以激发一些帮助:c
如果需要,我可以使用更多的脚本进行更新,只需询问,尝试将其保留为具体细节。