Query problems, I think, but no php errors

Asked

Viewed 34 times

-1

The form with the textboxes is not being shown

$session_Nome = $_SESSION['nome'];

$servername = "localhost";
$username = "root";
$password = "";
$db = "aeac";

// Create connection

$conn = mysqli_connect($servername, $username, $password, $db);

 //Check connection

if (!$conn) {
        die("Falha na ligação: " . mysqli_connect_error());
}
else {
    $sqla = "SELECT * FROM admin WHERE $session_Nome='username_Admin'";
    $result = mysqli_query($conn, $sqla);
    if ($result) {
        while($rowa= mysqli_fetch_assoc($result))
        {
            echo 'Nome: <input required type="text" name="nome" value="<?php echo $session_Nome; ?>"style="width: 300px;"><br><br><br>
            Email: <input required type="email" name="email" value="<?php echo $rowa["email"]; ?>"style="width: 300px;"><br><br><br>
            Senha: <input required type="password" name="password" value="<?php echo $rowa["password_Admin"]; ?>"style="width: 300px;"><br><br><br>';
        }
    }
}
  • 1

    change that line $rowa= mysqli_fetch_assoc($result); for while($rowa= mysqli_fetch_assoc($result))

  • I still have the same problem

  • Why are you wearing <?php within the plicas? whenever printing a php variable inside a string use the quotes duplas. <?php echo "Bla bla $minhastring[qualquercoisa] "; ?>

  • @Iazyfox, Ta using yes

  • @Redcandy which is line 86?

  • The 86 line is Email:'<input required type="email" name="email" value="<? php echo $rowa["email"]; ? >"style="width: 300px;"><br><br><br><br>

  • At the moment you are not displaying the form, so I think it is problems in the query?

  • Put a var_dump of the $sqla variable

  • string(51) "SELECT * FROM admin WHERE Redcandy='username_Admin'"

Show 4 more comments

1 answer

0


Along those lines

$sqla = "SELECT * FROM admin WHERE $session_Nome='username_Admin'";

change the simple place quotes

thus:

$sqla = "SELECT * FROM admin WHERE '$session_Nome'=username_Admin";
  • Perfect, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.