Jump to content

Wolphie

Members
  • Posts

    682
  • Joined

  • Last visited

    Never

Posts posted by Wolphie

  1. Yeah a good point. When getting numbers in from user input I use the following:

     

    $id = number_format($_POST['id'], 0, "", "");

     

    This way, if anything other than a number is entered a 0 is returned.

     

    Erm, why not just use PHP's pre-built is_numeric() function?

  2. function href_d($string) {
      $string = preg_replace("#<a[?: href=('|\")((\w:/\.\?\#&=\-)*)\\2]?[\w\"'_\s]*>#iU","1 \\2", $string); 
      $string = htmlspecialchars($string);
      return $string;
    }
    

  3. Yes, ScotDiddle is right, you need curly braces for code blocks. If it's just a single line of code then you don't need the braces.

     

    e.g.

     

    $name = 'Wolphie';
    if($name == 'Wolphie')
      print 'My name is ' . $name;
    
    
    // For braces
    
    $name = 'Wolphie';
    $age = 19;
    if(($name == 'Wolphie') && ($age == 19)) {
      print 'My name is ' . $name;
      print '<br />';
      print 'My age is ' . $age;
    }
    else
      print 'Your name is not ' . $name;
    
    

  4. To be honest I've never looked into this in depth but I've always been curious. But I would recommend taking a look at sockets in PHP. Remember PHP isn't jut a web development language. It is an actual language.

  5. Xyn: If you've been reading, that is what we've been discussing.

     

    bluejay: I suppose it is, I guess in any languages people will have their own experiences, but Lodius2000 there's no reason why you shouldn't at least try nl2br(), it may or may not work and if it does it's just saved you a lot of time and effort.

  6. Please in future use the Code BB tags.

     

    If you want to move them to different directories based on their ID, either get the ID from a database and store it in a variable and use a switch statement, or if you already have the dynamic ID's use a witch statement still.

     

    switch($uid) {
      case 'G1061':
        $homeDir = 'client1';
        break;
      case 'G1059':
        $homeDir = 'client2';
        break;
      default:
        print 'Invalid user ID!';
        break;
    }
    

  7. I don't use facebook, but I assume you're referring to inline editing. For example, you click on an element i.e. a paragraph, and then a text area appears with the contents of the element inside allowing you to edit it and then update it. For this I would recommend using jQuery, there's a plug-in named jEditable which allows you to do this in conjunction with Ajax.

  8. Surely anyway wouldn't you need to call the body of the blog post, title of the blog post, etc..?

    If I was doing the same thing, I would also have an author field in the same table. In which case, it wouldn't be that difficult to add an extra line or so to get the author from the database.

     

    But ID's are the best way to retrieve hierarchical data, or any kind of data to be honest.

  9. Well, first of all you're calling the function before it's being defined and then exiting. Exiting stops everything beyond it from being parsed by the PHP engine.

     

    <?php
    session_start();
    function createimage() { ... }
    createimage();
    exit; // exit is a language construct, not a function. Parentheses aren't necessary.
    ?>
    

    <?php  session_start(); ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/EN/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    <br>Login Page :
    <form action="tologin.php" method="post" >
    username : <input type="text" name="username">
    password : <input type="password" name="password">
    securitycode : <img src="securitycode.php" width="100" height="25" alt="Security Code">
    Submit
    </form>
    </body>
    </html>
    

     

    You have a whitespace <?php  session_start(); ?>, use <?php session_start(); ?>

    The whitespace may not do any harm, but it's best practice to avoid them.

     

     

  10. Haha, thanks for the reply! Not what I initially expected but still an interesting one. I know a lot of things are just a theory, but it would be annoying if I were to point out that everything I was talking about is just a theory! :P

     

     

    Lol @ That picture!

  11. If that's the case, then you shouldn't use list().

    list() assumes a known amount of elements in an array. Using the example you provided, exploding it would only make the array have 3 elements, therefore if the array were to have 4 elements you wouldn't be able to use list() because the amount of elements wouldn't be definite. In which case, you should ditch list().

×
×
  • 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.