Jump to content

oni-kun

Members
  • Posts

    1,984
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by oni-kun

  1. This will become (after trimming): $msg[0] = 'MSG ABC' $msg[1] = 'Hi how are you' Essentially in those arrays with that code. (it's 2 not one on parameter.)
  2. Beat you to it, Gizmola
  3. Does anyone read the manual anymore? explode remember parameters. //Here's the voodoo $msg = explode(',', $input, 2); $user = trim($msg[0]); $text = trim($msg[1]); EDIT: OP, It will allow anything before or after the first comma. trim will remove the space in case they write 'ABC, message after spaces'.
  4. function cleanFormData($text) { $data = trim($text); $data = strtolower($text); $data = strip_tags($text); $data = htmlentities($text); if(get_magic_quotes_gpc()) { return stripslashes($data); } else { return $data; } } The function should still work, if it's not assigned use that code.
  5. Why not run: cd /usr/local MySQL status And find out yourself if it's there or not. I'm sure the basedir is the basedir as mentioned by The Little Guy.
  6. var_dump($eprice,$sprice); What does this return? Put it in place of your '$bamm = ...'
  7. Yes indeed. You filter out everything but the most important thing: Slashes. Use this to sanitize the input: function cleanFormData($text) { $data = trim($text); $data = strtolower($text); $data = strip_tags($text); $data = htmlentities($text); $data = mysql_real_escape_string($text); return $data; } EDIT: And why do you have htmlentities before strip_tags? striptags will do nothing as they're already nullified.
  8. Mhmm yes! I was confusing myself over the modulus, I used it right in the while loop but it shouldn't have in the code: $exp = 200; $gaintolvlup = 60 $level = 1; while ($exp > ($exp % $gaintolvlup)) { $exp = $exp - 60; $level++; } echo "Exp: " . $exp . "<br/>\n"; //Exp: 20 (from remainder/60) echo "Level: " . $level; //Level: 4 That works fine, and will only 'level up' if it's /60. Thanks!
  9. I was just thinking (that if they got 100/100 exp) that it should be >= 100. I try this code: $exp = 9900; $level = 1; while ($exp > $exp % 60) { $exp = $exp % 60; $level++; } echo $level; It outputs '2' No matter what value I use. Is there a simple error in my math/logic preventing it from keep going up?
  10. Yeah, Just a shame that when people go through all the trouble to help you (for free) they would just flip them off. Knowledge is more powerful than content, anyone will know that when it comes to ...Life. EDIT: This is ironic, as I bet he'd be checking back and be disappointed no one needed to.
  11. Once a friend who was making a game came up with a little trouble calculating exp/level, He figured out a method but I've wanted for experience to learn how to do this exactly. I've come up with my own method: $exp % 60 for example, so it displays the remainder after it meeting the 'requirement'. $exp = 100; $level = 1; while ($exp >= $exp % 60) { $exp = $exp % 60; $level++; } echo $level; I thought that'd work, but when I put it in a while loop to iterate through itself, it just freezes, what is the problem with that loop?
  12. What is the point of aliasing commands? If you've long queries that would be helpful for you to split into functions that'd be fine, but if you're just going to use a simple query per each one it'd be as pointless in the first place as writing 'db*' down. And to your question, Core functions are many times as fast than calling an object.
  13. Nope, because the result query will be: category.php?selecting=Video Games&?page=1 Notice the extra '?' The top code will be correct to add the extra argument.
  14. You must use: <a href="$targetpage" . "page=$counter"
  15. Yes, if the pagination script adds to the end of the url, that should work fine. But you have to remove the spaces around the ands. $targetpage = 'category.php?selecting=' . $_GET["selecting"] . '&';
  16. $targetpage = "category.php"; $page = htmlspecialchars($_GET['page']); <a href="$targetpage?selecting=".$_GET['selecting']."&page=$page"> Do you mean that? It'll retain the 'selecting' variable and ADD the page variable at the end, as the pagination script asks..
  17. If you're wanting to get 'Video Games', than use this: $page = htmlspecialchars($_GET['selecting']); Note escaping data does not sanitize it, only for SQL queries. HTMLspecialchars prevents any input that is not wanted (XSS forgery etc.). Remember, $_GET['whatever'] is url.php?whatever=foobar. If it doesn't exist, the GET statement will throw that error.
  18. I'm not 100% sure what you're meaning to do, are you wishing to use the pagination script with category.php? Then yes, you will need to change 'mypage.php' to 'category.php'
  19. $output = null; exec('whereis mysql', $output); echo "<pre>" . var_export($output, TRUE) . "</pre>\\n"; How does this work out, does it still return 1? Also, if safemode is enabled on your PHP installation, you cannot use this function.
  20. You can of course assign one: //index.php?arg=test $_GET['arg'] = "Foobar"; $arg = $_GET['arg']; // Will echo"FooBar" GET arguments are useful when the user needs to return to a specific setting on a page, such as ID number.
  21. Of course, Take into account you enter this url: www.example.com/index.php?page=1&style=blue In PHP, you can find them using: if (isset($_GET['page'])) { echo 'Page ID is set!, ID = ' . $_GET['page']; } else { echo 'Please enter an ID'; } if ($_GET['style'] == 'blue) { echo '<div style="background-color:blue;"> A div! </div>'; }' It's recommended to use isset() to find out if they're entered or not, or else it may return an error if you ask for it and it's not there. http://www.php.net/manual/en/reserved.variables.get.php Also, make sure you sanitize anything being outputted via GET variables.
  22. Benchmarking 10000 iterations returns that _assoc() is on average 35% faster when pulling out 100 rows. Atleast on WAMP.
  23. Yes, the nature of the function is to return output into a variable if specified. All $var = shell_exec... will do is return true or false if it returned data or came up with an error. Thanks for the quick reply, but that outputs "1" Find the output status to find error? $command = 'which mysql'; $shellOutput = shell_exec($command.' > /dev/null; echo $?'); echo trim($shellOutput); Also I'd recommend using a PATH to the exeutable file (/usr/sbin/...) instead of just naming it.
  24. mysql_fetch_array() returns essentially two arrays, one with a numeric index and one with an associative based key index. Thus using mysql_fetch_array() without specifying which method you want (either MYSQL_NUM or MYSQL_ASSOC) always returns a double array, which is considerably more inefficient as compared to mysql_fetch_row or mysql_fetch_assoc. I normally use mysql_fetch_assoc() myself.
  25. Is your site submitted to google? Check your server logs on how often Googlebot crawls your pages and what it accesses. There's nothing else you can do, provided you have the proper alt tags and title for it. Just have to wait.
×
×
  • 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.