Jump to content

[SOLVED] Checking file existence through a list of file locations gathered from an array


BhA

Recommended Posts

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

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

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.