# Someone please help my website is down!

**URL:** <https://www.phphelp.com/t/someone-please-help-my-website-is-down/10783>\
**Category:** Beginners - Learning PHP\
**Created:** [January 18, 2008, 11:13pm UTC](https://www.phphelp.com/t/someone-please-help-my-website-is-down/10783 "2008-01-18T23:13:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![babybird11](https://www.phphelp.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@babybird11](https://www.phphelp.com/u/babybird11)\
**Post date:** [January 18, 2008, 11:13pm UTC](https://www.phphelp.com/t/someone-please-help-my-website-is-down/10783/1 "2008-01-18T23:13:27Z")

</div>

Hi i have a website , [http://www.bestcompaniesintheworld.com](http://www.bestcompaniesintheworld.com), until recently (new year!) the site has been fine, but all of a sudden its coming up with an error message when i type in the url, I have copied the page its reffering to the error can anyone help please!! the error message coming up is:

Fatal error: Cannot redeclare date\_format() in /home/bestdcom/public\_html/libraries/functions.lib.php on line 158

here is functions.lib.php below; please can anyone advise on how to fix? would be appreciated!

\<?php ob\_start(); if ($cfg['memory\_limit']) ini\_set('memory\_limit',$cfg['memory\_limit']); // Set up database connection $db = new db; $db-\>connect($cfg['db\_host'],$cfg['db\_user'],$cfg['db\_pass'],$cfg['db\_name']); $timestamp = date("YmdHis"); $status\_array = array( 'R' =\> 'Reserved', 'P' =\> 'Paid' ); /\* \* Build pixel links \*/ function link\_array() { global $cfg; $grid\_array = grid\_array(); ?\>

![]()

\<?php

if ($grid\_array) {

// Patch Details  
foreach ($grid\_array as $id =\> $value) {

// Explode patch details  
$value = explode ("|",$value);

switch ($value[5]) {  
case ‘P’:  
// Get image dimensions  
$file\_size = getimagesize($cfg[‘upload\_path’].$value[4]);  
?\>

\<?php break; } } } ?\> \<?php }

/\*

- Check user session  
\*/  
function is\_user\_session() {

session\_start();

if ($\_SESSION[‘sess\_user’] and $\_SESSION[‘sess\_id’])  
return true;  
else  
return false;  
}

/\*

- Check email is valid  
\*/  
function is\_email($email) {

if (ereg("[[:alnum:]]+@[[:alnum:]]+.[[:alnum:]]+", $email))  
return true;  
else  
return false;  
}

/\*

- Check url is valid  
\*/  
function is\_url($url) {

if (!preg\_match(’#^http://[a-z0-9-]+.([a-z0-9-]+.)?[a-z]+#i’, $url))  
return false;  
else  
return true;  
}

/\*

- Grid array  
\*/  
function grid\_array() {

global $db,$cfg;

$query = $db-\>query(“SELECT \* FROM “.$cfg[‘adverts’].””);  
while ($result = $db-\>fetch\_array($query)) {

$grid\_array[$result[‘id’]] = $result[‘x’].’|’.$result[‘y’].’|’.$result[‘width’].’|’.$result[‘height’].’|’.$result[‘image’].’|’.$result[‘status’].’|’.$result[‘url’].’|’.$result[‘title’];  
}  
return $grid\_array;  
}

/\*

- Global email  
\*/  
function send\_email($email,$subject,$message) {

global $cfg;

// Set HTML Mail Headers  
$headers = “MIME-Version: 1.0rn”;  
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;  
$headers .= "From: ".$cfg[‘site\_email’].“rn”;  
$headers .= "Reply-To: ".$cfg[‘site\_email’].“rn”;

// Send email  
mail($email,$subject,$message,$headers);  
}

/\*

- Shorten string  
\*/  
function shrstr($string, $num=“50”) {

// Check string length if grater then $num  
if (strlen($string) \> $num) {  
// Shorten the string with …  
$string = substr( $string, 0, $num-2);  
$string .= “…”;

return $string;  
} else {  
// If $num is less then  
return $string;  
}  
}

/\*

- Convert timestamp  
\*/  
function date\_format($date,$format) {

$year = substr($date,0,4);  
$month = substr($date,4,2);  
$day = substr($date,6,2);  
$hour = substr($date,8,2);  
$minute = substr($date,10,2);

return date($format,mktime($hour,$minute,0,$month,$day,$year));  
}

/\*

- Convert all files supporting ext.  
\*/  
function convert\_file\_jpg($image,$ext) {

global $cfg;

// Check the extension of the file  
if ($ext == “jpg”) {  
// Create new image from JPG  
$src = imagecreatefromjpeg($cfg[‘upload\_path’].$image);  
} elseif ($ext == “gif”) {

// Create new image from GIF  
$src = imagecreatefromgif($cfg[‘upload\_path’].$image);  
}

// Rename new image  
$new\_image = substr($image,0,-3).’.gif’;

// Delete old image  
unlink($cfg[‘upload\_path’].$image);

// Create new JPG image  
imagegif($src,$cfg[‘upload\_path’].$new\_image,$cfg[‘jpg\_quality’]);

return $new\_image;  
}

/\*

- Stats  
\*/  
function stats() {

global $db,$cfg;

// Check global switch  
if ($cfg[‘stats\_order’] == “random”) {  
// Run random order query  
$query = $db-\>query(“SELECT \* FROM “.$cfg[‘adverts’].” WHERE status = ‘P’ ORDER BY RAND()”);  
} elseif ($cfg[‘stats\_order’] == “hits”) {  
// Run clicks order query  
$query = $db-\>query(“SELECT \* FROM “.$cfg[‘adverts’].” WHERE status = ‘P’ ORDER BY hits DESC”);  
}  
?\>

\<?php while ($result = $db-\>fetch\_array($query)) { ?\> \<?php } ?\>

| URL | Advert | Hits |
| \<?php echo shrstr($result['url'],30); ?\>[/url] | ![]() | They've had **\<?php echo $result['hits']; ?\>** Visitors |

\<?php }

/\*

- Log errors  
\*/  
function log\_error($timestamp,$error) {

$message = date\_format($timestamp,‘d-m-y’).’-’.$error;

$file = fopen(‘error\_log.txt’, ‘a’);  
fwrite($file, $message);  
fclose($file);  
}

/\*

- News  
\*/  
function news() {

global $db,$cfg;

$query = $db-\>query(“SELECT \* FROM “.$cfg[‘news’].” ORDER BY timestamp DESC”);

while ($result = $db-\>fetch\_array($query)) {  
?\>

| \<?php echo date\_format($result['timestamp'],"d F Y H:i:s"); ?\> | |
| \<?php echo stripslashes($result['title']); ?\> | |
| \<?php echo nl2br(stripslashes($result['text'])); ?\> | |
| Posted by \<?php echo stripslashes($result['name']); ?\> | |

\<?php } } ?\>

---

<div class="post-metadata">

**Author:** ![Monk](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/c89c15/32.png) [@Monk](https://www.phphelp.com/u/Monk)\
**Post date:** [January 19, 2008, 12:36am UTC](https://www.phphelp.com/t/someone-please-help-my-website-is-down/10783/2 "2008-01-19T00:36:31Z")

</div>

I responded to your thread in the General section [http://www.phphelp.com/forums/viewtopic.php?f=1&t=8278](http://www.phphelp.com/forums/viewtopic.php?f=1&t=8278)

Please don’t post in more than one area.
