Jump to content

jackpf

Members
  • Posts

    1,410
  • Joined

  • Last visited

    Never

Everything posted by jackpf

  1. Oh yeah, I nicked it from one of my php scripts, I forgot to remove the escaped quotes lol. Yeah, 13 is the enter key. Oh, I forgot to call the function with the event. This should work better <script> function enter_button(e) { if(e.which == 13 || e.keycode == 13) { button_function(); window.stop(); document.execCommand('Stop'); } } function button_function() { alert("button function!"); } </script> <input type="text" onkeyup="enter_button(event);" /><br /> <input type="button" onclick="button_function();" />
  2. Could try something like this function enter_button(e) { if(e.which == 13 || e.keycode == 13) { do_what_your_button_does(); window.stop(); document.execCommand(\'Stop\'); } } //and then <input type="text" onkeyup="enter_button();" />
  3. echo '<a href="#" onclick="DOCALL(\''.$ere.'\');">test</a>';
  4. Well, no offense, but how are we supposed to know then? If you don't even know how your own site works, how are we supposed to?
  5. Yeah, but the problem with updating a database when users log in/out is that they might not necessarily log out. They could just close their browser which would result in them being displayed as online well....forever. If you follow my method you avoid that, as you can time them out. I fetch all users with a unix stamp >= time() - 600, which is 10 minutes. So if a user hasn't requested a page in the last ten minutes, they're considered offline. The ajax solution is basically the same, except it will check if the user is viewing pages as well. However, this would put a lot of strain on the server. Obv the more you update the database, the slower it's going to be. But yeah, that's how I did it. Works well for me.
  6. This will be an interesting read - http://uk2.php.net/internals2.ze1.zendapi
  7. Yeah, that's not how you retreive stuff from a db. The variable containing the query is just a resource pointer. You may want to look up a tutorial or something. You need to call the results with something like mysql_fetch_array().
  8. Just wondering...what's the point in that?
  9. echo the $_POST variables rather than the $_COOKIE ones?
  10. Why would you want to use wordpress? That's no fun. You don't learn anything. That's generally when you get people on here saying "I tried to edit this, but i just get a blank page" because they have no idea what they're doing. And how can you "do away with PHP" when wordpress is probably written in it? Even so, that'd mean you are totally reliant on WP. That's not cool.
  11. Oh yeah, didn't even notice that lol. Time for jack to go to bed...
  12. Yeah, you see that text "A Member Has Invited You To Chat. Click Ok To View. ('Clicking Ok Will Not Accept The Chat Invite It Will Show You Who Has Invited You To Chat')" Change that....?
  13. No, an expiry of 0 causes it to act like a session cookie. So it expires when the browser is closed or whatever. Can't you read chap?!
  14. Update a userid and timestamp with every page request. I made a system like this a while ago Check it out - http://www.jackpf.co.uk. Somewhere around the middle it'll say who's online, how many strangers etc. It also updates the location of the user, so I can figure out who's viewing what thread on the forum.
  15. How's it going to give you an error when you've got no error handling? Put or die(mysql_error()) after the query.
  16. Try this <html> <head> <title>Calling text formatting from PHP stored variables and applying to entered text</title> </head> <body> <form method="post" action="textoutput.php"> <!-- Input text and select colour, font & size --> <p> Enter your test text: <input type="text" size="60" name="testtext" /></p> <p> Select a text colour: <select style="width: 150px;" id="textcolour" name="textcolour" /> <option value="red">Red</option> <option value="purple">Purple</option> <option value="blue">Blue</option> <option value="black">Black</option> </select></p> <p> Select a font type: <select style="width: 150px;" id="fonttype" name="fonttype" /> <option value="Verdana">Verdana</option> <option value="New Times Roman">New Times Roman</option> <option value="Arial">Arial</option> </select></p> <p> Select a font size: <select style="width: 150px;" id="fontsize" name="fontsize" /> <option value="10px">10pt</option> <option value="12px">12pt</option> <option value="16px">16pt</option> <option value="20px">20pt</option> </select></p> <p> <label for="savedata">Save as a cookie?<label> <input type="checkbox" id="savedata" name="savedata" value="1" /> </p> <input type="submit" name="process" value="Process" /> </form> </body> </html> <?php if (isset($_POST['savedata'])) { setcookie("testtext", $_POST['testtext'], 0, '/', FALSE); setcookie("textcolour", $_POST['textcolour'], 0, '/', FALSE); setcookie("fonttype", $_POST['fonttype'], 0, '/', FALSE); setcookie("fontsize", $_POST['fontsize'], 0, '/', FALSE); } /* session_start(); Removed to see if the cookie is saving $_SESSION['testtext'] = $_POST['testtext']; $_SESSION['textcolour'] = $_POST['textcolour']; $_SESSION['fonttype'] = $_POST['fonttype']; $_SESSION['fontsize'] = $_POST['fontsize']; */ ?> <html> <head> <title>The Output of textinput.php</title> </head> <body> <p>The following text was entered and processed using the options you set for it:</p> <p <?php echo 'style="color:' . $_COOKIE['textcolour'] . '; ' . 'font-family:' . $_COOKIE['fonttype'] . '; ' . 'font-size:' . $_COOKIE['fontsize'] . ';"'; ?>> <?php echo $_COOKIE['testtext']; ?></p> </body> </html> Oh, and also, the values you have just set won't be in the $_COOKIE array (unless you put them there) until the next page refresh, because obviously your browser has requested the page before the cookies are set, so hasn't sent them to PHP .
  17. Setting the domain as "localhost" doesn't work for me. I always define the domain as FALSE on my local box. Seems to work for me.
  18. You could try setting a cookie like so: setcookie("testtext", $_POST['testtext'],time()+60, '/', 'www.yourdomain.com'); With the extra arguments of the path and domain name. They're not required but idk...could help. If that doesn't work, just try setting a cookie normally and see if it works. Also, try something like this: if (!isset($_POST['savedata'])) { die('the checkbox is not set!'); } else { die('the checkbox is set'); }
  19. Idk, I'm not entirely sure how that script works as I didn't write it. Try echoing out your queries to see if they're what you think they are.
  20. They're both the exact same script, just with a different query string. IE, $_GET['currentpage'] will be 2 in the second case and null on the first.
×
×
  • 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.