I get the error:
Fatal error: Uncaught Error: Call to undefined function call_components () in C: \ xampp \ htdocs \ webpage \ researchLabotatory \ inventory \ versala.php: 95 Stack trace: # 0 {main} thrown in C: \ xampp \ htdocs \ webpage \ researchLabotatory \ inventory \ versala.php on line 95
this is my code:
<?php
include($_SERVER['DOCUMENT_ROOT'].$_SERVER['ACTUAL_PAG']."config.php");
if(isset($_GET['sala'])){
$sala = $_GET['sala'];
}
$title = $sala;
$actualpagina = str_replace(' ', '', $sala);
?>
<?php include($ruta_php."head.php"); ?>
<!-- CABECERA -->
<?php include($ruta_php."navegacion.php"); ?>
<!-- IMAGEN ENTRANTE -->
<?php include($ruta_php."cabecera.php");?>
<!-- MAIN -->
<?php
//SI POR ALGÚN CASUAL NO SE RECIBE LA VARIABLE, NO MUESTRA NADA
//DE ESA FORMA NO MOSTRARÁ NINGUN ERROR, NO EJECUTARÁ NADA
//TAMBIEN EVITA QUE LA GENTE SE META EN LA PÁGINA DIRECTAMENTE CON EL LINK (por ejemplo: xxx/versala.php ) YA QUE ASÍ
//NO ENVIA NINGUNA VARIABLE (ejemplo correcto: xxx/versala.php?sala="XXXX")
if(isset($_GET['sala'])){
$sala = $_GET['sala'];
?>
<table class="tablepuestos">
<!-- NOMBRE DE LAS COLUMNAS -->
<thead>
<tr>
<th>
<!-- PARA AÑADIR MÁS -->
<?php if($_SESSION['tipo']=="administrador"){echo '<a href="'.$ruta_html.'adminpanel.php#crearElemento" class="addmore" title="Añadir nuevos elementos">+</a>';}?>
Component Ref
</th>
<th>Category</th>
<th>SubCategory</th>
<th>Name</th>
<th>Quantity</th>
<th>State</th>
<th>Link</th>
<th>Doc</th>
</tr>
</thead>
<!-- BODY PARA MOSTRAR EL CONTENIDO -->
<tbody>
<?php
if(!$inv_conexion){
men_error(mysqli_connect_error());
}
else{
// TODOS LOS SELECT DE LAS TABLAS NECESARIAS
$sql_elemento="SELECT * FROM elemento";
$sql_puesto="SELECT * FROM puesto";
$sql_sala="SELECT * FROM sala WHERE nombre='".$sala."'";
$sql_estado="SELECT * FROM estado";
//DECLARACIÓN DE VARIABLES
$idsala="";
$arraycomponentes=array();
//SELECCIONAMOS LA SALA
$sala_result=mysqli_query($inv_conexion,$sql_sala);
if(!$sala_result){
men_error("Imposible conectar con la tabla SALA de la base de datos");
}
else{
$sala_count=mysqli_num_rows($sala_result);
//SI NO EXISTE LA SALA SIMPLEMENTE MUESTRA QUE NO EXISTE
if($sala_count>0){
while($sala_fila=mysqli_fetch_array($sala_result)){
$idsala=$sala_fila["id_sala"];
}
//AQUI HAGO UNA CONSULTA A LA TABLA elemento
//EL TRUCO AQUÍ PARA QUE NO APAREZCAN DATOS REPETIDOS ES EL
//DISTINCT. QUE SI EL ID_ESTADO Y ID_COMPONENTES SON DISTINTOS
//ENTONCES LO MUESTRA
$sql_elemento="SELECT DISTINCT id_estado, id_componentes FROM elemento WHERE id_sala='".$idsala."'";
$elem_result=mysqli_query($inv_conexion,$sql_elemento);
if(!$elem_result){
men_error("Imposible conectar con la tabla ELEMENTO de la base de datos");
}
else{
$elem_count=mysqli_num_rows($elem_result);
if($elem_count>0){
while($elem_fila=mysqli_fetch_array($elem_result)){
//LLAMADA A LA TABLA COMPONENTES. DEVUELVE UN ARRAY CON TODA LA INFORMACIÓN
// 0 COMPONENT_REF
// 1 SUBCATEGORIA
// 2 CATEGORIA
// 3 NOMBRE
// 4 LINK
// LINEA 95 JUSTO DEBAJO
$id_componentes=$elem_fila['id_componentes'];
$id_estado=$elem_fila['id_estado'];
$arraycomponentes=llam_componentes($id_componentes);
//LLAMADA AL NOMBRE DEL ESTADO
$estado=llam_estado($id_estado);
//CUENTA CUANTAS FILAS TIENEN EL MISMO ID COMPONENTE Y EL MISMO ESTADO
$cantidad_result=mysqli_query($inv_conexion,"SELECT * FROM elemento WHERE id_componentes='".$id_componentes."' AND id_estado='".$id_estado."'");
$cantidad=mysqli_num_rows($cantidad_result);
//EL DOC - TEORIA:
//El doc son ficheros en los que se va almacenando la información de cada componente
//por ejemplo: el metodo de uso, el manual, la descripción, etc.
//simplemente es para tener un poco más de información sobre un componente en concreto
$documento=$ruta_php."doc/".$arraycomponentes[0].".php";
if(file_exists($documento)){
$fichero="<a href='".$ruta_html."doc/".$arraycomponentes[0]."'>DOC</a>";
}
else{
$fichero="<a href='' class='noexist'>DOC</a>";
}
//MOSTRAR EN PANTALLA
echo "<tr>";
echo "<td>".$arraycomponentes[0]."</td>";
echo "<td>".$arraycomponentes[3]."</td>";
echo "<td>".$arraycomponentes[2]."</td>";
echo "<td>".$arraycomponentes[1]."</td>";
echo "<td>".$cantidad."</td>";
echo "<td>".$estado."</td>";
echo "<td><a href='".$arraycomponentes[4]."'>Link</a></td>";
echo "<td>".$fichero."</td>";
echo "</tr>";
}
}
else{
$nocontenido="No existe ningun elemento que este en ".$sala;
}
}
}
else{
$nocontenido="No hay ninguna ".$sala;
}
}
}
//FUNCION DE LLAMADA A LA TABLA COMPONTNETES
function llam_componentes($id){
$sql_componentes="SELECT * FROM componentes WHERE id_componentes='".$id."'";
$compo_result=mysqli_query($GLOBALS['inv_conexion'],$sql_componentes);
$arraycompo = array();
if(!$compo_result){
men_error("Imposible conectar con la tabla COMPONENTES de la base de datos");
}
else{
$compo_count=mysqli_num_rows($compo_result);
if($compo_count>0){
while($compo_fila=mysqli_fetch_array($compo_result)){
//ESTABLECER EN EL ARRAY LOS VALORES
$arraycompo[0]=$compo_fila["component_ref"];
$arraycompo[1]=llam_subcategoria(2,$compo_fila['id_subcategoria']);
$arraycompo[2]=llam_subcategoria(1,$compo_fila['id_subcategoria']);
$arraycompo[3]=$compo_fila['nombre'];
$arraycompo[4]=$compo_fila['link'];
//RETORNAR EL ARRAY
return $arraycompo;
}
}
}
}
//FUNCION DE LLAMADA A LA TABLA SUBCATEGORIA
function llam_subcategoria($tipo,$id){
$sql_subcategoria="SELECT * FROM subcategoria WHERE id_subcategoria='".$id."'";
$subcat_result=mysqli_query($GLOBALS['inv_conexion'],$sql_subcategoria);
if(!$subcat_result){
men_error("Imposible conectar con la tabla SUBCATEGORIA de la base de datos");
}
else{
$subcat_count=mysqli_num_rows($subcat_result);
if($subcat_count>0){
while($subcat_fila=mysqli_fetch_array($subcat_result)){
//ESTO ES PARA DEVOLVER EL NOMBRE DE CATEGORIA O SUBCATEGORIA
//DEPENDIENDO DEL TIPO QUE LLAMES
switch($tipo){
case 1:
return $subcat_fila['nombre'];
break;
case 2:
return llam_categoria($subcat_fila['id_categoria']);
break;
}
}
}
}
}
//FUNCION DE LLAMADA A LA TABLA CATEGORIA
//NO TIENE MUCHO MISTERIO...
function llam_categoria($id){
$sql_categoria="SELECT * FROM categoria WHERE id_categoria='".$id."'";
$cat_result=mysqli_query($GLOBALS['inv_conexion'],$sql_categoria);
if(!$cat_result){
men_error("Imposible conectar con la tabla CATEGORIA de la base de datos");
}
else{
$cat_count=mysqli_num_rows($cat_result);
if($cat_count>0){
while($cat_fila=mysqli_fetch_array($cat_result)){
return $cat_fila["nombre"];
}
}
}
}
//FUNCION DE LLAMADA A LA TABLA ESTADO
//NO TIENE MUCHO MISTERIO...
function llam_estado($id){
//$sql_estado="SELECT * FROM estado WHERE id_estado='".$id."'";
$estad_result=mysqli_query($FLOBALS["inv_conexion"],$sql_estado);
if(!$estad_result){
men_error("Imposible conectar con la tabla estado de la base de datos");
}
else{
$estad_count=mysqli_num_rows($estad_result);
if($estad_count>0){
while($estad_fila=mysqli_fetch_array($estad_result)){
return $estad_fila["estado"];
}
}
}
}
?>
</tbody>
</table>
<!-- SI NO HAY CONTENIDO SE MUESTRA UN MENSAJE-->
<p class="sincontenido"><?php echo $nocontenido ?></p>
<?php
//CIERRE DE IF, SI NO RECIBE LA VARIABLE DEL POST
}
else{
men_error("Ha ocurrido un error inesperado");
}
?>
<!-- FOOTER -->
<?php include($ruta_php."footer.php"); ?>
Well, what to tell ... Basically I get that error and I do not understand or because since I'm using mysqli_ I've even passed it through a php validator so that I find some flaw and nothing