Jump to content

salathe

Staff Alumni
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by salathe

  1. The start tag of the heredoc block is END but the end tag is _END. They need to match.
  2. Ice cubes, yes. But the nine iron was a 1-wood.
  3. See the code that I posted a while ago. It's under the comment that says // Load XML document.
  4. He doesn't. But I know what you did last summer.
  5. For the second code block, where is $xml created (you use it in the foreach but it isn't defined anywhere your post)?
  6. Wow. $text = <<<_END drop some text and some stuff plus this stuff some other stuff _END; Should have been: $text = <<<_END drop some text and some stuff plus this stuff some other stuff _END; Note the lack of a tab character (or any other space) before _END; This is all very clearly outlined in the PHP manual, see PFMaBiSmAd's latest post.
  7. Trying, and failing.
  8. You might also like to use SimpleXML, which is supposed to make accessing XML "simple". To get the first link from within a feed item, you can simply do: $feed = simplexml_load_file('http://feeds.bbci.co.uk/news/video_and_audio/science_and_environment/rss.xml'); $link = (string) $feed->channel->item->link; echo $link; Be sure to read through the examples page.
  9. There should be no space before _END;
  10. Haha, good one!
  11. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=334552.0
  12. Please, don't suggest using the @ operator in a help thread.
  13. You could also use SimpleXML like: // Load XML document $xml = simplexml_load_file('XML URL'); // Build an array of actor names like array("Actor #1", "Actor #2", ...) $actors = array(); foreach ($xml->actor as $actor) { $actors[] = (string) $actor; } // Echo with commas echo implode(", ", $actors);
  14. I never have a problem with getting logged out here, I'm "remember me"-ed on multiple machines in multiple locations. I feel your pain, but these things happen. I have a habit of copying the post content into my clipboard before pressing the preview or post button.
  15. No matter what the value of $var is, that will return TRUE. Correction: no matter what the value of $var is, that will return FALSE. *stalks*
  16. The error points you right at the location of the problem (between the equals sign, and the 1). In XML, attributes must be wrapped in quotes (single or double, it doesn't matter). So, your resulting XML needs to look like: <node id="1">
  17. salathe

    PHP or JS

    Yep. A perfectly cromulent sentence, I might add.
  18. Excellent, have fun with your script.
  19. salathe

    PHP or JS

    http://phpjs.org/ -- blending doesn't always a good result make!
  20. Both. The XML has bad/invalid parts (see the warnings and earlier replies) and the way that you're trying to access the resourceURL attributes is wrong. To fix the former, don't use broken URLs in namespace declarations (xmlns=...). To fix the latter, read through the basic SimpleXML examples page in the manual. Have a stab at fixing the problems yourself, and let us know how you get on.
  21. Your check_email() function returns TRUE if the email address does not match the regular expression and FALSE if the address does match the regular expression. Your script looks to see if check_email() returned TRUE, and if it did then the email is sent via mail(). This logic seems backward to me: the email gets sent if the address does not look like an email address.
  22. Canguingo, please take the time to read the documentation (it takes a lot of effort to write it!) and understand how to use the functions that are suggested. It looks like you're just using them incorrectly. I gave you plenty of links through to the manual showing everything that you need to know. stripos Your code was: if (eregi("to:", $field) || eregi("cc:", $field) || eregi("bcc:", $field)) { Each of the eregi("...", $field) should become (stripos($field, "...") !== FALSE). That will behave in the same way as your old code. Another option is to use an equivalent PCRE regex: if (preg_match('/to:|cc:|bcc:/', $field)) { delimiters As mentioned in the manual (I gave you this link earlier), PCRE patterns need delimiters whereas POSIX ones do not. Your check_email() function already uses PCRE and has delimiters.
  23. Both of those code snippets suffer from the same problem, the variable containing any given line from the file ($refile and $line respectively) will contain the newline character(s) at the end of the IP address. Since the string "1.2.3.4\n" is not the same as "1.2.3.4", none of the comparisons are doing the job as expected. Options are plenty and varied, so take your pick. A simple one is to manipulate the variable within the loop to remove the trailing newline character(s), rtrim() (docs) would be fine for that. For the code using file(), you can pass various flags into the function call to change the default behaviour, a useful flag in this case is FILE_IGNORE_NEW_LINES (docs).
  24. The proper solution is to migrate your code to using one or more functions which are not considered deprecated. For regular expressions, that would be the PCRE functions (preg_match(), preg_replace(), etc.). An introduction to the differences between POSIX (ereg(), ereg_replace(), etc.) and PCRE functions can be found in the manual. Many times, simple string functions can also be used. In your case, the eregi() function calls could be changed to use stripos().
×
×
  • 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.