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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.