How to concatenate a String with SQL query in PHP?

1

I am writing a script in php that makes a query to a sql database.

The result of that query I need to concatenate it with a string.

Example: the query to the database returns "Cosme Fulanito" and I need to concatenate it with a string that says "Mi nombre es" so that the result is "Mi nombre es Cosme Fulanito" .

The query result is stored in a variable and the string is equal, and try with:

$consulta = "ejemplo de consulta";
$cadena = "Mi nombre es" ;
$nombre = $cadena . $consulta; 

How could I solve it?

    
asked by Cosme Fulanito 06.08.2017 в 03:17
source

2 answers

1

This is how it should work

$consulta = "ejemplo de consulta";
$cadena = "Mi nombre es" ;
$nombre = $cadena .' '. $nombre; 
    
answered by 06.08.2017 в 03:22
1

To concatenate a string you do not have to save it in a variable, you can do it like this:

echo 'Mi nombre es' . $nombre;
    
answered by 06.08.2017 в 03:23