Results 1 to 16 of 16

Thread: php noob

  1. #1
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    749
    Thanked
    253 times in 190 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband

    php noob

    Hi i am trying to create a basic php page that uses the method GET to retreive some values and return something using echo

    my php code is:

    PHP Code:
    <?php
    $screen_x 
    $_GET["sx"];
    $screen_y $_GET["sy"];

    $version $_GET["cur_version"];

    $new_version "1.2"

    if (screen_x == "176" && screen_y == "220")
    {
    // check the version of the game
        
    if (version new_version)
        {
            echo = 
    "OK"." />";
            echo = 
    "< "."http.www.google.com"." />";
            
        }

    }

    ?>
    and the link that i use is http://casino770.com/production_jon/...&cur_version=1

    the problem is that i get a 403 Forbidden page everytime i try the above url link. i have read, write and execute access to the file and the server yet its giving me a forbidden error in my web browser

    any suggestions? im quit new to php

  2. #2
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Code:
    echo = "OK"." />";
    echo = "< "."http.www.google.com"." />";
    echo is a global function, not a variable. I've never seen assignment operations using echo like that. I could be totally wrong however.

  3. #3
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Indeed, echo is a pesudo-function, the dot performs concatination, so it wouldn't make much sense to break it up unless you're introducing variables into the string in the echo lines.

    Also, make sure the page is readable by the user/group of the webserver process, otherwise you'll still get a 403 assuming the webserver is apache with the SAPI module, if it's any other webserver with the cgi php module you'll need read and execute, for safe permissions use `chmod 755 page.php'.
    Last edited by aidanjt; 22-05-2007 at 10:18 AM. Reason: typo
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  4. #4
    NOT Banned
    Join Date
    Jan 2007
    Posts
    5,905
    Thanks
    410
    Thanked
    276 times in 252 posts
    Quote Originally Posted by j.o.s.h.1408 View Post
    the problem is that i get a 403 Forbidden page everytime i try the above url link. i have read, write and execute access to the file and the server yet its giving me a forbidden error in my web browser

    any suggestions? im quit new to php
    seems that the script doesnt exist. maybe thats why your getting that error. or your just simply not allowed to run it.

  5. #5
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Quote Originally Posted by moogle View Post
    seems that the script doesnt exist. maybe thats why your getting that error. or your just simply not allowed to run it.
    error 404 means file isn't found. 403 is a permission error.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  6. #6
    NOT Banned
    Join Date
    Jan 2007
    Posts
    5,905
    Thanks
    410
    Thanked
    276 times in 252 posts
    Quote Originally Posted by aidanjt View Post
    error 404 means file isn't found. 403 is a permission error.
    my mistake, i tried with the php extension only.

  7. #7
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    749
    Thanked
    253 times in 190 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    thanks guys i got it to work by putting a .php3 at the end of the file and instead of doing echo = blah blah i simply did

    echo blah;

    i have another problem:

    I've tried to use this code to return either true or false. but it keeps ending up has false even though the value i entered matches the condition.

    PHP Code:
    $screen_x=$_GET["sx"];
    $screen_y=$_GET["sy"];
    $version=$_GET["cur_version"];
    $phone=$_GET["phone"];
    $new_version="1.2";
    $ok="OK";
    $url="http.google.com";
    if (
    strpos($phone"Nokia") === true)
        {
            
    // check the version of the game
            
    if ($version $new_version)
            {
                echo 
    $ok " /> " "\n";
                echo 
    $url " />";
            }
        }
        
        else if (
    strpos($phone"Samsung") === true)
        {
            
    // check the version of the game
            
    if ($version $new_version)
            {
                echo 
    $ok " /> " "\n";
                echo 
    $url " />";
            }
        }
    else
     {
      echo 
    "Error" "\n" ;
     } 

    here is the link to the php file:

    http://casino770.com/production_jon/...=1&phone=Nokia

  8. #8
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    If you're going to use strpos, drop the "=== true", you don't really need it, any non-zero value is considered true by the 'if' statement, you could also simply do $phone === "Nokia", which would equally surffice.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  9. #9
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    749
    Thanked
    253 times in 190 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    i could do $phone === "Nokia" but the problem is that the $phone will have a value of "Nokia/6680 s60 blah blah" and i want to search this string to see if it has the word nokia

  10. #10
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Ok, well the problem with your code is that you're using the === operater instead of ==, the former makes a comparison of value and type, in the case of the string containing Nokia strpos will return the position of the string as a numerical value, which could be a 1 or a 2, or anything. operator == on the other hand would only look at the value and ignore the type, so === true would be considered false by if, and == true would be considered true, if strpos didn't find the substring then it would return boolean false instead of a non-zero numeric.

    If that makes any sense.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  11. #11
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Quote Originally Posted by j.o.s.h.1408 View Post
    PHP Code:
    echo $ok " /> " "\n"
    Why not do...

    PHP Code:
    echo $ok " />\n"
    ?

    You seem to concatenate things a lot.

  12. #12
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Indeed, concatenations do have a slight bit of overhead involved.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  13. #13
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    749
    Thanked
    253 times in 190 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    i think i know why it dont work, im using php 3 and the strpos was introduced in php 5?

  14. #14
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    According to the PHP manual strpos is present in PHP4 and PHP5:
    http://www.php.net/manual/en/function.strpos.php

    It would have given a runtime error if the requested function was missing, though it would be worth it to rename the file to .php instead of .php3 anyway.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  15. #15
    Chillie in here j.o.s.h.1408's Avatar
    Join Date
    Dec 2005
    Location
    a place called home
    Posts
    8,545
    Thanks
    749
    Thanked
    253 times in 190 posts
    • j.o.s.h.1408's system
      • Motherboard:
      • ASUS P6T Delux
      • CPU:
      • Intel core i7 920 @ 3ghz
      • Memory:
      • 3GB DDR RAM
      • Storage:
      • 1TB Samsung F1, 500GB Seagate baracuda + 320gb Seagate PATA +150GB WD PATA
      • Graphics card(s):
      • EVGA 480GTX SC edition
      • PSU:
      • Seasonic M12 600W Module PSU FTW
      • Case:
      • Lian Li PC-A7010B (the rolls royce of pc cases)
      • Operating System:
      • vista ultimate edition and windows xp
      • Monitor(s):
      • 22inch 2005FPW dell monitor
      • Internet:
      • 24mb BE There Broadband
    i managed to get it to work by seeing if the value is != null. it worked so i assumed that php4 is installed on the server but not php5 which has the === ?

  16. #16
    NOT Banned
    Join Date
    Jan 2007
    Posts
    5,905
    Thanks
    410
    Thanked
    276 times in 252 posts
    Quote Originally Posted by j.o.s.h.1408 View Post
    i managed to get it to work by seeing if the value is != null. it worked so i assumed that php4 is installed on the server but not php5 which has the === ?
    no need to assume

    PHP Code:
    <?php
    phpinfo
    ();
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP and file uploads timing out too soon
    By McClane in forum Software
    Replies: 12
    Last Post: 02-12-2006, 05:57 PM
  2. Replies: 13
    Last Post: 30-07-2005, 06:15 PM
  3. Using PHP to replace the <title> tag.
    By XA04 in forum Software
    Replies: 8
    Last Post: 15-05-2005, 10:34 PM
  4. PHP book
    By Lujan in forum Software
    Replies: 6
    Last Post: 01-08-2003, 03:25 PM

Posting Permissions

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