Answer the question
In order to leave comments, you need to log in
PHP - why does url checking on hosting not work?
Hello!
I have a question.
I have a Security class that describes a method
public function checkUrl($url){
for($i=0;$i<count($url);$i++){
$a[$i]=mysql_real_escape_string(addslashes($url[$i]));
}
return $a;
}
$url=Security::checkUrl($url);
Answer the question
In order to leave comments, you need to log in
try not to use mysql_* functions
mb hosting php does not support these functions =)
// Функция получает ссылку на массив url
// После выполнения функции массив $url содержит экранированые данные
function secureUrl($url)
{
foreach ($url as &$elem)
$elem = mysql_real_escape_string(addslashes($elem));
unset($elem);
}
// Usage:
//
// $url = Массив;
// secureUrl($url);
// Функция получает массив url
// Возвращает новый массив, содержащий экранированные данные
function getSecureUrl($url)
{
$a = array();
foreach ($url as $elem)
$a[] = mysql_real_escape_string(addslashes($elem));
return $a;
}
// Usage:
//
// $url = Массив;
// $url = getSecureUrl($url);
Either make the checkUrl() method static:
Or use a dynamic call:
$obj = new Security();
$url = $obj->checkUrl($url);
::
No. There is no error. it just constantly gives me the main page even when I go through the menu items ..
and on the local server everything works
the whole problem is in this method
public function checkUrl($url){
for($i=0;$i<count($url);$i++){
$a[$i]=mysql_real_escape_string(addslashes($url[$i]));
}
return $a;
}
public function checkUrl($url){
return $url;
}
function secureUrl($url){
foreach ($url as &$elem)
$elem = mysql_real_escape_string(addslashes($elem));
unset($elem);
}
function getSecureUrl($url){
$a = array();
foreach ($url as $elem)
$a[] = mysql_real_escape_string(addslashes($elem));
return $a;
}
$obj = new Security();
$url = $obj->checkUrl($url);
try not to use mysql_* functions
mb hosting php does not support these functions =)
Doesn't work because I'm using PDO which doesn't work with mysql_real_escape_string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question