hello, iam using tempnam function in one of my scripts , after i coded the script it works very well on the localhost , but when i uploaded it on my host it didnt work and i got that error Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') PHP: so that is the code which cauzed the error from the tempnam func $data = "some data of mine"; $temp_path=@tempnam("/tmp",""); $fp = @fopen($temp_path,"wb"); @fwrite($fp, $data ); @fclose($fp); include($temp_path); @unlink($temp_path); PHP: there wasn't any addition includes on that file ,so the error come here from include($temp_path); so please , any idea for fixing that ?? and why it works on the localhost but doesn't works on my host ?? thanks alot
If you have @anything() in your code, then your code is broken. @ is a horrible crutch that keeps you from doing proper error-checking. It makes debugging more difficult and vastly increases the likelihood of your program doing something you didn't expect it to. Take those off and report on the error messages you get and you will have your answer.
First of all, who is saying /tmp is a dir in your host? Maybe locally yes...but not all servers are the same. perhaps make a dir called tmp in the location of the folder, then just use tempnam('tmp',''); Try that.
well, thanks guys for that useful info . now i deleted the @ for the error reporting , and i found the tempnam is disabled . errors :- Warning: tempnam() has been disabled for security reasons Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') so how can i enable it ??? thanks
You don't...just write your own method. Just replace _tempnam with your tempnam PM me if you need help! function _tempnam() { $File=md5(microtime().$_SERVER['REMOTE_ADDR'].$_SERVER['REMOTE_PORT']);//Unique file fclose(fopen('/tmp/'.$File,'w+'));//Open file then close it...new file. return $File; }
thanks alot ,i gonna contact the root to enable it from the php.ini file , beside special thanks NatalicWolf ,your function is so great, i gonna try its way to make my own temp in the same directory .