Problem with using variables as argument of get_meta_tag()
Posted: Fri Apr 17, 2009 6:16 am
Hi..i am newbie.Forgive my ignorance regarding PHP and posting in community.But i hav a serious problem.
The problem is that code works fine when a string is assigned directly given.It doesnt work when the input is read from a file.This is my code
$myFile = "C:\\database\\logentry.txt";
$fh = fopen($myFile, 'r');
while(!feof($fh))
{
$thefilename=fgets($fh);
if($thefilename==NULL)
break;
else
{
$tags = get_meta_tags($thefilename);
echo $tags1['keywords'];
}
}
fclose($fh);
?>
This produces the following error:
Warning: get_meta_tags(C:\\database\\ en.wikipedia.org_wiki_Main_Page.html ) [function.get-meta-tags]: failed to open stream: Invalid argument in C:\wamp\www\forum.php on line 13
But
$filename="C:\\database\\ en.wikipedia.org_wiki_Main_Page.html";
$tags = get_meta_tags($thefilename);
works fine.Problem is only with file reading.
Now the content of logentry.txt is list of HTML files stored in the local directory.It is given below.
C:\\database\\ en.wikipedia.org_wiki_Main_Page.html
C:\\database\\en.wikinews.org_wiki_Main_Page.html
C:\\database\\wikimediafoundation.org_wiki_Our_projects.html
C:\\database\\commons.wikimedia.org_wiki_.html
I have tested the filepath using '\' instead of '\\'
I am using wamp 2.0 with PHP 5.2.9-1.
Thanks in advance..
The problem is that code works fine when a string is assigned directly given.It doesnt work when the input is read from a file.This is my code
$myFile = "C:\\database\\logentry.txt";
$fh = fopen($myFile, 'r');
while(!feof($fh))
{
$thefilename=fgets($fh);
if($thefilename==NULL)
break;
else
{
$tags = get_meta_tags($thefilename);
echo $tags1['keywords'];
}
}
fclose($fh);
?>
This produces the following error:
Warning: get_meta_tags(C:\\database\\ en.wikipedia.org_wiki_Main_Page.html ) [function.get-meta-tags]: failed to open stream: Invalid argument in C:\wamp\www\forum.php on line 13
But
$filename="C:\\database\\ en.wikipedia.org_wiki_Main_Page.html";
$tags = get_meta_tags($thefilename);
works fine.Problem is only with file reading.
Now the content of logentry.txt is list of HTML files stored in the local directory.It is given below.
C:\\database\\ en.wikipedia.org_wiki_Main_Page.html
C:\\database\\en.wikinews.org_wiki_Main_Page.html
C:\\database\\wikimediafoundation.org_wiki_Our_projects.html
C:\\database\\commons.wikimedia.org_wiki_.html
I have tested the filepath using '\' instead of '\\'
I am using wamp 2.0 with PHP 5.2.9-1.
Thanks in advance..