Jump to content

I got the text from that but i am unable to check with another string


sasi

Recommended Posts

$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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.