dnienhaus Posted July 21, 2006 Share Posted July 21, 2006 I am trying to validate links before the print on a page. My problem is I am using a variable in the link itself and it does not parse until runtime right? So when my checkfile.php is called to check if the link exists it always says no because it is seeing "http://intranet/engineering/drawings/{$PARTNUMBER}.pdf" instead of the link with the partnumber thats called. I need to know if there is a way to have the link umm get the part number before it validates it. Anybody have a clue?search.php[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]checkfile.php[code]<?php$link = $url;echo "Checking: $link<br><br>\n"; flush();$fp = @fopen($link, "r");if (!$fp) { echo "No File"; }else { fclose($fp); echo "Yay it's there!"; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/ Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 anybody? Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61716 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 You only posted this an hour ago, give us some time to see it....You don't need the curly braces in this line:[code]<?PHP $url = "http://intranet/engineering/drawings/{$PARTNUMBER}.pdf"; ?>[/code]remove them.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61720 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 didn't change anything... Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61763 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 Is the file you're looking for on the same system as the running script? If so, do not use "http://" in the filespec, just use the local path.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61769 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 the problem is not with the file its with using the $PARTNUMBER variable in the url and i can't figure out how to get it to read whats stored in the variable instead of the plaintext $PARTNUMBER. Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61776 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 This code:[code]<?php $url = "http://intranet/engineering/drawings/$PARTNUMBER.pdf"; ?>[/code]or[code]<?php $url = 'http://intranet/engineering/drawings/' . $PARTNUMBER '.pdf'; ?>[/code]Will put the value of $PARTNUMBER into the string $url. Echo the string $url after the assignment.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61780 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 returns blank page :( Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61785 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 Please post your current code again.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61789 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 Updated code:search.php[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';echo "$url";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]checkfile.php[code]<?php$link = $url;echo "Checking: $link<br><br>\n"; flush();$fp = @fopen($link, "r");if (!$fp) { echo "No File"; }else { fclose($fp); echo "Yay it's there!"; }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61792 Share on other sites More sharing options...
kungfu71186 Posted July 21, 2006 Share Posted July 21, 2006 $url = 'http://intranet/engineering/drawings/' . $PARTNUMBER '.pdf';i think it should be$url = 'http://intranet/engineering/drawings/' . $PARTNUMBER . '.pdf';or it may not matter. but you can try. Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61797 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 got rid of the blank page but url still doesn't validate. and it does exist. i have the same problem still nothing has changed. bummer. Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61801 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 When you say "blank page", do you mean that no text is showing on your page?Make sure all errors are being shown by putting[code]<?php error_reporting(E_ALL); ?>[/code]at the start of your code.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61802 Share on other sites More sharing options...
True`Logic Posted July 21, 2006 Share Posted July 21, 2006 use file_exists("~" . $PARTNUMBER . ".php") or die("no such file") (replaceing ~ with that url that i was to lazy to type)... Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61805 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 if i copy and paste the url it has it open the file so it does exist just won't say so. returns...testHere are the results:no such file Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61811 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 Are you allowed to use "http://" in the filespec. Check to make sure that the ini directive allow_url_fopen is set to "1". Also, remove the "@" from infront of the fopen, that could be surpressing a critical error message.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61822 Share on other sites More sharing options...
dnienhaus Posted July 21, 2006 Author Share Posted July 21, 2006 testHere are the results:Checking: http://intranet/engineering/drawings/024T-G4203.pdfNo File http://intranet/engineering/drawings/024T-G4203.pdfwhen i copy and paste that the file opens so ahhh! No errors either. Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61825 Share on other sites More sharing options...
ryanlwh Posted July 21, 2006 Share Posted July 21, 2006 are you sure you can access http://intranet ??? Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61843 Share on other sites More sharing options...
kenrbnsn Posted July 21, 2006 Share Posted July 21, 2006 Remember, since PHP runs on the server it may not have access to the same files/domains you have when running from the browser.Ken Quote Link to comment https://forums.phpfreaks.com/topic/15267-ahhhh-help/#findComment-61905 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.