Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Daniel0

    Class vs. ID

    Yeah, but according to W3C all ids have to be unique in order to be valid XHTML:[quote]An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).[/quote] So you could just use an id attribute on things you know you will be using javascript on.
  2. You could also use [url=http://php.net/mysql_real_escape_string]mysql_real_escape_string[/url].
  3. In the shell, if you use Linux, you could do something like this: [code]daniel@daniel:~$ mysql -u root -p Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 36 to server version: 5.0.22-Debian_0ubuntu6.06-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SET GLOBAL time_zone = '+1:00';[/code] Or in PHP you could do it in this way: [code]<?php $link = mysql_connect("localhost","root","password"); mysql_query("SET GLOBAL time_zone = '+1:00';"); ?>[/code] These examples will set the timezone to GMT+1 (CET).
  4. Try putting [code] or die(mysql_error())[/code] after the mysql_query so it becomes [code]$rs_INV = mysql_query( $q_INV, $db ) or die(mysql_error());[/code] and see if it returnss any error.
  5. [quote author=ShogunWarrior link=topic=99947.msg393997#msg393997 date=1152456375]I changed the XML a bit, didn't make sense to me.[/quote] Probably because it had an invalid syntax ;)
  6. It appears that you forgot to end an echo/print with a semi-colon ( ; ) on line 117 in index.php
  7. [code]$timestamp = 'some_unix_timestamp_here'; // replace it with a timestamp $query = mysql_query("SELECT * FROM some_table WHERE timestamp<=".time()." AND timestamp>={$timestamp}"); if(mysql_num_rows($query) <= 0) { echo "No things from ".date('r')." untill now"; } else { while($row = mysql_fetch_assoc($query)); { // do stuff } }[/code] In case you have it in a database where the date is stored as a UNIX timestamp, which would be the prefered way to do it.
  8. You may also consider [url=http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html]fulltext searches[/url].
  9. Ahh, just run the through htmlentities() as Ken said ;)
  10. Put this on the page [code]<script type='text/javascript'> settimeout('location.href=location.href',5000); </script>[/code] To refresh it every 5 seconds.
  11. You can't, well you can, that is how you get spyware on your computer I believe. But why would you like to force a file onto the user's disk ???
  12. For that you'd want to use AJAX (Asynchronous JavaScript And XML). You can read about it at these links: http://www.w3schools.com/ajax/default.asp [url=http://en.wikipedia.org/wiki/Ajax_(programming)]http://en.wikipedia.org/wiki/Ajax_(programming)[/url] http://developer.mozilla.org/en/docs/AJAX:Getting_Started Your example script won't work by the way, you are sending a header after outputting.
  13. [quote author=kenrbnsn link=topic=99929.msg393836#msg393836 date=1152416357] What do mean by: [quote]t also has to be able to pass through preg_replace without causing any errors (it likes to fail evaluation on some characters)[/quote] [/quote] I think he is using it for his BBCodes. Here is an example of the [b]bold[/b], [i]italic[/i] and [u]underline[/u] BBCodes: [code]$t = preg_replace("`\[b\](.*)\[/b\]`sUi","<b>\\1</b>",$t); $t = preg_replace("`\[i\](.*)\[/i\]`sUi","<i>\\1</i>",$t); $t = preg_replace("`\[u\](.*)\[/u\]`sUi","<u>\\1</u>",$t);[/code]
  14. If you, as you say, put it at the end of the file, then it is unnecessary as it is automaticly done at the end of the script execution. I have actually seen an example where a script without used less memory than one with mysql_free_result(). I do not think it is necessary to call this function.
  15. You just put this in the very top of the file: [code]session_start()[/code]
  16. Why do you define everything as a session variable first?
  17. [code]$browser = get_browser(null, true); $browser = $browser['parent'];[/code] This would get the browser name and version (i.e. Firefox 1.5).
  18. Use accesskey to make shortcuts. Like here were alt+s submits the post form.
  19. 1. Read tutorials 2. Code a lot 3. Look at other code to see how things are done That's the way I learned it.
  20. [quote author=Barand link=topic=99806.msg393477#msg393477 date=1152349816] [quote author=smith.james0 link=topic=99806.msg393225#msg393225 date=1152295491] Second question If i change the column type will it keep all the date? (varchar(200) change to int(5,2)) [/quote] valid integer values should be retained. What is int(5,2)? [/quote] I believe int(5,2) would be an integer of that is 5 characters long with 2 decimals - but then it's a float and not an integer :S ???
  21. Daniel0

    Numbers

    Yeah, sometimes I just think 'why would anyone use time on writing all this' on some of the Wikipedia articles.
  22. Yeah, I know that one. But I just thought if it were able to see in that example if 07 or 08 is the month...
  23. Heh 8) Note that this will only work if the date is ALWAYS in that format and if it always have leading zeroes.
  24. Daniel0

    Numbers

    http://en.wikipedia.org/wiki/List_of_numbers Man somebody must have been bored :o
  25. Ok, here is the new code:[code]<?php //... $timestamp = "2006.07.08 01:41:10"; // i suppose this comes from somewere else function convert($t) { $year = substr($t,0,4); $month = substr($t,5,2); $day = substr($t,8,2); $hour = substr($t,11,2); $minute = substr($t,14,2); $second = substr($t,17,2); return mktime($hour,$minute,$second,$month,$day,$year); } $timestamp = convert($timestamp); if($timestamp+(3600*4) >= time()) { // within four hours echo "Within four hours old"; } else { // not within four hours echo "Not within four hours old"; } ?>[/code] There was an error in the old code, so don't use it, use this.
×
×
  • 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.