Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Can never really have too many answers to your question in my opinion. When ever I answer something and see someone else has replied first I just check what they put, i think the varied solutions can be helpful to someone learning. Only once have I seen it turn into some kind of 'reply war' where I think the original author of the topic just got confused... A
  2. Interesting. I wasn't even aware it was slower. IE7 results are shocking! Do you have the script available for people to test on their own machines? A
  3. Hah of course, I even knew that function existed just never thought about it. Though reading the PHP manual, it doesn't make it particularly clear that it only returns the first result. Ah well, sorted now thanks a lot! A
  4. Continuing my last topic which I frst thought was solved (http://www.phpfreaks.com/forums/index.php/topic,231586.0.html) .. I have a new problem, with the expression: \[pre\].+?\[\/pre\] With preg_replace it replaces all occurences of the matched string, but preg_match only seems to match the first? $str = '[tag]This should be replaced with ::tag:: and added to $matches[/tag] .. [tag]So should this![/tag] But this shouldn\'t!'; preg_match('#\[tag\].+?\[\/tag\]#', $str, $matches); $str = preg_replace('#\[tag\].+?\[\/tag\]#', '::tag::', $str); print 'After preg_replace: ' . $str . '<br />Matches from preg_match:<pre>'; print_r($matches); print '</pre><br /><br />'; That will return something like: I'm stuck ??? Anyone? Cheers! A
  5. Put the login HTML between the two curly braces: else { // if they have not submitted the form } A
  6. Perfect cheers! A
  7. Got a probs common problem with a greedy dot! I'm trying to get around it by supplying characters it can't be. Here's an example: [tag]SELECT THIS![/tag] and [tag]SELECT THIS SEPERATELY![/tag] The problem I'm getting is that it's returning the whole string, it's finding the first occurence of [tag] and the very last occurence of [/tag]. My regular expression looks like this at the minute: \[tag\].+\[\/tag\] I've tried many variations like: \[tag\][^\[\/tag\]]+\[\/tag\] But they are treated as individual characters instead of as a whole word. Anybody know a solution?? Cheers! A
  8. Bit busy at the moment, but al knock something up for you soon as I can.. A
  9. Try what I said before; exporting your login code to another file (such as login.php) .. and redirect back to the current page on success. You should be able to test if they're logged in, in the same way you are doing now - assuming the session data has been setup correctly. A
  10. Perhaps rather than having the login tests on your home page, would be easier for you to create a login.php page? Then you can simply test if they have been logged in, redirect if so, or display an error. The way you're doing it at the minute is.. If they've submitted the login form, run the login tests, else, display the page. You're basically either displaying the page, or trying to log them in but not displaying no output if successful. Note the: } else { // if they have not submitted the form ?> ... just before your HTML. Try adding instead of the "header()" function: echo 'Login successful!'; A
  11. You can actually setup PHP to parse any files.. Which would mean you can still have PHP functionality in your .asx files. Then to stop users viewing the content of the asx file through their browser, setup a global variable within your normal / 'parent' script that would include the asx file, such as: define('included', true); Then test for this in your asx file. Obviously it will work when the parents script includes it, but hide the content or whatever when the user tries to view it through their browser. The only problem I could think of would be if media player used this file, but if not, why the need for it to be a .asx file extension? There would probs be a work around for media player though.. A
  12. You're getting a white page because you're not sending them anywhere or printing anything to the screen. // if login is ok then we add a cookie and send them to the correct page { $username = stripslashes($username); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); // Finds out the user type $query = "SELECT `admin` FROM `users` WHERE `username` = '" . $username . "'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $admin = $row['admin']; $_SESSION['admin'] = $admin; } Underneath "$_SESSION['admin'] = $admin" you need to add: header("Location: page/to/redirect/to.php"); A
  13. Whoops, my post was supposed to say.. "Why not [ pre ]...[ /pre ] ??" .. But I see what you mean now, in a sense the parser is 'greedy' and wants to parse everything. I've never done anything like this so totally going off an idea, but why not extract everything between [pre ][ /pre] tags into an array, replacing with some special identifier such as "::pre::", parsing the rest of the code, then using str_replace() to replace the occurences of ::pre:: with your array?? Technically it should work, but somebody else might have a better idea? A
  14. Perhaps something along the lines of HTML's <pre> tag? Why not [pre]...[/pre] ?? A
  15. http://www.colorsontheweb.com/colorwizard.asp Try entering a color like #333333 in there and seeing what you can find. Click the "complimentary" tab at the bottom and playing around with the slides.. Eventually you'll come up with several colors that blend really well. I've found that tool very useful before... A
  16. mysql_real_escape_string() isn't always the best choice depending upon the data you're expecting. There's a whole range of functions you can use to filter your inputs... Just never leave an input variable unsecured! A
  17. Post your code exactly as you have it.. A
  18. What exactly doesn't work with it, are you getting an error? It's possible your email providers see it as spam, check your spam folder! Who is your email provider? AOL are extremely hard to please! A
  19. Plenty of tutorials out there... http://www.google.co.uk/search?q=online+users+php+tutorial A
  20. Not bad. I'd highlight the current date though? A
  21. I have to agree with dmccabe. Sometimes people come here only to have the odd question solved and aren't interested in spending time reading stickies, looking for solved buttons, etc. Someone won't waste more than a few seconds looking for a button, that really doesn't effect them, when they want to get back to their work. However as they reply to say.. "Cheers, worked!" - which most people do - if there was a quick check box or something there for them to tick, I'm sure a lot more of the solved topics would actually be classed as solved... A
  22. Think the minimum wage at the moment in the UK for more than 16 < 21 is £5.00, £5.50 after 21.. Also about the "Fias physics engines" - could be their framework / project under way? A
  23. Ignore that!
  24. What error do you get in Firefox's error console? I don't think you can create an object like this outside of a function: var image = document.getElementById('changeimage'); Try adding it inside the function.. A
  25. I think he's asking how though as JS runs after the page has loaded, which means that to test PHP-side for a cookie set via JS, you could only do it on the second request? ..and I didn't know that, cheers! A
×
×
  • 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.