php - Error "mysqli_num_rows" -


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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -