Jump to content

kektex

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kektex's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Alex, Thanks for your help . How can I use create_function to solve this problem? Im not very knowledgeable in PHP , I am just trying to fix an error in an existing script.
  2. Just from searching the board I realize this has been asked sooo many times, but I can't seem to locate the problem in this code: usort($status, function($a, $b) {global $sort; return strcmp($a[$sort], $b[$sort]); }); foreach(array_merge(array($cols), $status) as $line) call_user_func_array('printf', array_merge(array($fmt), $line)); print_r($print); I'm getting a " Parse error: syntax error, unexpected T_FUNCTION in ui.php " on the first line of this script. The weird thing is that when I run the script on my PC using EasyPHP I don't get the error, it only happens on my Linux server. Any ideas? Thanks!
  3. Thanks MadTechie your fix in my code worked great! I went through your other code but since I dont know that much PHP I had a hard time understanding it.I will go through it later once I get a bit more PHP savvy. Also, thanks BlueSkyIS, I will also take a look at your code when I'm learning about multidimensional arrays. I think I might improve my script later on using those arrays.
  4. Actually my problem is not the regex or finding the URLs and descriptions, my code already does that. The problem I´m having is outputting the URL and it´s respective anchor text to a text file. An example link: <a href="out.php?url=http://www.example.com/exampledocument.html" target="_blank" class="id" title="LINK DESCRIPTION">Link Description</a> I managed to pull the link from the a href without any problems as well as the LINK DESCRIPTION ( I could have also taken it from the anchor text, they are the same.) What I want to do is output both things to a text file like this: http://www.example.com/exampledocument.html | LINK DESCRIPTION Is there any way to use foreach to do this or should I try to use a multi-dimensional array (not that I know how to do that anyway but I'll just read up on it).
  5. Hello, I have been searching all afternoon for an answer to this and haven´t found a solution so my last resort is asking here I am collecting links from a few documents on our site using this: <?php $data = file_get_contents('http://www.example.com/'); preg_match_all("/out\.php\?url\=(.+?)\" target/",$data,$match); preg_match_all("/class\=\"id\" title\=\"(.+?)\"/",$data,$desc); foreach($match[1] as $url ) && foreach($desc[1] as $fulldesc){ echo urldecode($url); echo "\| $fulldesc<br>"; } ?> Basically , I want to output all the links and their respective descriptions separated by a pipe character. But reading from the two arrays is giving me a bit of a hard time.I now know I cannot use the && operator, I just left it in so you guys could see what I´m trying to do. How can I do this? I´m not much of a programmer but from what I have read the other option I have is using multi-dimensional arrays? I might be extracting the URL, the description and then some more data later on so this might be a better approach. Thanks for any help or advice.
  6. Sorry I take so long to answer, I´m trying to read as much as possible so I don´t come here asking dumb questions I checked $url as you suggested and I noticed that somehow there was some extra whitespace on the file I´m reading the domains from and that´s why I dont get the expected output. I used trim() to remove the whitespace and now it´s working! Thank you very much for your help effigy!
  7. Yes sorry, I should have specified I already had used file_get_contents: <?php $dominios = file("dominios.txt"); foreach($dominios as $check){ $url = file_get_contents('http://www.example.com'); preg_match_all("/<b> Estatus del dominio:<\/b> (.+)/", $url, $output); echo count($output) ."<br>"; print_r($output)."<br>"; echo is_array($output). "<br>"; foreach($output[1] as $keyword){ $keywords .= $keyword."\r\n"; } echo "$keywords"; } ?>
  8. Sorry that I didn't reply sooner, I was trying effigy's fix, but I couldn't get any output and I was just reading up on arrays and stuff to see where my problem was. Here is the code I have so far: preg_match_all("/<b> Estatus del dominio:<\/b> (.+)/", $url, $output); echo count($output) ."<br>"; print_r($output)."<br>"; echo is_array($output). "<br>"; foreach($output[1] as $keyword){ $keywords .= $keyword."\r\n"; } echo "$keywords"; And this is the output I'm getting: 2 Array ( [0] => Array ( ) [1] => Array ( ) ) 1 Notice: Undefined variable: keywords in C:\Documents and Settings\PC\Mis documentos\PHP\check2.php on line 23 The first part of the code (the count() and is_array() ) is just me testing some of the stuff I read. Why am I getting a "2" in the count()? The regex should be matching only one string on the page I'm grabbing. Then I notice that apparently the array is empty : [0] => Array ( ) Does this mean that the regex is not working? Now, I have to admit I do not understand much of the part where I try to print out the array: $keywords .= $keyword."\r\n"; I took that from a script I had where I was doing a similar thing and everything worked perfectly. I have a huge PHP book I just got (Beginning PHP and MySQL) and that's what I'm using to guide myself here. Thanks for your help effigy. I'm just starting to learn PHP and regexes are giving me a hard time.
  9. Hello, I am a newbie trying to write a script for personal use to check for domain availability at a ccTLD registrar. I am basically just grabbing the whois results page and looking for status codes which can be "activo" or "suspendido".Otherwise the domain is available (disponible). I tried just using eregi() to look for the status codes and return the status.This wasn´t working, for some reason it always told me everything was DISPONIBLE (available), and then I read at php.net that apparently eregi() has a 255 character limit (see http://www.php.net/manual/en/function.eregi.php#69582 ) I tried using preg_match_all but my regex skills aren´t that good because I cant get it to work. This is the part I´m interested in from a sample whois query: <b> Fecha de Vencimiento:</b> 2007-03-06 02:49:24 <b> Ultima Actualizacion:</b> 2006-02-06 18:25:48 <b> Fecha de Creacion:</b> 2006-02-06 02:49:24 <b> Estatus del dominio:</b> SUSPENDIDO <b> Servidor(es) de Nombres de Dominio:</b> I tried this and it didn´t work of course : preg_match_all("/<b> Estatus del dominio:<\/b> (.+?)/", $url, $output); Can anyone give me a hand with the regex or point me to some other, more suitable function for doing this? Thanks!
  10. I just checked the regex with this tool :  http://regexlib.com/RETester.aspx and it works great. Maybe theres something wrong with my php configuration? I have a similar script running without any problems so I dont think that´s the problem.
  11. Now I get this: Array ( [0] => Array ( ) [1] => Array ( ) ) I´m guessing the regular expression is not right and the array is empty?
  12. I get the same error when I substitute [color=blue]echo $result."<br />";[/color]  with  [color=blue]print_r($result);[/color]: Notice: Undefined offset: 3 in c:\xxxxx.php on line 9
  13. [b]I found the error in the code...I had some blank spaces in a place there shouldn´t have been any.The regex was correct.Thanks for the help thorpe![/b] Hello, Im trying to extract all URLs from an html file.The links I´m interested in have this formatting: <a style="clear:all;" href="http://www.example.com">Example Anchor</a> I´m using this code to extract the URL: [code] $data = file_get_contents('file.html'); preg_match_all("/<a style=\"clear:all\;\" href=\"(.+?)\"> /", $data, $result); $result = $result[3]; echo $result."<br />"; [/code] All I get is the following error: Notice: Undefined offset: 3 in c:\xxxxx.php on line 9 I´m a newbie to PHP and I´ve been reading about regex and arrays but I can´t seem to find what´s wrong here.I´m thinking it´s the array since the error says something about the offset.I´m just basing this on some code I found that does a similar job to the one I need to do. Thanks for any help!
×
×
  • 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.