Jump to content

DarkWater

Members
  • Posts

    6,173
  • Joined

  • Last visited

    Never

Everything posted by DarkWater

  1. @jonsjava: That's going to probably be much slower than having PHP handle the interpolation. @Minase: Get over it and use double quotes or structure your code better (i.e: a templating system).
  2. Constants don't magically interpolate into strings. You'll either need to use a variable or concatenate. <?php $test = "a value ..."; $text = "Welcome to $test ,enjoy your stay"; //notice the DOUBLE QUOTES ?> <?php define("test", "a value ..."); $text = 'Welcome to ' . test . ' ,enjoy your stay.'; ?>
  3. My scan shows that he's got some sort of Linux running, so it should be fine.
  4. The unix uptime utility can give you the uptime, so then you can easily calculate the last reset. You can access that program in PHP using exec() (or another one in the exec() family), or backticks: <?php $uptime = `uptime`; ?>
  5. Are the servers on the same box? If so, just do exec('mv file1 file2'); or rename(). Otherwise, check out the FTP functions.
  6. The only reason I said it was because I wasn't sure if \w was treated as [a-zA-Z0-9_] or [a-zA-Z\d_]. \d allows some weirdo characters like exponents and stuff, and I personally don't know every one of the characters and if they're good or not. I did some checking and it seems as if \w uses the former, so MSRE is unnecessary.
  7. @npsari: He wants to mod_rewrite by username, not just make a folder with an index.php that handles requests. That's like, makeshift mod_rewriting. =P
  8. By the way, that won't work in all browsers or all servers. There is no browser/server-independent way of doing that.
  9. Just run a simple foreach loop on the array from fetcharray() then.
  10. There's a lot of stuff askew in that code... <form action=<?php echo $SERVER['PHP_SELV']?> if(preg_match("match("/pass/i",$field)) $type = "text"; else $type = "text"; eho " selceted"; @type = "text"; Is code this atrocious really in that book? Or are these just typos from retyping it by hand?
  11. You're only outputting one element of the array. Did you expect the one element to contain several columns worth of data...? Try running print_r() on the result row instead.
  12. Lol, I think you're absolutely right. I think the 'impart entertain' phrase gives it away.
  13. function FilterText($str, $advanced=false) { $str = preg_replace("~[^\w ]~","",$str); if($advanced == true){ return mysql_real_escape_string($str); } $str = mysql_real_escape_string(htmlspecialchars($str)); return $str; } That's what it should be. Think about the code that you put: function FilterText($str, $advanced=false) { $str = "Some characters: 8*\^%@#*t*e*s*t!"; $str = preg_replace("~[^\w ]~","",$string); echo $str; if($advanced == true){ return mysql_real_escape_string($str); } $str = mysql_real_escape_string(htmlspecialchars($str)); return $str;[/b] } Firstly, that 2nd line just overwrites whatever you're passing into it. Then, on the 3rd line, you're using $string instead of $str. And then, on the fourth, you're echoing it out. Often, when receiving forum help, you need to really pay attention to how you use the code. Many posts use the code in an example context with an example string, so you need to fix it up for it to work for you.
  14. Well, it's not too complicated actually. Let's say $bio is your bio: <?php if (strlen($bio) > 200) { $bio = substr($bio, 197) . '...'; }
  15. Wait. By "the 2nd url", did you mean http://www.yoursite.com/DarkWater? If so, then they can absolutely go directly do it. In fact, that's the whole point of mod_rewrite. I thought you meant the second URL of the rewriting example, which is http://www.yoursite.com/profile.php?name=DarkWater. You had me confused there for a second, lol.
  16. Yeah, unless you don't want them to. Does it matter?
  17. That's because you can't echo an array. Try print_r() to view an array.
  18. In your FilterText() function...? Preferably above your mysql_real_escape_string() call. I don't really think you'll need that MSRE call anymore, but you might as well keep it to be on the safe side. Oh, and obviously you'll need to change the variable names from our examples to fit your code. And the code that Crayon Violent posted allows numbers, letters, the underscore, and a space bar.
  19. Well, firstly, you need a PHP script to handle grabbing the info. If it was, for example, named profile.php, it could conventionally be accessed like so: http://www.yoursite.com/profile.php?name=DarkWater After you get that sorted, you can go a step further and use an Apache module named mod_rewrite. It basically allows you to rewrite requests. You can use it to make "pretty URLs". It would allow you to rewrite: http://www.yoursite.com/DarkWater To: http://www.yoursite.com/profile.php?name=DarkWater The user would enter the first URL into their browser, and the server would actually serve back the second URL without the user needing to do anything.
  20. Woops, didn't realize that's what he said. \w includes the _ too, but it shouldn't really be a problem in this case.
  21. You aren't doing anything with the data returned by fetcharray().
  22. You could do something like: <?php $string = "Some characters: 8*\^%@#*t*e*s*t!"; $string = preg_replace('/[^a-z ]/i', '', $string); echo $string; ?>
  23. SELECT * FROM log WHERE updated_user = 'user' AND date >= SUBDATE(NOW(), INTERVAL 90 DAY); Try something along those lines.
  24. Change your querying to: $query = "INSERT INTO raids (RaidNum, RaidDate, RaidLength) VALUES ('$newRaidNum', FROM_UNIXTIME('$varRaidDate'), '{$_POST["Length"]}')"; echo "Query: $query"; $result = mysql_query($query) or die(mysql_error());
×
×
  • 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.