Jump to content

The Bat

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

About The Bat

  • Birthday 08/25/1988

Profile Information

  • Gender
    Male

The Bat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help everyone, I'll go with Crayon's solution.
  2. Hi everyone, my PHP skills are a bit rusty, so... I'm using basename($_SERVER['PHP_SELF']) to get (for example) blahblah_blah_stuff.php. What would be the best way to extract just the word "stuff" (the word right before ".php" and right after the last underscore) from it?
  3. Hello, I find myself using quite a bit of (example): function say_greeting($greeting = null) { $greeting = ($greeting) ? $greeting : 'Hello!' echo $greeting; } in my code (return $greeting if set, otherwise return 'Hello!'), and it's certainly not very DRY. In Ruby, a simple: def say_greeting(greeting = nil) print greeting || 'Hello!' end does the trick. I'm wondering if I can do something similar in PHP instead of what I am doing? Thanks!
  4. If I understand what you're talking about (fetching records from a table), then I think this is what you want... $query = mysql_query("SELECT * FROM stuff ORDER BY 'id'"); while ($row = mysql_fetch_array($query)) { echo $row['column_name']; echo $row['different_column_name']; # etc... } Much easier
  5. Hello, Is it possible to check if a function was called within a certain page? If so, how? Thanks.
  6. I have an .htaccess file which contains RewriteRule and RewriteCond statements. Here is the code (snippets are examples): RewriteCond %{REQUEST_URI} /cat [OR] RewriteRule ^([^/\.]*)/?$ cat.php?kitty=$1 [L] That way when the URL is mysite.com/cat/foo, foo is kitty. The problem is that "kitty" is applied to all pages. I tried adding RewriteCond %{REQUEST_URI} !(/cat) [OR] RewriteRule ^([^/\.]*)/?$ index.php?something=$1 [L] So that if the URL does not end with /cat, "kitty" will be "something". But this does not work. How can I fix this? Thank you!
  7. Of course you could also use getimagesize() in an if statement, and not have the upload continue if the size is not within your desired range.
  8. Thanks for the help! btherl, your method works great but I have one question: what exactly are the ampersands do?
  9. Hello, Is it at all possible in PHP to have "flexible" functions? For example, there's a function which has 3 parameters, and I only want to utilize 2 - the first one and last one. Instead of typing myFunc('first', false, 'third'); Could I/how would I do this? myFunc('first', $thirdparam = 'third'); (Assuming $thirdparam is the same variable used to declare the third parameter when creating the function.) Using Rails has had me wanting this functionality in PHP Thanks for the help!
  10. Not necessarily. If you use a RDMS, and you only need to call rows with a certain condition (like this) mysql_query("SELECT * FROM mytable WHERE myfield = 'something'"); and if it returns, say, 3 rows - that will take no time at all. However, when using a flat file, you'd need to load the whole file first before calling whatever information. Plus, it is extremely easy to work with MySQL in PHP.
  11. You should change the ereg function to eregi, otherwise someone can enter in an email address such as "JoeSmith@blah.com" and have it be invalid.
  12. On every page you want to restrict, you can put <?php if (!isset($_SESSION['sessionname']) { header('location: index.php'); } ?> at the very top of the page. If there is no session, it redirects to index.php (you can also change index.php to whatever you want, like a page saying they were trying to access a restricted section of the site).
  13. The one that you use (in my opinion) is the best way, however the last .""; is not needed (of course keep the semicolon).
  14. Thank you, however it still does not work. But if I replace it with the following (for testing purposes): function buttonDown(obj) { obj.style.visibility = 'hidden'; } It works fine. Why is this?
  15. Hello, I'm not that good in JavaScript, so bare with me. In an external JS file, I have the following function: function buttonDown(obj) { obj.style.backgroundImage = 'url(\'images/button-down.png\')'; } And then I have an onClick attribute applied to a div: <a onclick="buttonDown(this)"><div id="button"></a> This isn't working for some reason... but when I put the function code into the onClick attribute itself, it does work. Thank you for your help!
×
×
  • 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.