Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    More php error---please help

    1ST CODE:

    <?php
    $ads = array();
    $bannerAds = array();
    $bannerAdsTime = time();
    $lines = file($bannerAdsPath) or die();
    foreach ($lines as $line) {
    $line = chop($line);
    if (($line != '') && (!ereg('^#', $line))) {
    if (ereg('^[A-Za-z0-9]+\|\|', $line)) {
    $ads[] = $line;
    } else {
    list ($key, $val) = explode('=', $line);
    $bannerAds[$key] = $val;
    }
    }
    }
    function writeads()
    {
    global $bannerAdsPath, $ads, $bannerAds;
    $data = fopen($bannerAdsPath, 'w') or die();
    flock($data, 2) or die();
    fputs($data, @join("\n", $ads)."\n");
    while (list ($key, $val) = each ($bannerAds)) {
    if (($key != '') && ($val != '')) {
    fputs($data, $key.'='.$val."\n");
    }
    }
    flock($data, 3);
    fclose($data);
    reset($bannerAds);
    }
    ?>

    2ND CODE

    <?php
    $bannerAdsPath = '/home/yourdomain/public_html/ads/ads.dat';
    require '/home/yourdomain/public_html/ads/ads.inc.php';
    ///////////////////////////////////////
    // Don't Edit Anything Below This Line!
    ///////////////////////////////////////
    for ($i = 0; $i < count($ads); $i++) {
    if(ereg('^' .$_GET['id']. '\|\|', $ads[$i])) {
    $data = explode('||', $ads[$i]);
    $data[6]++;
    $ads[$i] = join('||', $data);
    break;
    }
    }
    if (!$data[9]) {
    die();
    }
    writeads();
    Header("Location: $data[9]");
    exit;

    3RD CODE :

    <?php
    require '/home/yourdomain/public_html/ads/ads.php';
    ///////////////////////////////////////
    // Don't Edit Anything Below This Line!
    ///////////////////////////////////////
    if (!isset($_GET['id']) || !ereg('^[0-9]+$', $_GET['id'])) {
    $_GET['id'] = null;
    }
    if (!isset($_GET['width']) || !ereg('^[0-9]+$', $_GET['width'])) {
    $_GET['width'] = 0;
    }
    if (!isset($_GET['width']) || !isset($_GET['height']) || !ereg('^[0-9]+$', $_GET['height'])) {
    $_GET['height'] = 0;
    }
    $buttons = new bannerAds($_GET['id'], 1, $_GET['width'], $_GET['height']);
    header('Content-type: application/x-javascript');
    echo "<!--\n";
    echo "document.write(\"" .addslashes($buttons->ad[0]). "\");\n";
    echo "//-->";
    ?>

    THE ERRORS ARE

    Function ereg() is deprecated

    PLEASE HELP

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,342
    Thanks
    13
    Thanked 349 Times in 345 Posts
    THE ERRORS ARE

    Function ereg() is deprecated

    PLEASE HELP
    that’s correct. you should use the preg_* functions instead. (e.g. preg_match())

    see also: PHP: Differences from POSIX regex - Manual
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •