douxi7219 2016-08-20 21:27
浏览 84

解析错误:语法错误,意外''(T_ENCAPSED_AND_WHITESPACE)[重复]

This question already has an answer here:

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']"; 
</div>
  • 写回答

1条回答 默认 最新

  • douwen5924 2016-08-20 21:32
    关注

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

    $sql = "SELECT server FROM users WHERE userId = $_SESSION['userId']";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题