I keep getting a T String parse error. I am not sure what I'm missing? Any help would be appreciated!

<?php
$filename = "http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf";

if (file_exists($filename)) {
    echo "<a\href="http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf </a>";
} else {
    echo "The file $filename does not exist";
}
?>

Recommended Answers

All 8 Replies

try:

<?php
$filename = "http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf";

if (file_exists($filename)) {
echo '<a href="http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf">PDF</a>';
} else {
echo "The file $filename does not exist";
}
?>

Thanks! I got the error to go away, but the link shows up on the webpage and it is not working. How do I get it to work without exposing the url? Also, I would like to make the part after inspection variable or dynamic so it will change based upon which page is loaded? Thanks so much!

I am pretty sure the path for file_exists needs to be relative to the script it's called from. If the script is being run from the root you want:

if(file_exists('/cambiolabs/extension/catalog/files/inspection_886.pdf')) {
//do something
}

Also, I would like to make the part after inspection variable or dynamic so it will change based upon which page is loaded?

I have no idea what you are talking about. You need to elaborate!

I am pretty sure the path for file_exists needs to be relative to the script it's called from. If the script is being run from the root you want:

if(file_exists('/cambiolabs/extension/catalog/files/inspection_886.pdf')) {
//do something
}

Would fopen() work to open the pdf file in a new window?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.