sasi Posted April 12, 2007 Share Posted April 12, 2007 $string = "/home/localftp1/DTFFiles/tr_his1240.dtf"; preg_match('|/([^/]+)\z|', $string, $match); echo $match[1]; hello thank you very much i got the result with your code,but now watch the following code: <?php $username="root"; $password=""; $database="mic"; $host="localhost"; $flag = true; $search=$_POST['search'];//text field value where we give the file name with ext as input //echo $search."<br>"; mysql_connect($host,$username,$password); mysql_select_db($database) or die( "Unable to select database"); $fsearch="SELECT Fname from logging"; $result1=mysql_query($fsearch); $num1=mysql_num_rows($result1); while($row = mysql_fetch_array($result1)) { $fstring=$row['Fname']; preg_match('|/([^/]+)\z|', $fstring, $match); //echo $match[1]."<br>"; foreach($match as $value) { //echo $value."<br>"; if($value === $search){ echo "File Found:".$search."<br>"; break; } else{ echo "File Not Found:".$search."<br>"; break; } } } ?> now if i had given some filename with extension in the text field, that value is compared and if found then i have to display that file is founded but in the while loop i am getting all the values from the database and then i am parsing that string and getting only the filename from that and later unable to compare. please respond to this as early as possible. Quote Link to comment 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.