Same question with different answer

2

Good morning: To work, take the essentials and it worked.

$sql021x = "SELECT * FROM $t00 WHERE 00_idpac= '3' ";

//$id el 3 reemplaza al $id sólo para no andar pasando por el buscador.

To then include the join (which is not yet) I replaced the * with the table and field names:

$sql021x = "SELECT $t00.00_apellido, 
                   $t00.00_nombres,
                   $t00.00_fenacim,
                   $t00.00_nacional, 
                   $t00.00_dni, 
                   $t00.00_domicili,
                   $t00.00_localida,
                   $t00.00_cp,
                   $t00.00_partido,
                   $t00.00_contacto,
                   $t00.00_telcelu,
                   $t00.00_telfijo,
                   $t00.00_email,
                   $t00.00_relfami,
                   $t00.00_oscobert,
                   $t00.00_nucobert,
                   $t00.00_tienecud,
                   $t00.00_fevenccud,
                   $t00.00_diagnost,
                   $t00.00_motivocons,
                   $t00.00_proforien,
                   $t00.00_feorien,
                   $t00.00_hoorien,
                   $t00.00_observac,
                   $t00.00_iduser,
                   $t00.00_carga,
                   $t00.00_idpac 
            FROM $t00  
            WHERE 00_idpac= '3' ";

And the answer is:

  

ERROR: It is not possible to execute the query SELECT 00_dato_pac.00_lastname, 00_dato_pac.00_nombre, 00_dato_pac.00_fenacim, 00_dato_pac.00_nacional, 00_dato_pac.00_dni, 00_dato_pac.00_domicili, 00_dato_pac.00_localida, 00_dato_pac.00_cp, 00_dato_pac.00_partido, 00_dato_pac. 00_contacto, 00_dato_pac.00_telcelu, 00_dato_pac.00_telfijo, 00_dato_pac.00_email, 00_dato_pac.00_relfami, 00_dato_pac.00_oscobert, 00_dato_pac.00_nucobert, 00_dato_pac.00_tienecud, 00_dato_pac.00_fevenccud, 00_dato_pac.00_diagnost, 00_dato_pac.00_motivocons, 00_dato_pac.00_proforien, 00_dato_pac.00_feorien, 00_dato_pac.00_hoorien, 00_dato_pac.00_observac, 00_dato_pac.00_iduser, 00_dato_pac.00_carga, 00_dato_pac.00_idpac FROM 00_dato_pac WHERE 00_idpac = '3'.

I feel confused

Someone here who understands or knows what macana I sent me?

    
asked by Silvia Gaviota Garcia 11.10.2017 в 17:20
source

1 answer

3

Try the following:

  
  • Alias the columns. Example: $t00.00_apellido AS Apellido . Maybe the special characters Example: $ can   cause problems
  •   
  • It also checks whether or not those columns exist in the table.
  •   
  • It also uses mysqli_error() to check the error of the message after executing the query 1 .
  •   

Contribution of Asero82 in your comment :

It may be that line breaks are not allowed. Test with two fields without line breaks.

Example: sql021x = "SELECT $t00.00_apellido, $t00.00_nombres FROM $t00 WHERE 00_idpac = '3'"

1 Source: Comment on the Question Can not execute a sql query (mysql, php)

    
answered by 11.10.2017 / 18:03
source