-1

I'm following the tutorial here to create a login page using MySQL. The code seemed to be working flawlessly when I left my computer 2 days ago. Now I come back to work on it, haven't changed anything, and I'm greeted with this warning:

Warning: Use of undefined constant php - assumed 'php' (this will throw an Error in a future version of PHP) in /filelocation/login.php on line 1

Line 1 in login.php literally says only this:

<?php

It also seems like this warning is breaking the form. When I hit the "login" button, nothing happens besides being redirected right back to the login page to try again.

Why would this be happening?

edit* As requested here is the fist couple lines of my code. Simply copy-pasted:

<?php
// Initialize the session
session_start();

// Check if the user is already logged in, if yes then redirect him to welcome page
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
    header("location: welcome.php");
    exit;
}
Trevzilla
  • 29
  • 1
  • 2
  • 9
  • 3
    You sure there isn't a space, like ` php`? Post the first couple lines of that file. – Devon Bessemer Sep 04 '18 at 15:24
  • Edited original post with first couple lines of code. But yes double checked that there are no spaces. – Trevzilla Sep 04 '18 at 15:29
  • *"When I hit the "login" button"* - What button's that? – Funk Forty Niner Sep 04 '18 at 15:51
  • btw, you sure that `<` and/or the `?` is/are in fact coming from a standard keyboard and not as one from a unicode character? – Funk Forty Niner Sep 04 '18 at 15:52
  • The full code on my page is [here](https://www.tutorialrepublic.com/php-tutorial/php-mysql-login-system.php) under "Step 1" of "Building the login system" I simply copy-pasted that code 2 days ago. And as stated, everything worked flawlessly 2 days ago. @Funk Forty Niner - The code for the login button can be seen there (although if you want me to repost it here, I'm more than happy to oblige). Also I considering I copy-pasted from that site, it worked 2 days ago, but no longer works, I can't imagine it's a unicode issue. – Trevzilla Sep 04 '18 at 16:01
  • 1
    sometimes, copied code from a website contains unicode, but if you say that it worked and stopped working suddenly, then I'm baffled. – Funk Forty Niner Sep 04 '18 at 16:03
  • 1
    Looks like I found the solution! See answer below. Would still love a reason why filezilla would cause that error. Maybe Filezilla is encoding with unicode or something as @Funk Forty Niner suggested? I'll have to look into filezilla settings. – Trevzilla Sep 04 '18 at 16:11

1 Answers1

0

Well, I got something that seems to work. When uploading my file with filezilla, I am greeted with this Warning.

I decided to try a different FTP program to upload (NppFTP to be specific) and my problem went away. I still have no idea why this works though! Any body know why that might be an issue?

Trevzilla
  • 29
  • 1
  • 2
  • 9
  • I think your FTP program was probably not sending as text but as binary. Now "that" would explain it. – Funk Forty Niner Sep 04 '18 at 16:12
  • Not sure if this is the appropriate place to continue this discussion or not...but here goes. When I select "ASCII" in Filezilla I get the error. When I select "Binary" I do NOT get the error. To me this seems counter-intuitive. I would think it's the other way around. – Trevzilla Sep 04 '18 at 16:36
  • yeah, that is really odd. – Funk Forty Niner Sep 04 '18 at 16:38
  • 1
    I had the same problem. Forcing FileZilla to send as binary instead of text solved it. Issue was only for include files with a .inc extension. – Alexandre Avrane Dec 30 '18 at 21:06