Jump to content

JasonLewis

Members
  • Posts

    3,347
  • Joined

  • Last visited

Posts posted by JasonLewis

  1. On a linux box (not that I'm a pro or anything) you don't need to specify a location to run a PHP script from the command line. All you need to write is:

     

    php -f [file]

     

    Or whatever the command is. As for Windows, perhaps provide a prompt for the user to input the location of their php.exe?

  2. There there is something wrong with your posts.php file. You're probably doing this:

     

    if(!isset($_GET['id'])){
       $id = 2;
    }else{
       $id = $_GET['id'];
    }

     

    You'd want to be doing this now, because you're not declaring a $_GET superglobal, your declaring a standard variable.

     

    if(!isset($id)){
       $id = 2;
    }

     

    You won't need to set it to itself again because it'll already be set.

  3. Or you could just go:

     

    if($userdata['user_level'] == 2){
       die('Wrong user level.');
    }

    Or if you end up with a few levels that are restricted.

    $restricted = array(2, 4, 5, 7); // levels 2, 4, 5 and 7 can't access the page
    if(in_array($userdata['user_level'], $restricted)){
       die('Wrong user level.');
    }

  4. You need to create a RegExp object out of your location, and use the i modifier on it. I took what you gave me and created an example, hopefully this is what you're after.

     

    <script type="text/javascript">
    // Create an example user inputted string.
    var loc = 'Rose';
    
    // Taken from your example.
    var rloc = [];
    rloc[55068] = 'Rosemount, MN';
    rloc[55124] = 'Apple Valley, MN';
    rloc[55401] = 'Minneapolis, MN';
    
    // Convert the location to a string.
    loc = loc.toString();
    
    // Create our regexp.
    regex = new RegExp(loc, 'i');
    
    // Now run the for loop.
    for(var l in rloc){
    	// Now we can test them.
    	if(
    		rloc[l].match(regex) !== null ||
    		l.match(regex) !== null
    	){
    		// Write out the matches.
    		document.write(rloc[l] + '<br />');
    	}
    }
    </script>

     

    Try copy and pasting that into a blank page and running it, change the loc to something else and test it out. I tried it and it seemed to be working. What I've done is created a RegExp object from the loc, firstly converting it to a string. Then you use the rloc variables as the test subject.

     

    Good luck man.

  5. You should be get errors when you run this script. The errors will tell you where the problem is. Look at this line:

    echo ", <a href="modcp.php">Mod CP</a>";

    You are opening a string with quotes, then inside the string you are using the quotes again. This is a no-no, because PHP thinks you are ending the string, and so it throws an error. You need to either escape the quotes, or use single quotes on the inside or outside.

    echo ", <a href=\"modcp.php\">Mod CP</a>";

    or

    echo ", <a href='modcp.php'>Mod CP</a>";

    or

    echo ', <a href="modcp.php">Mod CP</a>';

    You do the same thing a few lines down. You really need to look at your errors and check the lines out, then do a quick search on Google for the error. Generally these syntax errors are very easy to fix.

  6. I personally find his reaction hilarious, and a great addition to some of the posts you get on the forums. These members come and go, and I'm surprised it wasn't thorpe (no disrespect to thorpe :)) who caused the drama this time. I think they feel insecure because the answer is general so clear, so they go way overboard and portray themselves as a bit of an idiot.

  7. When you create a floating element you take it out of the document flow and position it either to the far left or far right of its containing element.

     

    What you need to do is create another element beneath both of these content divs and clear the floats.

     

    Since they're both floated left, you can just use a line break and set an inline style on it.

     

    <br style="clear: left" />

  8. This is what I have, which I ended up with after following a tutorial.

     

    [www]
    comment = www directory
    path = /var/www
    public = yes
    writable = yes
    valid users = jason
    create mask = 0771
    directory mask = 0771
    force user = jason
    force group = www

     

    So create mask should be 022?

     

    I change create mask = 0771 to 022 and now when I create files I get the following permissions:

     

    -----w--w- 1 jason www    0 2010-09-03 20:11 test.php

     

    NetBeans also says this: Cannot lock read-only file \\jcl-webserver\www\sites\home\htdocs\test.php

     

    Edit:

     

    I changed the create mask to 644 and now the permissions are set to the same as when created through SSH.

    I take it this is the right way?

  9. Okay, I set up samba so that it shares my /var/www directory so that I can gain access from my Windows box. The reason I did this was so that I could run NetBeans from my Windows box and edit files inside my /var/www directory.

     

    I've set up multiple sites so they are all stored in /var/www/sites/<sitename>/htdocs

    The problem is when I create a file from NetBeans it gives it incorrect permissions. Running ls -l from inside htdocs outputs this:

     

    -rw-r--r-- 1 jason www   19 2010-09-03 18:42 index.php
    drwxrws--x 3 jason www 4096 2010-09-03 18:34 nbproject
    -rwxrw---- 1 jason www  511 2010-09-03 18:43 netbeans_file.php
    

     

    index.php was created from SSH, and my linux isn't great but from looking at it index.php has read permissions for every group, and the owner can write too it (does it need execute?). However the netbeans_file.php (which was created from inside NetBeans), doesn't have any permissions for other.

     

    I'm kind of lost here, I can manually assign permissions to the file from SSH (chmod 644), however I'd prefer if files gained permissions when created.

     

    I'm not even sure where to start...

  10. And are they expressions, consider the following example:

    var patterns = [/^New York$/i, /^12345$/];
    var test_one = 'new york';
    var test_two = 'new york city';
    
    document.write(test_one.toString().match(patterns[0])); // will write new york
    document.write(test_two.toString().match(patterns[0])); // will write null

  11. You'll need a user authentication system, or members script, there are plenty of tutorials out there for that. Just Google "PHP MySQL Member System Tutorial". Then you just need to make a dynamic page which selects user information from the database depending on the member that logged in.

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