Pregunta:
Fecha: 22-06-2018 09:34:12
(En Español)
error Notice Undefined offset 2 in C:\XAMPP\HTDOCS\TEST2.PHP ON LINE 26
Me sale este error: Notice Undefined offset 2 in C:\XAMPP\HTDOCS\TEST2.PHP ON LINE 26[No resuelta]
Hola me sale este error soy nuevo en php estoy aprendiendoerror Notice Undefined offset 2 in C:\XAMPP\HTDOCS\TEST2.PHP ON LINE 26
<?php
$conn = oci_connect('hr', 'hr', 'localhost/xe');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$query = "select * from departments";
$stid = oci_parse($conn, $query);
oci_execute($stid);
$myfile=fopen("myFile","w") or die("Unable to open File");
$columns_total = oci_num_fields($stid);
$output = "";
for ($i = 1; $i <= $columns_total; $i++) {
$heading = oci_field_name($stid, $i);
$output .= '"'.$heading.'",';
}
$output .="\n";
while(($row=oci_fetch_array($stid,OCI_BOTH))!=false)
{
for ($i = 0; $i < $columns_total; $i++) {
$output .= '"'.$row[$i].'",';
}
$output .="\n";
}
oci_free_statement($stid);
oci_close($conn);
fwrite($myfile, $output);
echo "Data successfully exported";
fclose($myfile);
?>
Votos: 0 -
Respuestas: 3 -
Vistas: 11
Compartir en: Google
Facebook
Twitter
LinkedIn
Link
Respuestas:
-
Fecha: 25-06-2018 09:20:46 El Array al que tratas de acceder no tiene ese índice
Puedes poner específicamente la línea 26 Votos: 0 - Link respuesta -
Fecha: 25-06-2018 12:10:05 hice este nuevo y me saca este error una disculpa pero sufro de problemas para leer y ver
me saca error en la linea 30
<?php
$con = oci_connect("hr", "hr","localhost/XE");
$sql = 'select DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID from departments';
$resultado = oci_parse($con, $sql);
oci_execute($resultado);
$columns_total = oci_num_fields($resultado);
$output = "";
for ($i = 1; $i <= $columns_total; $i++) {
$heading = oci_field_name($resultado, $i);
$output .= '"'.$heading.'",';
}
$output .="\n";
if(oci_num_fields($resultado) > 0)
{
$output .='
<table class="table" bordered="1">
<tr>
<th>DEPARTMENT_ID</th>
<th>DEPARTMENT_NAME</th>
<th>MANAGER_ID</th>
</tr>
</table>'
;
while (($row = oci_fetch_array($resultado,OCI_BOTH))! = false)
{
for ($i = 0; < $columns_total;$i++){
$output .='"'.$row[$i].'"';
}
$output .="\n";
}
$output .="\n";
header("content-Type:application/xls");
header("Content-Disposition: attachment; filename=download.xls");
echo $output;
}
?> Votos: 0 - Link respuesta -
Fecha: 25-06-2018 13:42:26 Porque el formato empieza en 1
Si es un Array va a empezar desde cero Votos: 0 - Link respuesta
Para participar activamente de la comunidad primero debes autenticarte, ingresa al sistema.Iniciar Sesión
