Jump to content

joe92

Members
  • Posts

    304
  • Joined

  • Last visited

Everything posted by joe92

  1. Ah, well I'm afraid I have very little knowledge on POSIX regex as I've only learnt PCRE (do note that the patterns are different between POSIX and PCRE). That's because POSIX regex functions were deprecated in php as of version 5.3.0 and as a result this board is ultimately PCRE only now too. I have never used Textpad so can't help you there either. Maybe you could try a textpad forum if there is one? I think it's the spammers which have made you do image verification etc.. When I changed my registered email they deactivated my account till I verified my new one... what if I'd made a typo! haha. Good luck, Joe
  2. Please use the code tag on code $string ="yada yada yada<pre>This is what I wants to see!</pre>"; preg_match('/<pre.*?>(.*?[<pre.*?>.*<\/pre>]*)<\/pre>/', $string, $matches); echo $matches[1]; If you place this into mysql you will most likely be using common basic security such as htmlentities or htmlspecialchars on the input both of which converts the < and > into their respective html codes, < and >. After saying this I've come to realise I don't really know what your problem is... Could you please ask the question again in a way that we could understand? What's the regex being used for? Cheers, Joe
  3. Hi, if this were in a database it would be so much easier Anyway, this is untested but I think your best line of approach is to preg_match_all both items and match up the matches. So the first is a file name which is enclosed in square brackets try this: preg_match_all("/(?<=[)[^\]]/sm", $text, $file_matches); Then for the comment, a bit trickier. It always starts after '- COMMENT -' and ends when the next item begins with a square bracket. It can also cover multiple lines so we can't stop at the end line. You could try the following which is almost identical to above, but you would have to make sure that there were no start square brackets within the comment: preg_match_all("/(?<=- COMMENT -)[^\[]/sm", $text, $comment_matches); Preg_match_all will place the matches into a multi dimensional array and since there is a comment for every file name you should just be able to match up the matches and if there isn't (but there's still the word comment) it will just match up the blank space inbetween. So to print the results: <?php //file name in position $file_matches[0][0] will match up with comment in position $comment_matches[0][0] etc $count = count($file_matches[0]); for($i=0;$i<$count;++$i) { echo $file_matches[0][$i].'<br/>'; echo $comment_matches[0][$i]; } Hope this helps you, Joe
  4. http://static.thepiratebay.org/legal/sopa.txt That is interesting. It seems like the movie industry is built from patent infringement...
  5. Looks like it had a bit of an effect. Several senators have now changed their minds: https://rt.com/news/sopa-pipa-senators-oppose-189/
  6. I have found an e-petition for citizens of the UK to sign regarding our concern against SOPA and PIPA. The e-petition is asking that the UK government officially condemn SOPA and PIPA. We need international pressure against the USA regarding these acts as well as pressure from it's own soil. I have already signed it and will be posting it around the place (starting here). It takes 100,000 signatures for an e-petition to be brought to the governments attention so I ask that you please sign it too! You need to give your name, address and email address. You then need to verify the email address and your signature is added. https://submissions.epetitions.direct.gov.uk/petitions/26143 You can also sign this e-petition from elsewhere in the world, but I don't know whether you are added to the signature count? If someone could verify whether or not non UK individuals can affect the count, that would be nice. Cheers, Joe
  7. I know, this was posted in humour
  8. http://www.happyplace.com/13509/alternative-information-sources-while-wikipedia-is-down
  9. Preg_match_all prints it's results into a multidimensional array. To get the results you need to print out position[0][0] for the first result and position[0][1] for the second etc.. Also, what abareplace said was right, that was awfully sloppy of me. The dot will match any character except a newline so you need to escape it, my mistake. This should fix it: <?php if(isset($_POST['Store'])) { $mainUrl = 'http://www.grasshopper3d.com/forum/categories/sample-and-example-files/listForCategory'; //search for all URLs with www.grasshopper3d/forum/topics/bla preg_match_all("/discussion\./", $mainUrl, $urlMatches); //escape the dot $fileName = "urls.txt"; $urlFile = fopen($fileName, 'w') or die("Cant open file"); echo('matches: '. $urlMatches[0][0]); //multidimensional array so print position [0][0] //fwrite($urlFile, $urlMatches) or die("Cant write to file"); } ?>
  10. Have you seen Urban Dictionary too? They have a cracking definition of what SOPA is and they have censored out their logo haha.
  11. It's not officially dead yet :-\ And a blackout is still happening... tomorrow, http://sopablackout.org/ Wiki and Wordpress are the two big names that are participating. Plus there's still the matter of PIPA which is supposedly just as bad, though it's hasn't been discussed as much.
  12. You need delimiters round your pattern, turn this preg_match_all("discussion.", $mainUrl, $urlMatches); into this preg_match_all("/discussion./", $mainUrl, $urlMatches); A delimiter (the '/'s in this case) tells the regex engine what the boundaries of the pattern are. They are compulsory for all regex patterns. However, do note that this will return no matches. That is going to look for a match of 'discussion.' in the url string that you have provided.
  13. Good point, yes I did.
  14. That picture is hilarious! The internet and the first electric motor were both invented by British people, ergo we win.
  15. Twice in two days you've solved my problems . That is a cracking function, does exactly what I need, thanks PFMaBiSmAd
  16. An admin of a site I am creating needs to be able to create members with certain extra authorities, moderators if you will. They will create the members and insert all the details. However, they also need to keep paper records of these moderators with all the details on them. On these paper records is included the ID of the moderator. So I wish to display on screen after the member has been created, the members ID so the admin can make a note of it. This is the query being used (shortened): $new = mysql_query("INSERT INTO members (ID, name) VALUES (NULL, '$name')"); Without again querying the database am I able to find out what the value of the newly created ID is, that NULL value? Google has revealed nothing so far. Thanks for any help, Joe
  17. Now I feel so foolish for not printing the mysql_error() That has worked perfectly, thank you!
  18. Is it possible (and faster) to combine updating two tables in the same database into one query where the WHERE clause is identical? I cannot combine the tables together unfortunately and I can't seem to get these queries combined. Just to note, it definitely works prior to trying to combine the two. The queries trying to combine: <?php //first query $query1 = mysql_query("UPDATE table1 SET item1 = '$newItem1', date = CURDATE() WHERE ID = '$id' "); //second query $query2 = mysql_query("UPDATE table2 SET item2 = '$newItem2' WHERE ID = '$id' "); I have tried the following code but it does not work? <?php //combine the two queries? $query = mysql_query("UPDATE table1 AS a, table2 AS b SET a.item1 = '$newItem1', a.date = CURDATE(), b.item2 = '$newItem2' WHERE ID = '$id' "); Thanks for any help, Joe
  19. The new lines were causing an error. Didn't realise that javascript didn't allow new lines in a string. Sorted now.
  20. I am trying to create 3 elements on the fly when a button is clicked. The button is the show an upload form for images. I am using uploadify (first time using it) and I have several different upload type/options for them so I am sending id's to differentiate between them. The problem I am having is when trying to create the script tag which in turn controls the input file type tag, and it is baffling me. Here's the code first: var scriptContent = "$(document).ready(function() { $('#"+newid+"').uploadify({ 'uploader' : 'uploadify/uploadify.swf', 'script' : '?ajax=uploadElement&id="+newid+"&updateValue=Image&inputType=image', 'cancelImg' : 'uploadify/cancel.png', 'folder' : 'uploads', 'auto' : false, 'multi' : false, 'onAllComplete' : function(event,data) {alert(data.filesUploaded + ' files uploaded successfully!');} }); }); "; var scriptTag = document.createElement('script'); scriptTag.innerHTML = scriptContent; And this is the error: unterminated string literal [break On This Error] var scriptContent = "$(document).ready(function() { --------------------^ And this is what JSLint says about it: Error: Problem at line 1 character 21: Unclosed string. var scriptContent = "$(document).ready(function() { Problem at line 1 character 21: Stopping. (10% scanned). The error would indicate there is something wrong with the string. First thing that came to mind was that because there is a $ sign the string was searching for a variable (even if it is within a js file) so I changed the opening and closing speech marks to single quotations and cancelled the others with backslashes. This made no difference and gave me the same error, instead pointing to a single quotation instead of a speech mark. I then tried just removing the dollar signs altogether, no difference. So I undid all of that and moved the string into a variable before the scriptTag variable is created (beforehand was just placing it straight into the innerHTML) thinking maybe I should reference the content. That didn't work either. I am at loss here and I have no idea what is wrong with that string. Can you see anything wrong with it? Am I going about this the wrong way? I have multiple upload forms on the same screen because I wish for the user to be able to handle each image individually. I only want new upload forms to be shown when asked for. Any help is greatly appreciated, Joe
  21. You'd be surprised at how little this has hit the British domain. The useless BBC News has ranted on for days about Kim Jong Dead but mentioned nothing of this bill, or the one about being able to detain American citizens without trail. I have to watch things like RT to get that news, but then they put a massive bias slant on news about America. I think they still have a chip on their shoulder from the past 100 years
  22. Got it sorted. When you locate the element on the page and then ask to display it, it will display something like [object HTML....Element]. By converting this into a string I could use the javascript match to look for which type of element it was and act accordingly. After looking at a list of every single tag available (and testing on tags I didn't know) I found that the only tags that actually need javascripts value to display on screen the contents are input tags and textareas. Here is my code should anyone run into a similar problem: <?php /*locate element*/ var element = document.getElementById(id); /*turn [object HTML....Element] into a string that says just that*/ var el = new String(element); /*match the string with value elements to produce value as the output*/ if(el.match(/Input/g) || el.match(/TextArea/g)) { /*fill the value*/ element.value = thisItem; } /*since the huge majority of elements are actually filled using innerHTML, this is the else clause*/ else{ /*fill innerHTML*/ element.innerHTML = thisItem; }
  23. Does anyone know of a way that JavaScript could figure out whether it is to use .innerHTML or .value with a command? I.e. I have one function that is to change the contents of a group of elements within a for loop. I don't know whether the element that is currently being changed is going to be a div or a textarea so I would need to be able to figure out on the fly whether to use the .innerHTML or .value command with my function. Thanks for any help, Joe
×
×
  • 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.