Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or ...?

1

I'm doing a school work that is just to check ratings I'm doing in php and I already have the login but when I click on my menu to show me my qualifications send me the following error I'm using Xampp I leave my code I guess my error is in the query when I want to send to call the user's qualifications that I start session ojala could help me with my query or how do I do the tour if in any of the two I'm wrong.

Line 58 of my code is just the one in the query:

$calf=mysql_query("'SELECT * FROM boleta WHERE CURP = $_SESSION['Usuario']'");

Error that appears in xampp:

  

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

Code:

<?php 
session_start();
$_SESSION['Usuario'];
include "./conexion.php";
$re=mysql_query("select * from user_alumno where CURP='".$_POST['Usuario']."' AND 
          CONTRASENA='".$_POST['Password']."'") or die(mysql_error());
  while ($f=mysql_fetch_array($re)) {
      $arreglo[]=array('Id'=>$_POST['id']);

  }
  if(isset($arreglo)){
    $_SESSION['Usuario']=$arreglo;
    header("Location: ../admin.php");
  }else{
    header("Location: ../login.php?error=datos no validos");
  }

?> 

<!DOCTYPE html>
<html lang="es">
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<head>
<link href="csscali.css" rel="stylesheet" type="text/css" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>REPORTES</title>
<link href="csscali" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="./css/estilos.css">
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
  <script type="text/javascript"  href="./js/scripts.js"></script>
</head>
<body>


  <center><h1>CALIFICACIONES</h1></center>
   <?php mb_internal_encoding("UTF-8");
   mysql_query("SET NAMES 'utf8'"); ?>


  <table border="0px" width="100%"> 
    <tr>
      <td>Curp</td>
      <td>Materia</td>
      <td>Calificacion 1</td>
      <td>Calificacion 2</td>
      <td>Calificacion 3</td>
      <td>Calificacion Final</td>
      <td>Asistencia 1</td>
      <td>Asistencia 2</td>
      <td>Asistencia 3</td>

    </tr> 
<?php
if(isset($_POST['Usuario'])){
        $calf= $_POST['id'];
    $calf=mysql_query("'SELECT * FROM boleta WHERE CURP = $_SESSION['Usuario']'");
    $result = mysql_query($calf);
    if (mysql_num_rows($calf)>0) {
          $row = mysql_fetch_array($result);
          $_SESSION["Usuario"] = $row['id'];
            $calf=$_POST['id'];
          echo '<tr>
            <td>'.$calf['CURP'].'</td>
            <td>'.$calf['MATERIA'].'</td>
            <td>'.$calf['CALIFICCION1'].'</td>
              <td>'.$calf['CALIFICCION2'].'</td>
              <td>'.$calf['CALIFICCION3'].'</td>
              <td>'.$calf['CALIFICCION_FINAL'].'</td>
              <td>'.$calf['ASISTENCIA1'].'</td>
              <td>'.$calf['ASISTENCIA2'].'</td>
              <td>'.$calf['ASISTENCIA3'].'</td>

          </tr>';
                }
                }

    ?>
    
asked by abdiel sandoval 08.08.2017 в 23:13
source

2 answers

1

You have several quotes that open / close incorrectly.

I think with:

$calf=mysql_query("SELECT * FROM boleta WHERE CURP = $_SESSION['Usuario']");

It should work for you. Notice that I have removed the simple quotes that you have at the beginning and end of the Select. On the other hand, since you do not indicate how the CURP code of your application is, I have assumed that it is an integer, and therefore it does not include quotation marks. If it were a chain, I would recommend changing it to:

$curp = $_SESSION('Usuario');
$sql = sprintf("SELECT * FROM boleta WHERE CURP = '%s'", $curp);
$calf=mysql_query($sql);

NOTE : Since you use the $ _SESSION variable directly, your code can be targeted by SQL injection attacks. Check the security in your code.

    
answered by 08.08.2017 в 23:19
0

Hello, remove the single quotes at the beginning and end and the session variable adds it to another clean variable so that you do not have to insert the [] inside the insert:

$usuario = $_SESSION['Usuario'];
$calf=mysql_query("SELECT * FROM boleta WHERE CURP = '$usuario' ");
    
answered by 08.08.2017 в 23:22