Results 1 to 25 of 25

Thread: hmm, AddPostVariable trouble, maby

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default hmm, AddPostVariable trouble, maby

    I'm trying to make a little database type thing with SCAR, simply by saving a string to a file using POST vars, and such.

    my problem is that when i run the script, it doesn't send the POST var to the PHP...

    SCAR Code:
    program New;

    const
      Val = 'ohai';
    var
      i : integer;
      s : string;
    begin
      I := InitializeHTTPClient(true, true);
      AddPostVariable(i, 's', Val);
      PostHTTPPageEx(i, 'http://akwardsaw.hostoi.com/Mess_Board.php');
      s := getpage('http://akwardsaw.hostoi.com/Mess_Board.php');
      writeln(s);
    end.

    Code:
    <?php
       error_reporting(E_ALL);
      if (isset($_POST['s'])) {
        $f = file_put_contents("./s.txt", $_POST['s']); 
      } else { echo "oops!"; }
        echo file_get_contents("./s.txt");
    ?>
    results when i run the SCAR script:

    Successfully compiled (52 ms)
    oops!Awkwardsaw: Test



    PS: i put the "Awkwardsaw: test" in the text file myself when i made it
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    are you sure s.txt is chmodded to 777?
    Ce ne sont que des gueux


  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    are you sure s.txt is chmodded to 777?
    it is with a different version, but SCAR hasnt sent the POST variable to the php, which is why it returns "oops!Akwardsaw: test" or w/e lol
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    are you sure s.txt is chmodded to 777?
    Wait, what. Why would you chmod it to 777? Do you want that everyone is able to read, write and execute it?



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  5. #5
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Change your PHP to:
    PHP Code:
    <?php
        
    if ($_POST)
        {
            
    $f file_put_contents("./s.txt"$_POST['s']);
            if(!
    $f)
            {
                echo 
    "oops!";
            }
          }
        echo 
    file_get_contents("./s.txt");
    ?>
    @Wizz:
    I know it's dangerous... But else you'll get permission errors if you want to write to the file.
    There are other ways to do it but the easiest is just to set it's permissions to 777.
    Ce ne sont que des gueux


  6. #6
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    i fixed the file to make it chmod 777, and added a little "password" type thing, which also works

    also, what is the php equivlent of chr(13) in SCAR? (where you can add the enter key to a variable string)
    Last edited by Awkwardsaw; 11-19-2009 at 01:20 AM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  7. #7
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    i fixed the file to make it chmod 777, and added a little "password" type thing, which also works

    also, what is the php equivlent of chr(13) in SCAR? (where you can add the enter key to a variable string)
    Try '\n'

    EDIT: #13 is '\r'. #10 is '\n'. #10 should generally do it. If it's a windows server, use #13#10.
    Last edited by Wizzup?; 11-19-2009 at 01:47 AM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Try '\n'

    EDIT: #13 is '\r'. #10 is '\n'. #10 should generally do it. If it's a windows server, use #13#10.
    so,

    $a = $_POST['a'] + #13#10;

    will return
    "content of a

    "
    ?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    $a = $_POST['a'] . "\n";
    lol

  10. #10
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    What 'bout <br />? assuming you want to output it using HTLM? Else \n.
    Ce ne sont que des gueux


  11. #11
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    What 'bout <br />? assuming you want to output it using HTLM? Else \n.
    i want to save to the file like

    "entry one
    entry twp
    entry three"

    instead of
    "entry one entry two entry three"
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  12. #12
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thats what <br> does... It makes a new line so "me<br>you<br>ahh" would return

    me
    You
    ahh

    in html...
    I do visit every 2-6 months

  13. #13
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by ZaSz View Post
    Thats what <br> does... It makes a new line so "me<br>you<br>ahh" would return

    me
    You
    ahh

    in html...
    Incorrect.
    It would return:
    Code:
    me
    you
    ahh
    Because you had "you" lowercased in your example, but it is uppercase in your output.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  14. #14
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Don't be such a nitpick Sex

    If you want it just to go in a .txt file, use echo "sentence, lol!\n";
    Ce ne sont que des gueux


  15. #15
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    Don't be such a nitpick Sex

    If you want it just to go in a .txt file, use echo "sentence, lol!\n";
    Code:
    <?php
        if ($_POST){
            $a = $_POST['a'] + "/n";
            $f = file_put_contents("./s.txt", $a);
            if(!$f)
              echo "oops!";
          }
        echo "[akw]". file_get_contents("./s.txt") ."[/akw]";
    ?>
    returns: [akw]0[/akw]

    no matter what i use as the POST
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  16. #16
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Come on fella's..

    PHP Code:
    <?php
        
    if ($_POST){
            
    $a $_POST['a'] . "<br>";
            
    $f file_put_contents("./s.txt"$a);
            if(!
    $f)
              echo 
    "oops!";
          }
        echo 
    "[akw]"file_get_contents("./s.txt") ."[/akw]";
    ?>
    We arnt adding up here. Use . instead

    PHP Code:
    $a "a" "<br>";
    echo 
    $a;
    echo 
    'b'
    Results in

    a
    b

    PHP Code:
    $a "a" "<br>";
    echo 
    $a;
    echo 
    'b'
    Results in

    0b

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  17. #17
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by rogeruk View Post
    Come on fella's..

    PHP Code:
    <?php
        
    if ($_POST){
            
    $a $_POST['a'] . "<br>";
            
    $f file_put_contents("./s.txt"$a);
            if(!
    $f)
              echo 
    "oops!";
          }
        echo 
    "[akw]"file_get_contents("./s.txt") ."[/akw]";
    ?>
    We arnt adding up here. Use . instead

    PHP Code:
    $a "a" "<br>";
    echo 
    $a;
    echo 
    'b'
    Results in

    a
    b

    PHP Code:
    $a "a" "<br>";
    echo 
    $a;
    echo 
    'b'
    Results in

    0b
    wewt, i got the enter part down, but it still doesnt return any thing :L

    Code:
    <?php
        if ($_POST){
            $a = $_POST['a'] . "<br>";
            $f = file_put_contents("./s.txt", $a);
            if(!$f)
              echo "oops!";
          }
        echo "[akw]" . file_get_contents("./s.txt") . "[/akw]";
    ?>
    returns
    [akw]
    [/akw]

    i feel like a nub
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  18. #18
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Is there a reason for s.txt to be in a directory up? Can't you just let it be file_get_contents("s.txt"); so the .txt is placed in the same folder as this PHP script?
    Ce ne sont que des gueux


  19. #19
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    Is there a reason for s.txt to be in a directory up? Can't you just let it be file_get_contents("s.txt"); so the .txt is placed in the same folder as this PHP script?
    it is in the same directory
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  20. #20
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Oh well then the PHP script is probably in the root ;P
    Ce ne sont que des gueux


  21. #21
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    Oh well then the PHP script is probably in the root ;P
    root/public_html to be exact
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  22. #22
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    yeah yeah
    Maybe you should put a wait inbetween the PostHTTPPageEx and the GetPage.
    Ce ne sont que des gueux


  23. #23
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    yeah yeah
    Maybe you should put a wait inbetween the PostHTTPPageEx and the GetPage.
    im testing this directly with an html form

    Code:
    <html>
    
    <form method="POST" action="http://akwardsaw.hostoi.com/Mess_Board.php">
        <input type="text" name="s" value="text"> 
        <input type="submit" value="Post"> 
    </form>
    </html>
    the scar returns the same result though
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  24. #24
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Erm... In your HTML the post value is name="s"
    In the PHP you ask; $_POST['a'];
    Ce ne sont que des gueux


  25. #25
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Floor66 View Post
    Erm... In your HTML the post value is name="s"
    In the PHP you ask; $_POST['a'];


    /facepalmx100

    i am and idiot.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

Thread Information

Users Browsing this Thread

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

Posting Permissions

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