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, 2020 in PHP by Nishant
• 210 points
498 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, 2020 by Niroj
• 82,880 points

Related Questions In PHP

0 votes
0 answers
0 votes
0 answers
0 votes
1 answer

How can I access the MySQL command line with XAMPP for Windows?

Hello @kartik, Your MySQL binaries should be somewhere ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,880 points
19,831 views
0 votes
1 answer

How do I import an SQL file using the command line in MySQL?

Hello @kartik, Try: mysql -u username -p database_name < ...READ MORE

answered Aug 26, 2020 in PHP by Niroj
• 82,880 points
1,106 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,220 points
1,146 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
10,903 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,670 points
3,679 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,670 points
1,455 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, 2020 in PHP by Niroj
• 82,880 points
810 views
0 votes
1 answer

How can I do an UPDATE statement with JOIN in SQL Server?

Hello @kartik, This should work in SQL Server: update ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,880 points
610 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP