PHP - Warning: Illegal string offset y Notice: Use of undefined constant

 
Vista:

Warning: Illegal string offset y Notice: Use of undefined constant

Publicado por mario (3 intervenciones) el 24/09/2017 23:01:21
este es mi codigo fuente !

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$host="localhost";
$usuario="root";
$contraseña="";
$base="registro";
 
$conexion= new mysqli($host, $usuario, $contraseña, $base);
if ($conexion->connect_errno){
    die("Fallo La Conexion A La Base De Datos:(".$conexion -> mysqli_connect_errno().")".$conexion-> mysqli_connect_error());
}
 
 
$formulario="SELECT * FROM formulario";
$resformulario=$conexion->query($formulario);
$formulario=mysqli_fetch_array($formulario, $resformulario);
    while($resformulario){
        echo'<tr>
            <td>'.resformulario['codigo'].'</td>
            <td>'.resformulario['nombre_perro'].'</td>
            <td>'.resformulario['raza'].'</td>
            <td>'.resformulario['edad'].'</td>
            <td>'.resformulario['caracteristica'].'</td>
            <td>'.resformulario['Localidad_Barrio'].'</td>
            <td>'.resformulario['nombre'].'</td>
            <td>'.resformulario['cc'].'</td>
            <td>'.resformulario['tel'].'</td>
            <td>'.resformulario['direccion'].'</td>
            <td>'.resformulario['email'].'</td>
        </tr>';
    }
?>



y el error que me sale es este
el primero por el mysqli_fetch_array me sale eso y en lo demas lo otro
[b]Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 61

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 64

Warning: Illegal string offset 'codigo' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 64

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 65

Warning: Illegal string offset 'nombre_perro' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 65

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 66

Warning: Illegal string offset 'raza' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 66

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 67

Warning: Illegal string offset 'edad' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 67

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 68

Warning: Illegal string offset 'caracteristica' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 68

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 69

Warning: Illegal string offset 'Localidad_Barrio' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 69

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 70

Warning: Illegal string offset 'nombre' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 70

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 71

Warning: Illegal string offset 'cc' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 71

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 72

Warning: Illegal string offset 'tel' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 72

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 73

Warning: Illegal string offset 'direccion' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 73

Notice: Use of undefined constant resformulario - assumed 'resformulario' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 74

Warning: Illegal string offset 'email' in C:\xampp\htdocs\FormularioRegistro\php\consulta.php on line 74



MUCHAS GRACIAS!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Warning: Illegal string offset y Notice: Use of undefined constant

Publicado por xve (6935 intervenciones) el 25/09/2017 12:21:57
Hola Mario, creo que estas utilizando incorrectamente la lectura del resultado de la base de datos... si utilizas mysqli como objeto, siempre tienes que utilizarlo como un objeto...

yo lo haría así:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$formulario="SELECT * FROM formulario";
$resformulario=$conexion->query($formulario);
while($row = $resformulario->fetch_array(MYSQLI_ASSOC)){
    echo'<tr>
        <td>'.$row['codigo'].'</td>
        <td>'.$row['nombre_perro'].'</td>
        <td>'.$row['raza'].'</td>
        <td>'.$row['edad'].'</td>
        <td>'.$row['caracteristica'].'</td>
        <td>'.$row['Localidad_Barrio'].'</td>
        <td>'.$row['nombre'].'</td>
        <td>'.$row['cc'].'</td>
        <td>'.$row['tel'].'</td>
        <td>'.$row['direccion'].'</td>
        <td>'.$row['email'].'</td>
    </tr>';
}
?>

Te sirve?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Warning: Illegal string offset y Notice: Use of undefined constant

Publicado por mario (3 intervenciones) el 25/09/2017 16:33:54
dale lo voy a mirar muchas gracias!!! por tomate el tiempo y revisarlo !!! gracias men!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar