dnienhaus Posted July 20, 2006 Share Posted July 20, 2006 My file_exists always returns false? I know the file exists so what might be the problem? Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/ Share on other sites More sharing options...
cmgmyr Posted July 20, 2006 Share Posted July 20, 2006 can you please show us some code? Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61274 Share on other sites More sharing options...
wildteen88 Posted July 20, 2006 Share Posted July 20, 2006 WTF! I was replying to this earlier then it disappered. Could you post your code again please. Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61277 Share on other sites More sharing options...
dnienhaus Posted July 20, 2006 Author Share Posted July 20, 2006 Heres my variable i want to validate..[code]$url = "'http://intranet/engineering/drawings/$PARTNUMBER.pdf'";include ('checkfile.php');[/code]Heres the file_exists code..[code]<?php$filename = "$url";if (file_exists($filename)) {}else {$url = "No Drawing";}?> [/code] Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61278 Share on other sites More sharing options...
legohead6 Posted July 20, 2006 Share Posted July 20, 2006 is that a private bussness network address or sumthin cuz in my browser the link comes up with a dns error[code]Bad GatewayThe following error occurred:[code=DNS_HOST_NOT_FOUND] The host name was not found during the DNS lookup. Contact your system administrator if the problem is not found by retrying the URL.[/code][/code] Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61287 Share on other sites More sharing options...
effigy Posted July 20, 2006 Share Posted July 20, 2006 [list][*]Your $url variable has single quotes within the double.[*]Is $PARTNUMBER defined?[*]Is your PHP version 5.0.0+?[*]Are you sure $filename contains a valid URL? (Did you echo it?)[/list] Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61288 Share on other sites More sharing options...
dnienhaus Posted July 20, 2006 Author Share Posted July 20, 2006 here the full page code :[code]<?php$username="root";$password="";$database="engineering";mysql_connect(localhost,$username,$password);@mysql_select_db($database) or die( "Unable to select database");if(!empty($_POST['search'])){echo '<h1>test</h1>';$query="SELECT * FROM Assembly WHERE PARTNUMBER LIKE '%" . $_POST['search'] . "%'";$result=mysql_query($query) or die(mysql_error()); if($result != false){echo "Here are the results:<br><br>";echo "<table width=90% align=center border=1><tr><td align=center bgcolor=#00FFFF><b>Creation Date</b></td><td align=center bgcolor=#00FFFF><b>Creator</b></td><td align=center bgcolor=#00FFFF><b>Nomenclature</b></td><td align=center bgcolor=#00FFFF><b>OBID</b></td><td align=center bgcolor=#00FFFF><b>Part Number</b></td><td align=center bgcolor=#00FFFF><b>Part Drawing</b></td></tr>";while ($r = mysql_fetch_array($result)) { // Begin while$CREATIONDATE = $r["CREATIONDATE"];$CREATOR = $r["CREATOR"];$NOMENCLATURE = $r["NOMENCLATURE"];$OBID = $r["OBID"];$PARTNUMBER = $r["PARTNUMBER"];$PARTNUMBER = str_replace('"','',$PARTNUMBER); $url = "'http://intranet/engineering/drawings/$PARTNUMBER.pdf'";include ('checkfile.php');echo "<tr><td><center>$CREATIONDATE</center></td><td><center>$CREATOR</center></td><td><center>$NOMENCLATURE</center></td><td><center>$OBID</center></td><td><center><b>$PARTNUMBER</b></center></td><td><center>$url</center></td></tr><br><br><hr>";} // end whileecho "</table>";} else { echo "problems...."; }} else {echo "Search string is empty. <br> Go back and type a string to search";} ?>[/code]its grabbing checkfile.php which is the file_exists function and always returning false.Partnumber is definedPHP is 5+url is valid i can paste it in my browser and open the file and yes it's on a business network. Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61292 Share on other sites More sharing options...
wildteen88 Posted July 20, 2006 Share Posted July 20, 2006 You'll want to remove the quotes from the $url variable, so its this:[code]$url = "http://intranet/engineering/drawings/$PARTNUMBER.pdf";[/code] Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61295 Share on other sites More sharing options...
dnienhaus Posted July 20, 2006 Author Share Posted July 20, 2006 for some reason when i do that it doesn't parse the variable and the link shows up as "http://intranet/engineering/drawings/$PARTNUMBER.pdf" and not the part #.... Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61298 Share on other sites More sharing options...
wildteen88 Posted July 20, 2006 Share Posted July 20, 2006 Try this:[code]$url = "http://intranet/engineering/drawings/{$PARTNUMBER}.pdf";[/code] Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61299 Share on other sites More sharing options...
effigy Posted July 20, 2006 Share Posted July 20, 2006 According to the manual, this works with [i]some[/i] URL wrappers. I could not get it to work.... There's always:[code]<?php $url = 'http://www.google.com'; echo $url, '...', fopen($url, 'r') ? 'Yes' : 'No' ;?>[/code] Link to comment https://forums.phpfreaks.com/topic/15190-php-file_exists/#findComment-61301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.