Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13

Thread: php

  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php

    when i put this code in my computer:
    Code:
    <?php
    session_register("view1count");
    session_register("view2count");
    session_register("view3count");
    session_register("view4count");
    ?>
    <?php
    //page_count.php
    if (!$view1count) $view1count = 0;
    if (!$view2count) $view2count = 0;
    if (!$view3count) $view3count = 0;
    if (!$view4count) $view4count = 0;
    echo "<HTML><HEAD><TITLE>Web Page Hit Counter</TITLE></HEAD><BODY>";
    if ($whichpage) {
    echo "<B>You are currently on page $whichpage.</B><BR><BR>\n";
    $GLOBALS["view${whichpage}count"]++;
    }
    for ($i = 1; $i <= 4; $i++) {
    if ($whichpage == $i) {
    echo "<B><A HREF=\"$PHP_SELF?".SID."&whichpage=$i\">Page $i</A></B>";
    } else {
    echo "<A HREF=%22$PHP_SELF?&quot;.SID.&quot;&whichpage=$i/&quot;>Page $i</A>";
    }
    echo ", which you have chosen ".$GLOBALS["view${i}count"]." times.<BR>\n";
    }
    echo "\n\n<BR><BR>\n\n";
    echo "</BODY></HTML>";
    ?>
    warning message appeared to me, but when i uploaded it (http://members.lycos.co.uk/aymenplusplus/page_count.php) every think is ok but when i press the first link for example i don't know what happened... why?

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Firstly, I dont know if it matters, but put { and } in your if statements.

    Secondly, and I dont know If this is right, you should change

    ${i} to {$i} and similar instances.


    If this doesn't work, please post the error so that I know what is going wrong.

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    echo "<A HREF=%22$PHP_SELF?".SID."&whichpage=$i/">Page $i</A>
    should be

    PHP Code:
    echo "<A HREF=\"".$PHP_SELF."?".SID."&whichpage=".$i."\">Page ".$i."</A>"
    Also, don't forget the session_start();

    The code is kinda messy though

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but why my computer prints warning on the first page?

  • #5
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    What does the warning say?

  • #6
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that is whole the page that appeared to me:
    Warning: open(/tmp\sess_8f32df803149e82883472caec93a6900, O_RDWR) failed: m (2) in C:\apache\htdocs\test\page_count.php on line 2
    Page 1, which you have chosen 0 times.
    Page 2, which you have chosen 0 times.
    Page 3, which you have chosen 0 times.
    Page 4, which you have chosen 0 times.



    Warning: open(/tmp\sess_8f32df803149e82883472caec93a6900, O_RDWR) failed: m (2) in Unknown on line 0

    Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

  • #7
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Right, that means you have no /tmp folder to store your session data. I am having the same problem, but I am using phpdev.

  • #8
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just remembered, you can change the name of the dir in php.ini

  • #9
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how about session_start(); at the stop of the page?

  • #10
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, how can i solve it?

  • #11
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    by the way, what is meaning of "stateless", i searched it in the dictionary and i didn't find it?

  • #12
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    stateless and state normally refer to an object and its state...look it up in an OO based language, I can't think of a way to describe it.


    Jason

  • #13
    Regular Coder
    Join Date
    Nov 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i did it with phpdev but only the first warning appeared to me, why?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •