Jump to content

genericnumber1

Members
  • Posts

    1,858
  • Joined

  • Last visited

    Never

Everything posted by genericnumber1

  1. You might try collecting quite a few more data samples (minimum 3, maximum as many as possible) and curve fitting for an attempt at the function. That function can give you a better idea of the underlying formula.
  2. when you concatenate strings, you do it with '.', not '+'. The plus will attempt to add the two strings and give unpredictable results. Use the concatenation operator Eg. $a2 = $a2 . "-left";
  3. As a heads up, you might want to be more specific about what your problem is and isolate the issue more. It will increase your likelihood of a reply.
  4. Try echoing the $query_worksRS after it has been constructed. From that point you will probably be able to figure out the problem.
  5. Then why not use existing IDEs such as NetBeans (free) or Zend Studio (not free) that already have that? Some people love to reinvent the wheel. But dude, I totally have an idea for a enneakaidecagonal wheel. Since it has flat sides, it can rest easily when the wheeled structure isn't supposed to move. Don't tell anyone, the patent isn't finalized yet.
  6. Your best bet would be to take an existing PHP grammar (see: http://www.phpcompiler.org/doc/latest/grammar.html) and modify it to fit YACC's notation. Edit: This one LOOKS like yacc's notation, but I'm not sure, I don't have much experience with YACC... http://gcov.php.net/PHP_5_3/lcov_html/var/php_gcov/PHP_5_3/Zend/zend_language_parser.y.gcov.php Another grammar... http://www.icosaedro.it/articoli/php-syntax-ebnf.txt
  7. Well, depending on what $db->execute does, it could be prepared statements or just a normal string replacement. To me it looks like those are probably prepared statements, but I'm not familiar with the class you're using to interface with your database.
  8. Unless you use prepared statements (you don't above) you're not protected no matter what database you use.
  9. mysql_real_escape_string is the method I always suggest (if you use the mysql_* family of functions). There's a lot of good information posted around about avoiding sql injection
  10. trim (with 1 parameter) strips all white space from the edges of the first parameter. The % in %string% is just a wildcard for the LIKE sql keyword. Google "SQL LIKE" for more information. PS. The code you posted is vulnerable to SQL injection.
  11. I'm sorry, I just skimmed your original code, not spending much attention. You might want to look into list() and each() to see what my mistake was, but the short fix is to swap $rdate with $d and $url with $u. That said, why have two seperate loops? Just place the logic in this loop we're creating in the while loop that does mysql_fetch_assoc to begin with.
  12. Yes, it will loop through both arrays linearly, terminating execution when one of the arrays runs out of data members. Note this means that if one array (let's call it L) has more elements than the other array (let's call it S), the loop will only iterate through count(S) elements of L.
  13. Well, conditions wouldn't be the right word to use, because they're not really conditions. They're more like expressions. As far as I know, there are no ways to (linearly) loop through two arrays using only the foreach loop. That said, <?php while(list(,$rdate) = each($d) && list(,$url) = each($u)) { } ?> Would be comparable to your desired loop, although it's a bit difficult to read. There are cleaner ways of doing what you're suggesting.
  14. This is a common problem you could find a solution for by doing a forum search. That said, your query was probably invalid. add "or die(mysql_error());" after your query function. If you can't figure out what I mean, a forum search will find a post that has a more detailed solution.
  15. can you tell us what problem you're having with the function you posted? I can see a few things like not doing $menu .= on the recursive call, but there may be deeper issues I'm not seeing.
  16. mysql_fetch_array and the related functions work on an internal pointer. You can easily reset this pointer with mysql_field_seek/mysql_data_seek if you feel that is the best way to reuse data from a query result. Alternatively, you could simply save the value in a variable and use it later.
  17. The problem is that the number "1313527373619043141" can't fit in an integer, so it sticks it in a double. Unfortunately there's no easy way of dealing with this other than to be running it on a 64 bit system (If PHP will even allow 64 bit integers on a 64 bit system, I don't know). Edit: Bah, silly me and my ignorance of JSON... This solution is a bit more reasonable... If you can find some way of creating the JSON with the number as a string {"next":"1313527373619043141"} It should come through json_decode as a string. Unfortunately you won't be able to use most mathematical operations on it without using the much slower BC Math functions.
  18. http://www.phpfreaks.com/forums/index.php/topic,95426.0.html If you "just can't get it right," show us that you've at least attempted to use the information available to you.
  19. Touche. In the future I will defer to your superior grasp of people's problems and your probable solutions.
  20. Why would you ever disable such a cool feature?
  21. It's the exact same meaning as if it used braces, some people just like to use it because they think it looks prettier in their web page templates, and can make things easier to read For example take these two (functionally) identical pages and consider which is easier to read <?php if ($something == true) { ?> Text text textText text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text text Text text textText text textText text textText text textText text text Text text text <?php while(false) { ?> Text text text Text text Text text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text texttext Text text text Text text text Text text text Text text text <?php } ?> Text text text Text textText text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text text <?php } ?> versus <?php if ($something == true) : ?> Text text textText text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text text Text text textText text textText text textText text textText text text Text text text <?php while(false) : ?> Text text text Text text Text text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text texttext Text text text Text text text Text text text Text text text <?php endwhile; ?> Text text text Text textText text text Text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text text text Text text text Text text text Text text text Text text textText text text Text text text Text text text Text text text Text text text Text text text <?php endif; ?> The second syntax is a bit easier to read, which is why people use them sometimes for templates where php and HTML are freely mixed. They are EXACTLY the same functionally. More reading: http://us2.php.net/manual/en/control-structures.alternative-syntax.php
  22. In that case, it's not the ternary operator. In fact, those if while statements you showed aren't even specific to wordpress, you can use them any where as alternative syntax. For example a php page consisting of only: <?php $pie = true; if ($pie) : while ($pie) : echo 'Pie\'s true!'; $pie = false; endwhile; endif; ?> is perfectly valid syntax even without wordpress anywhere in site (sorry, terrible pun). It's a good observation that they both use a colon, but they have completely different meanings and are treated completely differently as far as php is concerned.
  23. It's called the ternary operator. (as opposed to binary operators like =, +, ==, etc). It's shorthand for <?php if ($age < 16) { $agestr = 'child'; } else { $agestr = 'child'; } ?> Think of ? as "then" and : as "else". $someVariable = (BooleanCondition) ? 'ValueIfBooleanConditionIsTrue' : 'ValueIfBooleanConditionIsFalse'; could be read as $someVariable = if SomethingIsTrue then "Set someVariable to this value" else "Set someVariable to this value" Do note this can be used for any datatypes, including strings, as we did in the above examples. It has nothing to do with the alternate if, while, for, etc syntax that are often used in templates for readability like wordpress.
  24. Yes, using unix time functions such as date(), strtotime(), etc are limited to those date ranges in my post.
  25. I updated my post with the solution, sorry I was ambiguous in my original post
×
×
  • 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.