I'm starting PHP with SQL Server 2008.
The code below makes a query in the database and displays what has been obtained.
<?php
$serverName = "DESKTOP-B8EB4SG\SQLEXPRESS";
$connectionInfo = array( "Database"=>"contas", "UID"=>"sa", "PWD"=>"123456" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
//$sql = "INSERT INTO usuarios (login, senha) VALUES (?, ?)";
$seleciona = "SELECT Login FROM pessoas WHERE UID=3";
// Executa a consulta
$stmt = sqlsrv_query($conn, $seleciona);
if ($stmt === false) {
die(print_r(sqlsrv_errors(), true));
}
if ($stmt == "renato")
echo "Bem-vindo";
// Exibe o resultado
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
echo $row['Login'].'<br>';
}
?>
I would like that when the Login name obtained was renato , it displayed Welcome . After all, why does not the welcome appear? Do you need some sort of conversion to string / char?
NOTE: I know there must be endless explanations about this, but I do not know exactly what to look for.