<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Simular POST
$_POST['per2'] = 9;
$_POST['cur2'] = 12;
$_POST['estudiante2'] = 160008;

include '../conector.php';
include 'fpdf.php';

echo "=== Debug: Test select_periodos query ===\n\n";

echo "per2 = " . $_POST['per2'] . "\n";
echo "Type: " . gettype($_POST['per2']) . "\n";

$per2 = $_POST['per2'];
echo "per2 as variable: $per2\n";

$select_periodos="select a.anno,b.periodo,b.id,a.periodo
                from planilla a,planilla b 
                where a.id=$per2 
                and a.anno=b.anno
                and b.periodo<a.periodo
                order by b.periodo";

echo "\nQuery: $select_periodos\n\n";

$res_select_periodos = mysql_query($select_periodos);
if(!$res_select_periodos){
    echo "ERROR: " . mysql_error() . "\n";
    echo "Error number: " . mysqli_errno() . "\n";
} else {
    echo "Success!\n";
    echo "Rows: " . mysql_num_rows($res_select_periodos) . "\n";
}
?>