Javis Posted January 28, 2008 Share Posted January 28, 2008 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 Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 28, 2008 Share Posted January 28, 2008 PHP 5 already has a function called hash_file Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2008 Share Posted January 28, 2008 There is already a function built into php5 and above called hash_file. Rename your function to something else. Quote Link to comment Share on other sites More sharing options...
Javis Posted January 28, 2008 Author Share Posted January 28, 2008 thorpe got an axample or you mean like any name? im extremely new to this stuff Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 28, 2008 Share Posted January 28, 2008 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); } } Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2008 Share Posted January 28, 2008 Any name will do. Just remember, when you call the function you'll need to use the same name. In fact you can probably proceed without the function at all and just use the newer built in hash_file function in its place. Quote Link to comment Share on other sites More sharing options...
Javis Posted January 28, 2008 Author Share Posted January 28, 2008 lol i keep missing the reply button. any ways ill rename it something random. Quote Link to comment Share on other sites More sharing options...
Javis Posted January 28, 2008 Author Share Posted January 28, 2008 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 Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2008 Share Posted January 28, 2008 Where is $q defined? Quote Link to comment Share on other sites More sharing options...
Javis Posted January 28, 2008 Author Share Posted January 28, 2008 your asking for this right? if not sorry $rec=(object)$q->getrow(); Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 28, 2008 Share Posted January 28, 2008 No, on this line: $q->query($DB, $sSQL); You access the variable $q. Where is $q set? Quote Link to comment Share on other sites More sharing options...
Javis Posted January 28, 2008 Author Share Posted January 28, 2008 umm fixed that one will post back if i have any more errors that i need help with Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.