Jump to content


  • Posts

  • Joined

  • Last visited


Posts posted by abhi_madhani

  1. Hi Phpfreaks,


    I have written this following code, it take any given URL of, and searches and list all 'ABC' links found in that given page. Then it goes through each 'ABC' link or page, searches and list all 'XYZ' links. The code works perfectly till here.


    Now I am planning to recursive search, where if more 'ABC' links are present inside each 'ABC' page, it should search and list them and 'XYZ' links, and this could go to many levels deep. It is more or less similar to 'Recursive Directory Listing' which lists the directory structure of folder and files, but in HTML page.


    I am still learning PHP Basic's, so any help even in simplifying my method of code would be grateful.

    I have attached the dummy file that I have been working on, kindly find it attached.


    Example ::


    ABC page
    ABC Link 1
    	XYZ Link 1.1
    	XYZ Link 1.2
    	XYZ Link 1.3
    ABC Link 2
    	XYZ Link 2.1
    	XYZ Link 2.2
    ABC Link 3
    	ABC Link 3-1
    		XYZ Link 3-1.1
    		XYZ Link 3-1.2
    		XYZ Link 3-1.3
    	ABC Link 3-2
    		XYZ Link 3-2.1
    		XYZ Link 3-2.1
    		XYZ Link 3-2.1
    	XYZ Link 3.1
    	XYZ Link 3.2
    ABC Link 4



    My code is as follows ......


    $url = "abclistA.html";
    $needle = "abc"; $needle1 = "xyz";
    echo '<table border="1">';
    $acontents = file_get_contents($url);
    if (strpos($acontents, $needle)==!false) {
    	foreach ($abc[0] as $akey => $abcrecord) {
    		echo '<tr><td>'.$abc[2][$akey].'</td></tr>';
    		$xcontents = file_get_contents($abc[1][$akey]);
    		if(strpos($xcontents, $needle1)!==false) {
    			foreach ($xyz[0] as $xkey => $xyzrecord) {
    				echo '<tr><td>'.$xyz[2][$xkey].'</td></tr>';
    			// Planning to use this 'goto' shortcut, that when it again find ABC link inside ABC page, 
    			// 	it should go to begining of this code and rerun it.
    			// However this time $url will be changed with suburl that needs to scanned.
    			// This doesn't seem to work.
    			/*if (strpos($xcontents, $needle)==!false) {
    				$url = $abc[1][$akey];
    				echo " S-MF ";
    				goto ABCfound;
    			} else { echo " S-MNF "; } */
    		} else { echo " SNF ";	}
    } else { echo " MNF "; }
    echo '</table>';


  2. I am trying to extract URL's from html page by using following Regular Expression.

    <a href="      (....till....)     "> Name </a>




    It works perfectly on most URL's. But it fails to recognise following kind of urls in HTML.


    http://en.wikipedia.org/wiki/B'ham - Note the single quotation in the B'ham.


    The URL's in the HTML are not encoded for special characters, hence I have to build my regex to count in URL's which have special characters in them.

    Could anyone guide me for solutions towards this bend?



  3. Hi,


    I am using a PHP's preg_match() to search through string, and displaying its pattern, but want to display only part of it.


    E.g. looks like




    The search displays " class='PHPfreaks' "


    From the search I would like to display only the part highlighted in bold. " '/shape=\'.*\'/sU' "

    So the final value to be displayed should be      " PHPfreaks "




  4. Hi,


    I am not that good with understanding REGEX/REGEXP functions but,

    Could someone please let me know as how can I search through html code for a particular tag having a definite start and definite end.


    E.g. HTML Code below, it has


    definite Start of

    <div id="ST


    and definite End of



    <div id="ST12345678_st" class="r_right_col">
    <div class=""></div>
    <div id=""><span class=""></span></div>
    <div class=""></div>
    <div class=""><span class=""></span></div>
    <div class=""></div>
    <div class="">
    	<div style="" id=""


    So the HTML file which I have, has the this particular tag being repeated atleast more than 50 times in whole code.


    And I am planning to extract each of them seperately. So if someone could help me with REGEX to search for this particular tags in whole file, would be really helpful.



    Abhishek Madhani


  5. Hi,



    I am trying to verify if the given url exists or not, by using file_exists() function.


    It always returns 'FALSE' , according to my understanding it happening because the file to be checked on the given url is located in safe mode.


    Could anyone please suggest as to how this could be overcome, by similar function or by using alternative method.



    Abhishek Madhani

  6. Hi


    In If, ElseIf, Else logic,

    the ElseIf logic is only run, when its preceding IF/ElseIf has appeared to be false. and if its comes true it makes a exit, (That's the case I think is with your code.)


    Because the second ElseIF (Instructor) is coming true, it straight away execute the that logic, and makes a exit without reading ElseIf (Course).


    So I hope it clears the road bit.



  7. Hi,


    The url can be accessed in normal browser,


    Your suggestion is possible that the source server has script in place, which only allows browsers to make the request, and not any to any other type of applications or scripts.


    My website url might not be blocked, but it could be my hosts server's ip address that is blocked.


    I will try to implement curl() to accomplish this task, and will see how can the identity be faked as a real browser. Thanks for your suggestion, will post here back if any of the solutions works.

  8. hi,


    try this solution


    $paragraph = '300 had not been then, greece would not have been now';
    $paragraph1 = 'if 300 had not been then, greece would not have been now';
    $var1 = '300';
    if (stripos($paragraph, $var1)=='0') {
    echo 'it works';
    else {
    echo 'it doesnt';


    now try changing $paragraph with $paragraph1 in stripos.



  9. Hi,


    I am trying to fetch a file with function file_get_contents() from a website, but am getting following error.


    [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /data/22/1/27/17/1842180/user/1999295/htdocs/web/modules/index.php on line 14.


    using following code,


    	$content = file_get_contents($source);
    $handle = fopen($destination, 'wb');
    fwrite($handle, $content);


    does it have something to with http header, which might be required to set as HTTP/1.1 in php




  10. Hi,


    I am using PHP mail() function to sent message. Following is the code, the message is received in email account, but as attachment, not displayed in the body section as normal message would.


    Please can you guys help, as why is this message going as attachment, but not being displayed in the body of email.


    Below is the url which gives preview as to what I mean.




    	$to = $_POST['to'];
    $subject = ' web visior';
    $customer = stripslashes($_POST['customer']);
    $email = stripslashes($_POST['email']);
    $contactinfo = stripslashes($_POST['contactinfo']);
    $body = stripslashes($_POST['enquiry']);
    $header =  	'From:'.$email.'\r\n';
    $header = 	'Reply-To:'.$email.'\r\n';
    $header = 	'X-Mailer: PHP/' . phpversion();
    $header = 	'Content-type: text/html\r\n';
    $message = 	'<html><body>
    				<tr><td>Contact No'.$contactinfo.'</td></tr>
    				<tr><td style="center"><b>Message:</b></td></tr>





  11. Hi, Friends


    I am retrieving records from a database and using a while loop to display each record in tabular format. While displaying each record I am trying to store a section of that record e.g. 'Postcode' in a new custom array.


    I am trying to store the Postcode of each record at new location of an array. E.g. First record is stored at

    [0] => 'EC1N 8WE', then second record is stored at [1] => 'B16 9RE', then third record is stored at [2] => 'TW19 6QW'

    , and so on in a same array.


    Can anybody please guide me as to how can I achieve this.


    echo "		<html>
    		$viewprodSQL="select * from product where fieldname='term' ";
    		$exeviewprodSQL=mysql_query($viewprodSQL) or die (mysql_error);
                            $n = 0;
    		while ($thisviewprodarray=mysql_fetch_array($exeviewprodSQL))
    echo "				<td><img src=".$imgloc." width='125' height='125'></td>";
    echo "		</tr>

  12. Hi Friends,


    I have created a search page, that displays the results for particular entered search terms, something similar to Google Image Search engine.


    I am trying to display the first five records of the results on 1st row, and next five records on 2nd row, and next five records on 3rd row and so on


    Can any of you please guide me as to how can I achieve this. I have attached a sample code of my page which reads each record from the database and displays them.



    echo "		<html>
    		$viewprodSQL="select * from product where fieldname='term' ";
    		$exeviewprodSQL=mysql_query($viewprodSQL) or die (mysql_error);
    		while ($thisviewprodarray=mysql_fetch_array($exeviewprodSQL))
    echo "				<td>
    				<img src=".$imgloc." width='125' height='125'>
    echo "		</tr>

  13. Hi, Friends


    I am using a file upload utility, can anyone please shed some light on the working of this code, especially on the copy function.


    $max_size = '2097152';
    if ($_FILES["filename"]["size"] > $max_size) die ("<b>File too big!  Try again...</b>");
    copy($_FILES["picone"]["tmp_name"],$imagelocation.$_FILES["picone"]["name"]) or die("<b>Unknown error!</b>");




  14. Hi, friends


    I am trying to store a value in a session array, and calling it on second page, but instead of displaying all the records, its just displaying the 2nd record out of many on the next page.


    Can you guys please help me as to why this is not happening.


    First page - it retrieves the result from database and displays in a table.


    $filelistSQL="select * from files";
    $exelistarray=mysql_query($filelistSQL) or die (mysql_error);
    while ($filelistarray=mysql_fetch_array($exelistarray))
    	$_SESSION['filename']= array('id' => $filelistarray['id'],
    		'merchantid' => $filelistarray['merchantid'],
    		'filelocation' => $filelistarray['flocation']);
    	echo "<tr>";
    	echo "<td>".$filelistarray['id']."</td>";
    	echo "<td>".$filelistarray['merchantid']."</td>";
    	echo "<td>".$filelistarray['flocation']."</td>";
    	echo "</tr>";



    Second page grabs the value from the $_SESSION and displays them in a page. Its just displays the 2nd record not 1st and other remaining records


    foreach ($_SESSION['filename'] as $i => $filevalue)
    	echo $_SESSION['filename'][$i];




  15. Hi, hacklive


    What you have suggested is exact solution, but just for a single excel file.


    The admin will have many excel files to process, and for that it may not be possible using the above mentioned method. Is there any other solution, that can process many files together.


    The uploaded excel files, are not just ordinary files, that are product files for merchants,

    which will be stored in the database.

    Once the products from particular merchants are stored, then anybody can view them via Web Interface.


    I am building a site just similar to 'Auction or Shopping website' but where sellers can upload their products via excel file.



  16. Hi hacklive


    Yes exactly what you have mentioned, that something that can retrieve data from excel files, and store them in database,


    This below mentioned Future and advance coding, only to be done once the above step is accomplished.

    the reverse options is not that important, because if a member can upload only one excel file. and if he uploads a new file, than all his previous data stored in database will also be updated with new changes.

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