I'm trying to connect to the database via myqli
with php
but I can not. Here is the code:
<html>
<head>
<title>sistema de cadastro</title>
</head>
<body>
<form method="get" action="cadastramento.php">
nome:
<input type="text" name="name" />
<p></p>
sobre nome:
<input type="text" name="sobrenome" />
<p></p>
senha:
<input type="password" name="senha" />
<p></p>
<input type="submit" value="" />
</form>
</body>
</html>
Now the mysqli connection code in php:
<html>
<head>
<title> cadastramento</title>
</head>
<body>
<?php
$servidor = 'localhost';
$usuario = 'root';
$senha = '';
$banco = 'mydb';
$mysqli = new mysqli($servidor, $nome, $ssobrenome, $senha);
if (mysqli_connect_errno()) trigger_error(mysqli_connect_error());
?>
<?php
$mysqli = new mysqli('localhost', 'root', '', 'mydb');
$sql = "SELECT 'id', 'titulo' FROM 'cadastramento' LIMIT 5";
$query = $mysqli->query($sql);
while ($dados = $query->mysqli_fetch_array()) {
echo 'ID: ' . $dados['id'] . '';
echo 'Título: ' . $dados['titulo'] . '';
}
echo 'Registros encontrados: ' . $query->num_rows;
?>