BhA Posted June 8, 2007 Share Posted June 8, 2007 Hi guys, I've been trying to wrote a code to check the existence of some files gathered from a field in mySql database. And I am kind a stuck at a point where I get the file locations from the database but when it passes those locations to file exist it keeps telling me the file does not exist. Only first file exists the other 2 file does not exist to test if the code was working or not. <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $db = mysql_connect("dbaddress","username","pass"); if ( $db != FALSE) { print "connected to the database"; } else { print "connection failed to the database"; } mysql_select_db("dbname", $db); $result = mysql_query("SELECT resume FROM `test`", $db); while ($row = mysql_fetch_array($result)) { printf ("Link: %s", $row[0]); $filename = $row[0]; if (file_exists($filename)) { echo "The file $filename exists."; } else { echo "The file $filename does not exist."; } } ?> </body> </html> you can check the result at www.flxdesign-prototype.com/testdb.php I would appreciate any help or guidance. Thanks, BhA Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 8, 2007 Share Posted June 8, 2007 From the API on the function, I gather that it checks the entire path provided. If you just supply a filename, it seems like it would check the root directory. Make sure you're giving teh full path. Could that be it? Quote Link to comment Share on other sites More sharing options...
BhA Posted June 8, 2007 Author Share Posted June 8, 2007 Thanks charlieholder, But it's not it sql field already contains the full path of the files. You can see it from the http://www.flxdesign-prototype.com/testdb.php too. Quote Link to comment Share on other sites More sharing options...
BhA Posted June 11, 2007 Author Share Posted June 11, 2007 Well I really appreciate som here I still couln't figure out the problem. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted June 11, 2007 Share Posted June 11, 2007 Why are you using $row[0]? Shouldn't you be using the field name to reference? Wouldn't 0 just give you the first file in the array every time? Quote Link to comment Share on other sites More sharing options...
BhA Posted June 11, 2007 Author Share Posted June 11, 2007 Well I don't think thats the problem, if you check the result page you can see that it increments the value $row[0] and it fetches the right links. I was wondering whether the file permissions are causing the problem or not. Any ideas? Quote Link to comment Share on other sites More sharing options...
trq Posted June 11, 2007 Share Posted June 11, 2007 The problem is more likely caused by url wrappers not being enbled. Use valid file paths, not urls. Quote Link to comment Share on other sites More sharing options...
BhA Posted June 11, 2007 Author Share Posted June 11, 2007 Thanks Charlieholder & Thorpe, It's working now probably charlie mentioned the same thing that you said Thorpe at his first post but I didn't get it until you said "not the url". Well anyways thank you guys this was giving me lots of trouble. 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.