$dc=fopen("numeu.txt","rb");
$row1=fgets($dc,120);
$row2=fgets($dc,120);
$row3=fgets($dc,120);
fclose($dc);
$servername="localhost";
$username="root";
$password='';
$database="Stildev";
$conn = new mysqli($servername, $username, $password, $database);
$sql="SELECT poza1,poza2,poza3,poza4,poza5,poza6 FROM postari WHERE utilizator='".$row2."' AND subiect='".$row1."' AND id2='".$row3."'";
$resultat=$conn->query($sql);
echo $resultat->num_rows;
This piece of code returns 0 rows
There is no error and sql query works just fine in MySQL console.
Also i discovered that withought WHERE clause the code works.How you explain that?
Is the password empty on purpose?
Try adding
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
Also, according to https://php.net/manual/ro/mysqli.query.php , this may help:
if ($result = $mysqli->query($sql)) {
echo $result->num_rows;
/* close result set */
$result->close();
}
If you are using several result-returning queries, close previous results with ->close();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.