Jump to content

Dorky

Members
  • Posts

    287
  • Joined

  • Last visited

    Never

Posts posted by Dorky

  1. are you on a host or your own server?

    My error:

    Warning: fopen(NameFile_dogs.txt) [function.fopen]: failed to open stream: Permission denied in /Users../Sites/nametest/index.php on line 43
    can't open file
    

     

    Here is the relevant code:

    <?php
    //...
    $DirectionsFile = "NameFile_".$species.".txt";
    $fh = fopen($DirectionsFile, 'w') or die("can't open file");  // THIS IS LINE 43
    //...
    fwrite($fh, "Scrubs\n");
    fwrite($fh, "Snoopy\n");
    //...
    if(isset($fh)){
    fclose($fh);
    }
    ?>
    

     

    Anyone know how to fix this? I have no clue how to set/vary php/other permissions for my files. Also it is the first time i tried this code, so i know the filename does not exist yet.

     

    Other than that, i'm lost! Any1 have a clue??

  2. ereg_replace("[^A-Za-z0-9]", " ", $whatever);

     

    this just cuts it all out. maybe overkill. you can also use a combo of

     

    strpos(

     

    that will return the position of a defined char then

     

    substr(

     

    to pull what part of the string in ref to the defined char forward or backward in the string

     

    im sure i could help more if i understood your source of data and desired output but im sure these three things will bring you closer.

  3. lets say you are using post.

     

    if (isset($_POST['whatever']))

    {

    //do whatever

    }

     

    this can be put anywhere. i put all of my application scripts  before <html> then work in any dynamic portions in the html by using

     

    echo "<html>

     

    and using single quotes so i dont have to escape all of the double quotes. this also allows the information that was just uploaded to be viewed when the page refreshes without having to call it with jscript.

     

    if you dont have dynamic markup just put it above the html and disregard the html echo.

  4. that would explain why i cant find anything about it. i did find this http://www.herongyang.com/PHP/session_3.html very informative. well i supose some trickery to keep it safe using post could be performed but this project doesn't pay enough for all of that.  thx again guys. very helpful. i must say the custom captcha was easier then figuring out that when they say server side session its only half the truth.

    how does one keep the session completely server side.
    There is no such thing.

  5. yeah i turned off cookies and thats a fact. ive been looking to see how to direct it to the flatfile. i dont imagine it works just by writing to the file, still need to tell it not to send it to the browser somehow correct? ill keep looking and checking back here. thx guys.

     

    starting a session automatically tries to create a cookie to store the session id.  Failing that, the session ID can be passed via the url.  Or manually doing it by storing and retrieving a session id in a flatfile or db and manually setting the session id.

  6. that makes sense but i followed everything i saw in regards to using server sessions. ill turn off my cookies later and try. if what you are saying is the case how do insure to use only server sessions. i gave no instruction to create a cookie but that doesnt mean it aint so.

     

    Ummm. By default, the session id is passed between pages using a cookie, which is why when you were changing between www. and no-www. that sessions weren't working. The hostname/subdomain where the sesison id cookie was created did not match the hostname/subdomain you switched to. By setting the session.cookie_domain so that it matches all hostnames/subdomains of your domain, the session id cookie will be sent by the browser with the requests matching your domain, regardless of any hostname/subdomain in the URL.

  7. as far as i can tell im using server side sessions. i try to stear clear of anything requiring more then html and css on the client side. thats pretty much the direction the web is taking, thus moving animations to css3. also you may find this helpful when designing your own sites, not that your a noob at all. just the direction of things as i interpret them.

     

    Use a text browser such as Lynx to examine your site, because most search engine spiders see your site much as Lynx would. If fancy features such as JavaScript, cookies, session IDs, frames, DHTML, or Flash keep you from seeing all of your site in a text browser, then search engine spiders may have trouble crawling your site.

    http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=35769#1

     

    OR you could always set the session.cookie_domain so that it matches your domain no matter what hostname/subdomain is being used -

     

    http://www.php.net/manual/en/function.session-set-cookie-params.php

    http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-domain

  8. that was incorrect. it will not always return that. thx crayon. sorry.

     

    http_host will always return with a www. so it is not an accurate method of discovery and recontrutin the url wont do any good because i would be telling my script what it wants to hear not actually checking the header url.

     

     

    You mean something like this?

    function getFullURL() {
        $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
        return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    }
    

  9. http_host will always return with a www. so it is not an accurate method of discovery and recontrutin the url wont do any good because i would be telling my script what it wants to hear not actually checking the header url.

     

     

    You mean something like this?

    function getFullURL() {
        $protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
        return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    }
    

  10. this is also problematic but closer. im have trouble finding the correct way to retrieve the url from the header. all i see so far are several commands that reconstruct what should be the url but it doesnt actually pull it from the current header.

    the goal would be something like

     

    if (however i can pull and check the actual url from header)
    {
    header ("Location: http://whateverurl.com");
    }

     

    dude you couldnt have been more right. i hope this is the real problem and solution. if not, please say so. my fix is as stated below.

    if (!$_SESSION['whateversession'])
    {
    header ("Location: http://whateverurl.com");
    }

     

    from the second submit and on it works fine
    Sounds like you are switching the URL for a page from one that has a www. to one that does not or visa-versa and your session cookie parameters are not setup to match URL's both with and without a www. on them.

  11. dude you couldnt have been more right. i hope this is the real problem and solution. if not, please say so. my fix is as stated below.

    if (!$_SESSION['whateversession'])
    {
    header ("Location: http://whateverurl.com");
    }

     

    from the second submit and on it works fine
    Sounds like you are switching the URL for a page from one that has a www. to one that does not or visa-versa and your session cookie parameters are not setup to match URL's both with and without a www. on them.

  12. that sounds like that may be it. considering visitors will encounter the same issue depending on how they get to the page how would i solve that.

     

    from the second submit and on it works fine
    Sounds like you are switching the URL for a page from one that has a www. to one that does not or visa-versa and your session cookie parameters are not setup to match URL's both with and without a www. on them.

  13. MY ISSUE IS YOU INSINUATED I AM RUDE WHEN IT WAS ANOTHER USER THAT USED THAT WORD TO BEGIN WITH NOT ME. AS WELL AS SAYING I EXPECTED ANYTHING OF YOU OR ANYONE. ITS VVVVVVVOOOOOOOOLLLLLUUUUUUNNNNNNTTTTTAAAAARRRRRYYYYY DU!

     

    lol, wow, REALLY. i dont expect anyone to do anything for me, read the original post "if anyone is interested" makes it more then clear (as if it wasnt already) this is voluntary to begin with. i dont recall anyone being required to respond to my post. you voluntarily decided to show you #$$ is the truth of the matter. go argue with you girlfriend or grandmother. im not interested.

     

    if you are not interested in responding to this thread other then to complain that i posted

     

    I agree. I hate when people reply to a question with "go look it up in google" or "go read a manual". It's pretty rude.

    It's not rude. I think it's pretty rude that some expect people to write them a book specifically for them when there are already thousands of other tutorials and examples out there. (Not specifically talking about this case, at least not totally.).

     

    I'm not exactly sure what your issue is. I simply pointed you to a source that if read would likely get you the understanding your seeking. Its up to you to read it or not.

  14. LOOK. I POSTED THIS TO FIND SOMEONE INTERESTED IN HELPING ME UNDERSTAND SOMETHING A CLEARLY STATED DID NOT MAKE SENSE TO ME IN THE TUTORIALS I HAVE READ. WHY ARE ALL OF YOU SO PREDISPOSED TO NEGATIVITY. IF IT DOESNT INTEREST YOU THEN LEAVE IT ALONE. FIND ANOTHER THREAD TO HELP WITH. BUT FOR GOD SAKE GET OFF MY CASE. IF YOU CANT SAY ANYTHING NICE-DONT SAY ANYTHING AT ALL

  15. lol, wow, REALLY. i dont expect anyone to do anything for me, read the original post "if anyone is interested" makes it more then clear (as if it wasnt already) this is voluntary to begin with. i dont recall anyone being required to respond to my post. you voluntarily decided to show you #$$ is the truth of the matter. go argue with you girlfriend or grandmother. im not interested.

     

    if you are not interested in responding to this thread other then to complain that i posted

     

    I agree. I hate when people reply to a question with "go look it up in google" or "go read a manual". It's pretty rude.

    It's not rude. I think it's pretty rude that some expect people to write them a book specifically for them when there are already thousands of other tutorials and examples out there. (Not specifically talking about this case, at least not totally.).

  16. and while this is one use of classes im sure this is not the limits of classes and it isnt really a step by step breakdown of code, being of practical exp this should be easy for you. im sorry if my questions make you uncomfortable but it is and was your choice to reply to this thread. and its really just for as i said "the sake of having a clue" that im interested in them. my target and existing clients do not require anything i would need this for.

     

    corbin is right, you should definitely look into some tutorials, but about the code

     

    class myClass {
    private $var1, $var2, $var3;
    
    public function display(){
    echo $this->var1, $this->var2, $this->var3;
    }
    }//end class
    

     

    this defines a class. you can define variables within the class, and set hem as private, public, or protected. private means that only the class can access them, and public means that anyone can access them. Ill explain this further with the next code snippet

     

    the function display is called a method, because its a function within the class. there are a couple of things to notice. for a class to access its member variables, we use the $this keyword, with the array (->) character. if you are familiar with C++, java, etc. it is similar to the '.' operator. calling a method is similar. we use the same $this-> syntax, but with the method name. IE $this->display()

     

    now the second snippet

     

    $object = new myClass;
    echo $object->var1;
    

    the first line does what is called instantiating the class. Basically it means to create an "object" of the class. That object is now a container in your code with the classes data members and methods. Look at the second line. notice two things. WHen we access PUBLIC data members and methods, instead of the $this keyword (which is only usable inside classes) we use the variable name, which is now basically a reference to the object of class myClass.

     

    The second thing to notice is that the second line won't work because the data member var1 in the class myCLass is defined as private, so only the class can use it. If we were to change the keyword private to public, than it would work in that case.

     

    but honestly, as corbin said, the subject of OOP is far too huge to cover in one simple post. I didn't even go over constructors, protected, inheritance or anything like that. I really think you should read up on some tutorials and try it yourself.

  17. well if i was interested in whatever PVP is then i would consider wasting my time listening to you.

     

    if you can't understand tutorials on functions or classes, perhaps you should read tutorials on more basic aspects of PVP. classes can be somewhat hard to understand, but functions are just a couple of lines of code that you can basically run with certain information and have it spit out more information. classes are like containers that have a certain set of data, with a certain set of functions that can alter that data.

     

    what kind of breakdown do you seek. it doesn't take much real world experience to see how classes work. are you looking to be convinced that you should use classes? do you want a sample function with an explanation of every line? Also, what about the tutorials do you not understand. I have read the w3schools tutorials, as well as the manual, and it seems very clear to me.

  18. i have. they dont make sense. im sure a small script of each with a breakdown of what is happening in them step by step(one example each) would suffice. but so far what i see are folks using them to bypass other parts of php they dont understand. thats why in the manual section(as noted i have already tried) is full of post correcting post after post correcting post. im sure someone with real world exp with them and the understanding of the "why" not just remembering, could give the breakdown i seek. if you are not interested in responding to this thread other then to complain that i posted it or anything other then the advice i am seeking, dont waste my time to check your post or your time to write a reply. its simply counterproductive.

     

     

    Functions and classes are not something that can be properly and fully explained in a brief forum post.  (Definitely not classes.... maybe functions.)

     

     

    I suggest reading tutorials and articles about the two things.

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