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
157 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,820 points

Related Questions In PHP

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,820 points
5,219 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,820 points
152 views
0 votes
1 answer

How can I convert the output of PHP's filesize() function to a format with MegaBytes, KiloBytes etc?

Hello @kartik, Here is a sample: <?php // Snippet from ...READ MORE

answered Sep 15, 2020 in PHP by Niroj
• 82,820 points
631 views
0 votes
1 answer

How to run process with realtime output in PHP?

Hello @kartik, This worked for me: $cmd = "ping ...READ MORE

answered Oct 20, 2020 in PHP by Niroj
• 82,820 points
957 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
373 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
8,233 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,650 points
1,612 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,650 points
852 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,820 points
221 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,820 points
178 views