rotate.php script on wordpress problem

7 replies
  • WEB DESIGN
  • |
My client want me to rotate header image after refreshing page. i got rotate.php on the net..
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
/*
By Matt Mullenweg > Matt Mullenweg -- aka Photo Matt -- on WordPress, Web, Jazz, Life, and Photography
Inspired by Dan Benjamin >
Latest version always at:

Random Image Script -- Matt Mullenweg

*/// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // for each extension check the extension
if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
$files[] = $file; // it's good
++$i;
}
}
}
closedir($handle); // We're not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along

header('Location: '.$folder.$files[$rand]); // Voila!
?>

<body>
</body>
</html>
it worked fine on my localhost [wamp] with dreamweaver but when i uploaded all my data on web host den no header image is loading and i got this error on header image
Warning: Cannot modify header information - headers already sent by (output started at /home/ericfran/public_html/wp-content/themes/Shihab/images/headerimgs/rotate.php:7) in /home/ericfran/public_html/wp-content/themes/Shihab/images/headerimgs/rotate.php on line 39
any suggestion please!!!
#problem #rotatephp #script #wordpress
  • Profile picture of the author pinterest01
    it might be permission problem, u need to change the mod of the file for your header.php?
    {{ DiscussionBoard.errors[6129798].message }}
  • Profile picture of the author Kingfish85
    Try removing the line of blank space right before your <body> tag. This error is usually caused by having white space before or after the opening and closing PHP tags
    Signature

    |~| VeeroTech Hosting - sales @ veerotech.net
    |~| High Performance CloudLinux & LiteSpeed Powered Web Hosting
    |~| cPanel & WHM - Softaculous - Website Builder - R1Soft - SpamExperts
    |~| Visit us @veerotech Facebook - Twitter - LinkedIn

    {{ DiscussionBoard.errors[6129895].message }}
    • Profile picture of the author killerintech
      Originally Posted by Kingfish85 View Post

      Try removing the line of blank space right before your <body> tag. This error is usually caused by having white space before or after the opening and closing PHP tags
      Thanks a lot .. it works for me
      {{ DiscussionBoard.errors[6130465].message }}
      • Profile picture of the author Kingfish85
        Originally Posted by killerintech View Post

        Thanks a lot .. it works for me
        You bet! Glad it's working for you.

        -Brent
        Signature

        |~| VeeroTech Hosting - sales @ veerotech.net
        |~| High Performance CloudLinux & LiteSpeed Powered Web Hosting
        |~| cPanel & WHM - Softaculous - Website Builder - R1Soft - SpamExperts
        |~| Visit us @veerotech Facebook - Twitter - LinkedIn

        {{ DiscussionBoard.errors[6132528].message }}
  • Profile picture of the author antac
    Banned
    If it works better, then I just want to say,
    Best of luck and go ahead.
    {{ DiscussionBoard.errors[6131711].message }}
  • Profile picture of the author doozign
    Try to change the code below :
    Code:
    header('Location: '..); // Voila!
    with this code :
    Code:
    wp_redirect('Location: '..); // Voila!
    Hope it works,
    Irfan Permana
    {{ DiscussionBoard.errors[6131782].message }}
    • Profile picture of the author mmrumii
      Originally Posted by doozign View Post

      Try to change the code below :
      Code:
      header('Location: '..); // Voila!
      with this code :
      Code:
      wp_redirect('Location: '..); // Voila!
      Hope it works,
      Irfan Permana

      This is a good stuff.
      I'm sure it will work for you, as i known.
      Best of luck for your site.
      {{ DiscussionBoard.errors[6132083].message }}

Trending Topics