1

Hello and i am having a problem with php at the moment which is kind of getting annoying ive tried everything i can and the error i get is

Parse error: syntax error, unexpected 'var' (T_VAR) in C:\wamp\www\index.php on line 23

And Im using this code


<html>
<head><title> Panda Project </title></head>
<body>
<?php
session_start();
// Db Details
$servername = "no ip for you";
$username = "no user name for you";
$password = "no password for you";
$database = "remoteaddr";
// Creates Connection To Db
$conn = new mysqli($servername, $username, $password, $database) OR die("Error Connecting : " .  $conn->connect_error);
$remoteconn = $_SERVER['REMOTE_ADDR'];
// Checks Connection To Db
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "<br>";
// Inserts Query
$sql = "INSERT INTO connections (IP)
VALUES ('$remoteconn')";
// Checks Query
var filename = 0;
$get = TRUE;
$file_exists ( "log/atestconnection.txt");
if(file_exists == TRUE) {
    while(get) {
            $sfilename = (string)$filename;
            $check_file = ("log/". $sfilename .".txt");
            if(check_file == TRUE) 
                filename+
            if(check_file == FALSE) {
                rename("log/latestconnection.txt" . $filename . ".txt");
                get = FALSE;
            }
    }
}
system("echo " . $remoteconn . " > log/latestconnection.txt");
if ($conn->query($sql) === TRUE) {
} else {
}
$conn->close();
?>
<table align="center" border=1 width=20 height = 20>
<th> Your IP </th>
<?php
echo "<tr>";
echo "<td> " . $remoteconn . " </td>";
echo "</tr>";
?>
</body></html>

Now Im Getting This Error Parse error: syntax error, unexpected 'if' (T_IF) in C:\wamp\www\index.php on line 32 I Get Quite A Few Theres 3 More D:!

ImXari
  • 144
  • 1
  • 1
  • 8
  • 2
    You have an error on line 23. `var` doesn't make sense here. It would make sense in JavaScript, but in PHP yo use `$`. –  Apr 13 '15 at 14:33

1 Answers1

2

Replace var filename = 0; by $filename = 0

Med
  • 2,035
  • 20
  • 31
  • 1
    Tip: You can use back ticks ` to designate `inline code snippets` – nuala Apr 13 '15 at 14:37
  • Daan that worked thanks! but i now get this error "Parse error: syntax error, unexpected 'if' (T_IF) in C:\wamp\www\index.php on line 32" – ImXari Apr 13 '15 at 14:37