Jump to content

johnnyk

Members
  • Posts

    126
  • Joined

  • Last visited

Everything posted by johnnyk

  1. Does NOW() in MySQL change according to daylight savings? If it does, should I use ... INTERVAL + 5 + date(I)? Also, what's the correct way to add an interval in MySQL? Now() + INTERVAL 5 or DATE_ADD(NOW(), INTERVAL 5 HOURS)
  2. [!--quoteo(post=385797:date=Jun 19 2006, 05:11 PM:name=Wildbug)--][div class=\'quotetop\']QUOTE(Wildbug @ Jun 19 2006, 05:11 PM) [snapback]385797[/snapback][/div][div class=\'quotemain\'][!--quotec--] You might have to use parantheses to make it unambiguous, but, yes:[code]echo "You have " . ($a < 4 ? 'less than four' : 'four or more') . " items.";[/code] [/quote] It's not working for me. echo '<h5 class="class">' . $row['a'] . ((isset($row['b'])) ? 'text') . "</h5><br />\n"; //line 30 is producing Parse error: syntax error, unexpected ')' in page.html on line 30
  3. My fault for not making myself clear. What I mean is is it possible to use a ternary operator in the middle of an echo? Something that would mimic: [code] echo 'You have'; if($a >= 4){    echo 'equal to or more than 4'; }else{    echo 'less than 4'; } echo "items<br />\n"; [/code] I can't find a way to do that with ternary operator (without including the whole phrase, You...items, on each evaulation of the conditional).
  4. Is it possible to use a ternary operator on the same line as an echo (using the conditional to modify the echo)?
  5. [!--quoteo(post=385777:date=Jun 19 2006, 03:43 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 19 2006, 03:43 PM) [snapback]385777[/snapback][/div][div class=\'quotemain\'][!--quotec--] Yes as the mysql_fetch_array returns an array with both associative and number indices if you want to use numbers for the array keys use this: mysql_fetch_array(mysql_query("SELECT a, b FROM `table`"), MYSQL_NUM) But if you want letters for the array keys use this: mysql_fetch_array(mysql_query("SELECT a, b FROM `table`"), MYSQL_ASSOC) [/quote] Why does it return it as both? Would specifying MYSQL_NUM or MYSQL_ASSOC make it return the results faster?
  6. [code] $row = mysql_fetch_array(mysql_query("SELECT a, b FROM `table`")) print_r($row); /*outputs: Array (     [0] => text     [a] => text     [1] => blah blah blah     [b] => blah blah blah ) */ [/code] Why is each column placed in the array twice? Is that supposed to happen?
  7. Thanks alot for all the info!
  8. I usually keep a file of functions that I regularly use. I include this file on every page. Obviously, not every function is used on every page. Is it bad to include all the functions, considering maybe only 2/5 will be used on any given page. Does it slow down the loading of the page or anything?
  9. johnnyk

    exit

    That's the only way to do it? Just wondering cause I always indent my conditionals and the bulk of the code would be in the first }else{ (where the "yada yada yada" is), which would make the code a little harder to read/write
  10. johnnyk

    Regex

    Oh man my fault. I just realized I used strip_tags() to strip everything but <ol> and <li>. Thanks alot.
  11. johnnyk

    exit

    So is there a way to stop the script just from executing the parent conditional but printing everything else?
  12. johnnyk

    Regex

    More regex - why isn't /<DL><DD>(.*?)<\/DD>/si matching <I>text.</I> [b]<DL><DD>text.</DD>[/b]</DL><HR ALIGN="LEFT" .....
  13. johnnyk

    exit

    So here's what I got: [code]<?php if(isset($_POST['a'])){      if(empty($_POST['a'])){         echo 'a is empty';         exit;      }      echo 'yada yada yada'; }else{    echo 'blah blah blah'; } echo 'not in conditional'; ?> </body></html>[/code] What's happening is that if a set but is empty, "a is empty" is echoed, but the page is completely blank after that. When a is set (and not empty), I want "yada yada yada", "not in conditional" and "</body></html>" to all be printed (that works as it is now). When a is set but empty, I want only "a is empty", "not in conditional" and "</body></html>" to be printed. I know I could just add "not in conditional" and "</body></html>" to the TRUE and FALSE of the main conditional, but is there an easier way?
  14. johnnyk

    Regex

    So what exactly was wrong with my regex. I thought it said "match any characters (except for a bullet end), until you find a bullet end." And what if I wanted it to not stop at \n (/regex/s) AND be case insensitive (/regex/i)? How would I combine them?
  15. johnnyk

    Regex

    Why doesn't /<OL><LI>.[^<\/LI>]*<\/LI>/s match <OL><LI><OL TYPE="a"><LI TYPE="a">text.</LI> Wouldn't . include <OL TYPE="a"><LI TYPE="a"> Also, if I wanted to make it single line and case insensitive, what would I do? Would it just be /regex/si?
  16. [!--quoteo(post=377741:date=May 27 2006, 10:20 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ May 27 2006, 10:20 PM) [snapback]377741[/snapback][/div][div class=\'quotemain\'][!--quotec--] Actually if it generates a timestamp there is no difference. Basically mktime() generates local timestamps, and gmmktime() GMT timestamps. [/quote] Ah I see, I see. I didn't really understand what a unix timestamp was. It all makes sense now. But why 1970?
  17. I don't understand why this happens: [code] $date = getdate(mktime(0, 0, 0, 5, 27, 2006)); echo $date['weekday']; //Saturday (correct) [/code] [code] $date = getdate(gmmktime(0, 0, 0, 5, 27, 2006)); echo $date['weekday']; //Friday (incorrect) [/code] What makes mktime() and gmmktime() different? I know gmmktime() is based on GMT time, but I don't understand why that makes a difference since the user is providing the date and time. Maybe I don't make sense. Let me know.
  18. I'm running a script and sometimes it returns stuff like 8-4 BC/BCE – 29-36 AD/CE when it should echo 8-4 BC/BCE – 29-36 AD/CE and Móshe (מֹש×?Ö¶× when it should echo מֹשֶׁה is there a function or anything that will convert the string either to simple letters or to what it should be? The stuff before "when it should echo" is what the script actually echoes, the stuff after is what the text looks like before it reaches the script (the script is reading other files). Or is it just a problem with my page encoding?
  19. johnnyk

    Regex

    Edit: Doesn't work. It looked like it would, don't know why it doesnt. Edit dos: I got it to work with $pattern = "/<p>((A |An |The )?)<b>$word<\/b> ((.[^\.]*)?(Jr\.)?(.[^\.]*))(\.|\?|!)/i"; but did I do more than I had to? Edit 3: The above works, but also continues on to find second period even if Jr. isn't found.
  20. johnnyk

    Regex

    /<p>((A |An |The )?)<b>Theodore Roosevelt<\/b>.[^\.]*(\.|\?|!)/i I'm newish at regex, so I can't figure this out out. The above regex basically matches up until it finds punctuation. For example, the following would be a match: <p><b>Theodore Roosevent</b> text text text. BUT, I want it to ignore certain punctiation, for example the period after Jr., so that it would be able to match <p><b>Theodore Roosevent</b> (Theodore Roosevelt Jr.) is a really cool guy. I would want it to ignore the . after Jr and go all the way up to the end of the sentence. I tried a bunch of things out but couldn't figure it out. Any help would be mucho appreciated.
  21. Wasn't going to, but the other one got confusing and the problem ended up not being the problem i listed as the title. If I could have deleted I would have.
  22. readfile(http://en.wikipedia.org/wiki/PHP); // line 15 results in Warning: readfile(http://en.wikipedia.org/wiki/PHP): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in page.php on line 15 Anyone know why?
  23. Edit: Forget it, post name confusing, started other post
  24. I heard fsockopen would stop the 403, but I tried it out and it won't make a connection at all. At least I don't think it makes a connection cause the script aint working.
×
×
  • 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.