Jump to content

Help with an error


Javis

Recommended Posts

alright I'm new to php so im trying to learn some stuff and ive already done most of the basics. Im following a tut to build my first web site and when i debug my file i get this error

 

Fatal error: Cannot redeclare hash_file() on line 180

 

the code on line 180 looks like this

 function hash_file ($strFilename) {
    $n = 0;
    for ($posFilename = strlen($strFilename) -1; $posFilename >= 0; $posFilename-- ) {
      $n *= 2;
      if ($n & 4096) { $n |= 1; }
      $n ^= (ord($strFilename[$posFilename])*11);
      $n &= 4095;
    }
    return sprintf ("%02o/%02o", ($n/64) & 63 , $n&63);
  }

 

any one know what i should do? thanks in advanced

Link to comment
https://forums.phpfreaks.com/topic/88186-help-with-an-error/
Share on other sites

I'm not familiar with the function, but it looks to do the same thing as PHPs version. My guess would be that the function was added so it would work on PHP4. Add an if around it to test it's existence:

 

if(!function_exists('hash_file')){
function hash_file ($strFilename) {
    $n = 0;
    for ($posFilename = strlen($strFilename) -1; $posFilename >= 0; $posFilename-- ) {
      $n *= 2;
      if ($n & 4096) { $n |= 1; }
      $n ^= (ord($strFilename[$posFilename])*11);
      $n &= 4095;
    }
    return sprintf ("%02o/%02o", ($n/64) & 63 , $n&63);
  }
}

Link to comment
https://forums.phpfreaks.com/topic/88186-help-with-an-error/#findComment-451211
Share on other sites

got a new problem went through and fixed a few others but i dont know what to do with this one

 

Call to a member function query() on a non-object on line 20

 

lines 19-22 look like the following

$sSQL="Select * from ".$pho_main." where parent=$num order by name";
  $q->query($DB, $sSQL);
  $rec=(object)$q->getrow();
  if($q->numrows()==0){

 

any suggestions

Link to comment
https://forums.phpfreaks.com/topic/88186-help-with-an-error/#findComment-451235
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.