Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Recoverable fatal error: Object of class mysqli could not be converted to string

Estas en el tema de Recoverable fatal error: Object of class mysqli could not be converted to string en el foro de PHP en Foros del Web. Código PHP: mysqli_set_charset ( $cnx = mysqli_connect ( 'localhost' , 'root' , null , 'pruebas' ), 'utf8' ); var_dump ( $cnx ); var_dump ( "UPDATE $table SET " ...
  #1 (permalink)  
Antiguo 13/06/2019, 05:48
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 3 meses
Puntos: 9
Recoverable fatal error: Object of class mysqli could not be converted to string

Código PHP:
mysqli_set_charset($cnx=mysqli_connect('localhost','root',null,'pruebas'),'utf8');

var_dump($cnx);
var_dump("UPDATE $table SET ".implode(',',$u)." WHERE "."id_".$singular[$DDBB]."=".$id);
mysqli_query($cnx."UPDATE $table SET ".implode(',',$u)." WHERE "."id_".$singular[$DDBB]."=".$id); 
//Navegador
Cita:
object(mysqli)#2 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(79) "mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $" ["client_version"]=> int(50012) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(21) "5.5.5-10.1.38-MariaDB" ["server_version"]=> int(50505) ["stat"]=> string(135) "Uptime: 77391 Threads: 1 Questions: 3458 Slow queries: 0 Opens: 27 Flush tables: 1 Open tables: 21 Queries per second avg: 0.044" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(805) ["warning_count"]=> int(0) } string(11) "profesional" object(mysqli)#3 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(79) "mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $" ["client_version"]=> int(50012) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(21) "5.5.5-10.1.38-MariaDB" ["server_version"]=> int(50505) ["stat"]=> string(135) "Uptime: 77391 Threads: 2 Questions: 3459 Slow queries: 0 Opens: 27 Flush tables: 1 Open tables: 21 Queries per second avg: 0.044" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(806) ["warning_count"]=> int(0) }

string(11) "profesional" string(116) "UPDATE profesionales SET nombre='Andrea5',apellidos='Gómez',profesional='Ps ic.' WHERE id_profesional=9"

Recoverable fatal error: Object of class mysqli could not be converted to string in C:\xampp\htdocs\controller\controller.php on line 21

Última edición por quico5; 13/06/2019 a las 06:07
  #2 (permalink)  
Antiguo 13/06/2019, 09:36
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Recoverable fatal error: Object of class mysqli could not be converted to

En la consulta estás concatenando la variable de conexión con la consulta, después de $cnx cambia el punto por coma y listo.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 17/06/2019, 05:36
 
Fecha de Ingreso: enero-2008
Mensajes: 580
Antigüedad: 16 años, 3 meses
Puntos: 9
Respuesta: Recoverable fatal error: Object of class mysqli could not be converted to

Hola @Tribi, muchas gracias por responder

Qué error más tonto

Etiquetas: class, fatal, mysql, mysqli, object, query, string
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:40.