0

I Just Bought a PHP Script That Was Working Properly Till I Test It ON my Web Server. When I ran THe Script It looks Great But When I click the Sub-Category of my Website I gives me This Error "Deprecated: Function ereg_replace() is deprecated in /home/*/public_html/includes/functions.php on line 61"

My Script is Look LIke This:

<?php function generate_link($pagename,$c='',$k='',$q='',$p='',$ktext=''){

if (USE_SEO_URLS==true){

    switch ($pagename){

        case 'category.php':
            $result ='c' . $c . '.html';
            break;
        case 'questions.php':
            $result ='q-c' . $c . '-k' . $k . '-p' . $p . '-' . str_replace(" ","-",$ktext) . '.html';
            break;
        case 'answer.php':
            $result ='a' . $q . '-c' . $c . '-k' . $k . '.html';
            break;
    }

}
else {
    switch ($pagename){
        case 'category.php':
            $result ='category.php?c=' . $c;
            break;
        case 'questions.php':
            $result ='questions.php?c=' . $c . '&k=' . $k . '&p=' . $p . '&ktext=' . str_replace(" ","-",$ktext) ;
            break;
        case 'answer.php':
            $result ='answer.php?k=' . $k . '&c=' . $c . '&id=' . $q ;
            break;
    }
}

return $result;  } function db_prepare_input($string) {
if (is_string($string)) {
  return trim(sanitize_string(stripslashes($string)));
} elseif (is_array($string)) {
  reset($string);
  while (list($key, $value) = each($string)) {
    $string[$key] = db_prepare_input($value);
  }
  return $string;
} else {
  return $string;
} } function sanitize_string($string) {
$string = ereg_replace(' +', ' ', trim($string));

return preg_replace("/[<>]/", '_', $string);}?>

Sorry , My Code Is also Not Proper Formatted. I face Great Problem When I post this Question Stackoverflow. Any Help Is appreciated. The Error Is Occur in Line 61. I am New in PHP. I check, There is ereg and preg Both Functions are present. please help me.. Thanks

Redwan
  • 11
  • 1
  • 5
  • 1
    get a refund, its rubish –  Aug 20 '13 at 07:17
  • SO is not a place to just post code and get answers without making any effort to solve the problem yourself. A simple search of the error message would show you the answer, there are many questions with the answers already on SO and thousands of pages with the answer on google. You need to learn how to search before you can get anywhere with programming – Anigel Aug 20 '13 at 07:18

1 Answers1

1

ereg_replace deprecated. Use preg_replace like this:

$string = preg_replace('/ \+/', ' ', trim($string));

That is important / \+/ pattern. Space and plus(+)

Bora
  • 10,529
  • 5
  • 43
  • 73
  • Hello Bora, Sir, How I send you a message??? Can you please Check My Script???? – Redwan Aug 20 '13 at 12:15
  • Bora, Sir, After Replace the piece of Code There's Still a new Error Deprecated: Assigning the return value of new by reference is deprecated in /home/*/public_html/includes/phpflickr/phpFlickr.php on line 91 – Redwan Aug 20 '13 at 12:22
  • Sir, I Wanna Mail you Full Folder. Sir, I am Noobs. Can you Give me your mail address please??? I am Tanvir redwan. From Bangladesh. Thanks – Redwan Aug 20 '13 at 16:01
  • Sir, This is a Complex Script. It Can Scrap Yahoo Answer Content and Flickr Image. But this is a Bug...And It is not available on Surface Web . U search But Not found Anywhere.. – Redwan Aug 20 '13 at 16:03
  • Sir, This is the LIne 91 "$this->req =& new HTTP_Request();" – Redwan Aug 20 '13 at 16:08
  • phpFlickr Class 2.1.0 * Written by Dan Coulter – Redwan Aug 20 '13 at 16:09