Warning: Failed Opening 'library/closedb.php' For Inclusion - Webmasters - Nairaland
Nairaland Forum › Science/Technology › Webmasters › Warning: Failed Opening 'library/closedb.php' For Inclusion (2589 Views)
| Warning: Failed Opening 'library/closedb.php' For Inclusion by pagolina(op): 12:48pm On Apr 30, 2010 |
I have a form that contain file field, I want the user to upload file (image) as part of the form. other part of the script work fine EXCEPT this include statement (include 'library/config.php' and include 'library/opendb.php' ) that return an error msg like this Warning: Failed opening 'library/closedb.php' for inclusion (include_path='.;C:/phpdev/php/includes;C:/phpdev/php/class') in c:\phpdev\www\phpnew\uploadok.php on line 27 that's my problem it fail to open any include library/files.php why? and how do i handle this? Your response will be highly welcome. my procesing script goes like this. <?php if (isset($_POST['upload'])&&$_FILES[userfile][size]>0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } include 'library/config.php'; include 'library/opendb.php'; $query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); include 'library/closedb.php'; echo "<br>File $fileName uploaded<br>"; } ?> or is there any other way i can upload image as part of my form easyly? |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by Incarnate: 1:59pm On Apr 30, 2010 |
What is the part to the file that contains the code you posted? what is the part to the file that you want to include? Me feels it is in different locations so your php file cant find the include stuff. difficult to say for now and if you have the website online post a link |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by ogzille(m): 3:04pm On Apr 30, 2010 |
is uploadok.php in the same folder with the library folder? |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by Nobody: 3:11pm On Apr 30, 2010 |
Incarnate is right the include is referencing a folder that doesn't exist in that path or the level you are specifying is wrong if ur files is inside a folder and u need to reference a folder on another directory like say the root u need to change your directory path with chdir() and you can view where u are with getcwd(); the reason for that error is includes will still run regardless of the error compared to require which is better include is meant for html php templates and require should be used for including classes and function. look for this here c:\phpdev\www\phpnew\uploadok.php on line 27 that's where the error first started add -print getcwd() and compare the path to ur server or system hope this helps |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by Nobody: 3:13pm On Apr 30, 2010 |
better still attach both files but i will advise u to get urself a proper PHP IDE it saves time debugging and stuff like there free ones like Zend PDT or use Aptana that's what i use and save ur self the stress. attach the script or paste the code here |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by pagolina(op): 4:42pm On May 07, 2010 |
i have been able to do away with the library/file.php that brought warning msg Now the image is going to a temporary folder (uploads) when i insert it into my db it enter but when i retrive it via sql statement is not showing on echo rather the file path is showing why?. pls if sombody can show me the easiest way to upload image to the db and display it on a webpage i will be very gratefull thanks |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by ogzille(m): 5:10pm On May 07, 2010 |
parameters: name of folder to upload to: uploads name of the file field on the form: logo what u will insert into the database: $file the code to handle upload: $rand = rand(1000, 100000); $file="uploads/".$rand.basename($_FILES["logo"]["name"]); move_uploaded_file($_FILES["logo"]["tmp_name"],$file); insert $file in the appropriate column in ur table. select from db: select column_name from table_name; run the query then the image source will now be in variable eg $img display the image: <img src="<?php echo $img;?>" /> NB: what u store in d database is the source of the image u uploaded to the server. |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by Nobody: 7:49am On May 08, 2010 |
@ogzille at some point a small probability at 20% chance that a file might the same random no and also the same filename and that will over-write an existing picture user coud either use file_exist() with ur code or reduce the chances of double images by $filename=(current-time) + (md5(name of the picture)); that way the chances of repeating pix are rare |
| Re: Warning: Failed Opening 'library/closedb.php' For Inclusion by ogzille(m): 8:39am On May 08, 2010 |
@pc guru i wonder where u got your percentage from? 20% means out of five pictures, u will have an instance of the same name. Anyway, ur idea is okay, but for the percentage,i dislike fake statistics. |
Solution To Sms Sending Failed Unit (bulk Sms Website) • INTERSWITCH/QUICKTELLER Won't Return My Funds After A Failed Transaction! • Why Linda Ikeji Would Have Failed If She Started Blogging 2013 • 2 • 3 • 4
Advice On Payment Gateway To Use For A Real Estate Site • Google Adsense Payment Help! • Networkng Business