I am trying to run following command But I end up with an error :

0 votes

I am trying to run following code :

$con=mysqli_connect("localhost","root");

mysqli_select_db($con,"hellotune");

$sql="select email,password from register where email='".$email."' and password='".$password."'";

$result=mysqli_query($con,$sql);

$record=mysqli_num_rows($result);

But following error is occured:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\wamp64\www\HelloTune\login.php on line 38

Can anyone please tell me what is wrong in this code.

Thanking You.

Apr 9 in PHP by Nishant
• 210 points
31 views

1 answer to this question.

0 votes

Hello Nishant,

You are getting this error because your query failed. 

So,you can use mysqli_error and echo your query to see the problem. Everywhere that you have

$query = mysqli_query($db_conx, $sql);

You should add:

$query = mysqli_query($db_conx, $sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(db_conx), E_USER_ERROR);

You should consider switching to the OOP mysqli between, then you don't have to use the connection variable every time and if you can't resolve error then send me your file.php

Hope this works!!

Thank You!!

answered Apr 9 by Niroj
• 22,790 points

Related Questions In PHP

0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered Feb 13 in PHP by Niroj
• 22,790 points
106 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19 in PHP by Niroj
• 22,790 points
36 views
0 votes
1 answer

How to convert an image to base64 encoding?

Hello @kartik, You can also do this via ...READ MORE

answered Apr 1 in PHP by Niroj
• 22,790 points
31 views
0 votes
1 answer

How to prevent XSS with HTML/PHP?

Hello, HTML Encoding htmlspecialchars will convert any "HTML special characters" ...READ MORE

answered Apr 1 in PHP by Niroj
• 22,790 points
34 views
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,200 points
176 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
4,888 views
0 votes
1 answer

Failure uploading Image on AmazonS3 with PHP SDK

Try this, I took it out from ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,630 points
883 views
0 votes
1 answer

Trying to call AWS API via PHP

Try using AWS SDK for PHP, Link ...READ MORE

answered Jun 6, 2018 in AWS by Cloud gunner
• 4,630 points
456 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8 in PHP by Niroj
• 22,790 points
26 views
0 votes
1 answer

How to Validate Form Data With PHP?

Hey @kartik, The first thing we will do ...READ MORE

answered Feb 13 in PHP by Niroj
• 22,790 points
93 views