"preg_match" For What purpose this command use?

Reply

Join Date: Sep 2004
Posts: 2
Reputation: qadeer is an unknown quantity at this point 
Solved Threads: 0
qadeer qadeer is offline Offline
Newbie Poster

"preg_match" For What purpose this command use?

 
0
  #1
Sep 7th, 2004
This command working but i do't understand it ??? i am writing funtion in which it using please guid me..


<?php
$dbHost="localhost";
$dbLogin="root";
$dbPassword="123";
$dbName="test12";
$query="";
$error="";
$mySqlError="";
$connect = mysql_connect( $dbHost, $dbLogin, $dbPassword ) ;
if ( !mysql_select_db( $dbName ) )
{
return "<p>Error: Database[ $dbName ] could not be located p>" ;
}
$fp = fopen ("database2.txt", "r") ;
while (!feof ($fp))
{
$query="";
$error="";
$buff = fgets($fp, 1000);

if ( preg_match( "/(DROP TABLE)/", $buff ) )
{
$query = substr( $buff, 0, strlen( $buff ) - 2 ) ;
$query = stripslashes( $query ) ;
$res = mysql_query( $query, $connect ) ;
$mySqlError .= mysql_error() ;
}

if ( preg_match( "/(CREATE TABLE)/", $buff ) )
{
$query .= $buff ;
if ( !preg_match( "/\) TYPE=MyISAM/", $buff ) )
{
while ( $buff = fgets( $fp, 500 ) )
{
if ( preg_match( "/\) TYPE=MyISAM/", $buff ) ){ break 1 ; }
$query .= $buff ;
}
if ( !preg_match( "/\) TYPE=MyISAM/", $query ) )
$query = "$query);" ;
}
$query = stripslashes( $query ) ;
$res = mysql_query( $query, $connect ) ;
$mySqlError .= mysql_error() ;
}

if ( preg_match( "/(INSERT INTO)/", $buff ) )
{
$query = substr( $buff, 0, strlen( $buff ) - 2 ) ;
$query = stripslashes( $query ) ;
$res = mysql_query( $query, $connect ) ;
$mySqlError .= mysql_error() ;
}
}
fclose( $fp ) ;
mysql_close( $connect ) ;
if ( $mySqlError )
{
$error = "<p>Error: Following database error(s) were generated:<br>$mySqlError<p>" ;
}
return $error ;


?>




With Best Regards
Qadeer Ahmad
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: "preg_match" For What purpose this command use?

 
0
  #2
Sep 8th, 2004
http://www.php.net/preg_match will answer your question.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC