php - Error "mysqli_num_rows" -
this question has answer here:
how fix error ?
edit.php:
<?php include 'connect.php'; if(isset($_post['btn_submit'])){ } $cpf = ''; $nome = ''; $cep = ''; if(isset($_get['cpf'])){ $sql = "select cpf, nome, cep pessoas where cpf=" .$_get['cpf']; $result = mysqli_query($con, $sql); if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_assoc($result) ; $cpf = $row['cpf']; echo $cpf; } } ?>
error:
warning: mysqli_num_rows() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\banco_de_dados\edit.php on line 158
connect.php:
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "meubd"; // create connection $con = mysqli_connect($servername, $username, $password, $dbname); // check connection if ($con->connect_error) { die("connection failed: " . $con->connect_error); } $sql = "select nome, cpf, cep, rua, bairro, cidade, estado, ibge pessoas"; $result = $con->query($sql); ?>
you need write quotes around statement of get.
$sql = "select cpf, nome, cep pessoas cpf='" . $_get['cpf'] . "'";
Comments
Post a Comment