Jump to content

bobbinsbro

Members
  • Posts

    385
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male

bobbinsbro's Achievements

Member

Member (2/5)

0

Reputation

  1. thank you very much, that did the trick. i didn't know about greedy and non-greedy. nice to learn new things.
  2. the pattern i gave is part of a much longer pattern, that is supposed to match long blocks of text containing many quote-delimited strings. i originally tried what you suggested, but preg_match() didn't stop at the first quote (the one on which i need to end the sub-pattern) but rather continued to the very last quote, counting all intermediate quotes as part of the (.*) sub-pattern. so i tried using matching any character that isn't the backreference to force preg_match() to stop on the first quote found. i need to use the back reference because i need to allow both single and double quotes in all places, and i can't know which in advance. example of a string i want to match: and the pattern $pattern = '/(\'|")([^\1])(\1)/s'; should match only but doesn't match anything. using $pattern = '/(\'|")(.*)(\1)/s'; matches which is not what i want
  3. the problem is that doesn't work. i'm trying to get the contents of a string delimited by either double quotes ("...") or single quotes ('...'). the regex i'm using is: $pattern = '/(\'|")([^\1]*)(?:\1)/s' that doesn't work. however, changing it to $pattern = '/(\'|")([^\']*)(?:\1)/s' does work (assuming the string is delimited by single quotes). i checked and made sure that \1 contains a single or double quote (used preg_match() with the optional &$matches argument and print_r()'ed $matches to see what is in the sub-patterns). as a result, i assume either i can't use a backreference in a character class or i'm doing something wrong.
  4. regular expressions http://www.phpfreaks.com/tutorial/regular-expressions-part1---basic-syntax or if the string inside which the substring you want is static (always the same) you could use strcmp (case sensitive), strcasecmp (case insensitive), substr, strstr or something similar (chack out the functions on this page http://us2.php.net/manual/en/book.strings.php.
  5. hi all how would i go about using a backreference in a character class in a pcre regex pattern? example of something similar to what i want to do: $pattern = '/(abc)([^\1]).*/'; thanks in advance bob
  6. hi phpfreaks i need to test to see if a static method is declared in an abstract class. i can't use method_exists() because that requires an instance of the class. i looked at is_callable(), but it looks like i would have the same problem there. is there a way to check if a static method is declared in an abstract class without having to use a try...catch block to find out by way of trial and error? thanx in advance.
  7. hi all. i am working on a website for a client whose host only allows uploads to be up to 8MB per file. users of this site may legitimately attempt to upload larger files. is there any way to make the client post the file in chunks and reassemble them on the server? i found a thread on a different forum referring to a java applet that does this, but i'd rather use a php solution if at all possible. i thought i'd try to use javascript to split the file into chunks and send each chunk with an XHR, but i discovered only IE allows file manipulation in js via active-x (which makes sense, as allowing js to manipulate files would be a tremendous security problem). is there anyone out there who has any inkling how this can be done in a java-free way?
  8. set the method attribute in the html <form> to be method="post" (like this <form method="post") and in the php code retrieve the variables via the $_POST superglobal instead of the $_GET.
  9. hi all. i'm using an <object> tag to load dynamic content into a static html template without using javascript (otherwise i would use a <div>). i would like the size of the <object> to stretch to the size of the content, like a div does. basically, i want to have to scroll the page and not the <object>. is there any way to do this, or should i consider a different solution? i really want to do achieve this (or a similar result) without using javascript. thanx in advance.
  10. figured it out for myself. i was including the static html into index.php, so all the paths would have to be relative to index.php and not to the html file as i was doing. silly me.
  11. hi all. i'm using an <object> tag to load dynamically generated content (by a php script) into a static .html page. the idea is to have only the contents of a certain <div> change without using javascript. my html looks like this: <html> <head> <title>a page</title> </head> <body> a page <div> <!--[if IE]> <object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="content.html"> Dynamic page content </object> <![endif]--> <!--[if !IE]> <--> <object type="text/html" data="content.html"> Dynamic page content </object> <!--> <![endif]--> </div> </body> </html> i got the conditional comments from some website after discovering that IE needed the clsid. my problem is that for some reason i can't fathom, instead of loading content.html, what gets loaded into the object are another copy of the above html in which the alt object text appears (see attached screenshot of the page in FF 3.0.6). the page is stored in /public/html/ and so i content.html. however, the page is called by index.php which resides in /public/. when i tried setting data="/content.html", instead of the page being nested, i get the alternate object text. the same happens when i try data="/html/content.html". a few examples of things i tried putting in content.html: 1) <html><body>index page</body></html> 2) index page what am i doing wrong? thanx in advance. [attachment deleted by admin]
  12. i will definitely use that. i was using simpleXML because i thought that it had less of a memory footprint (since it's a so much smaller class), but i didn't test my theory, which was a bit daft of me. i just ran a test, and the difference is about 100 bytes... i feel kinda silly. thanx Dj Kat.
  13. ok. in more depth. this is a permissions editing thing. the permissions are stored as an xml string in a DB. i get said string from the db, load it into a simplXMLElement. in the bit of code i pasted, i'm changing a user's permissions. heres the logic: that's what the code posted above does. an example: before i run the code <security> <perm1> <user>1</user> <user>2</user> </perm1> <perm2> </perm2> <perm3> </perm3> </security> now, i edit user 2, and move him to perm2 node. this is the result in the DB: <security> <perm1> <user>1</user> </perm1> <perm2> <user>2</user> </perm2> <perm3> </perm3> </security> i dumped the contents of the temporary xml string (the variable $xmlStr) and the '<' '>' characters are intact. then i dumped the simpleXMLElement object after i set $xmlStr into the permission node, and the '<' changed to '<'. as i said, i tried doing the same thing with addChild() with the same results. i should note that in a different place in the same code i use addChild() and the xml is created just fine. is there a way to prevent simpleXML from htmlentities()-ing my xml string (since i think that this is a security measure of the simpleXML class)?
  14. i checked out the source HTML of both the working html and the faulty php-generated html. the php 1 just stops here: <td class="sponsorbg"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="5"> <tr> <td align="center"> </td> </tr> <tr> the working html continues for a quite a while and ends properly (</html>). as a result, there's probably a fatal php error here (this is the php code immediately after the point where the faulty html ends): <?php $randoms = array(); $start =1; $total =11; while (count($random) < 3) { $random = mt_rand($start,$total); if (!in_array($random, $randoms)) { $randoms[] = $random; } } $captions = array("RBC","Prodomax","Liews Motors","Advanced Motion Controls","Burnside","TD Canada Trust","Reinhart","SCDSB","ARO","Stayner Lions","test","ComTek"); $urls = array("http://www.royalbank.com", "http://prodomax.com/","http://a-m-c.com/","http://www.rjburnside.com/","http://tdcanadatrust.com","http://www.reinhartfoods.com/", "http://www.scdsb.on.ca/", "http://www.aronet.com/", "http://www.lionsclubs.org/","test","http://www.comtekcomputers.com/"); for ( $i = 0; $i < 3; $i++){ print $randoms[$i]; $caps = $captions[$randoms[$i]];; $img = $urls[$randoms[$i]]; } ?> turn on error reporting and post any errors you get when loading the page please
×
×
  • 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.