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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.