-1

Sorry to bother you,

So i mixed APIs in my code in my first post, i figured it out and i checked my code, now everything is in MYSQL (not with MYSQLI and MYSQL as it was in my first post).

I've got another problem with my code, i've got the following error:

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in your code on line 8.

So here's my code, if someone could help me what to do, i would be thankful :)

<?php 
    session_start();
    ob_start();
    error_reporting(E_ALL);
    require_once 'dbconnect.php';
    include_once("apitest/Functions/GTServerInfo.php"); 

    $sql = "SELECT server FROM users WHERE userId = $_SESSION['userId']"; 
    $result = mysql_query($sql);

    if (mysql_num_rows($result) > 0) {
        // output data of each row

        while($row = mysql_fetch_assoc($result)) {
            $ip=$row["server"];
        }
    } else {
        echo "0 results";
    }
    mysql_close($con);



    if( !isset($_SESSION['user']) ) {

            header("Location: index.php");

            exit;

    }

    ?>

Line 8:

 $sql = "SELECT server FROM users WHERE userId = $_SESSION['userId']"; 
Ebbe M. Pedersen
  • 7,250
  • 3
  • 27
  • 47
darknet
  • 47
  • 5

1 Answers1

0

It should be $_SESSION and not $_SESSiON, I corrected it below;

$sql = "SELECT server FROM users WHERE userId = $_SESSION['userId']";
Derick Alangi
  • 1,080
  • 1
  • 11
  • 31
  • Still no results fetched – darknet Aug 20 '16 at 21:33
  • Do you still have the syntax error? – Derick Alangi Aug 20 '16 at 21:34
  • At least that is resolved right? – Derick Alangi Aug 20 '16 at 21:34
  • No, i don't have the syntax error anymore, but no results are fetched now :( – darknet Aug 20 '16 at 21:35
  • Yes, results might not be fetched since we need to know what the value of $_SESSION['userId'] is and see if there is any value like that in the DB that matches that value for results to be searched. Try to var_dump($_SESSION['userId']) and check its value. – Derick Alangi Aug 20 '16 at 21:36
  • I made the mysql table myself, so there is "userId" for sure, but how to do that? Sorry, i'm not very proffessional at this. – darknet Aug 20 '16 at 21:39
  • PHP often points to a line but the error has happened before that. Id be interested in seeing in what is contained in the include file - GTServerInfo.php. Im betting that there is an error in there. Try die-ing after each line and check your error reporting. – Deano Aug 21 '16 at 17:40