No error is reported for mysqli_connect, but notavalidMySQL-Linkresource is displayed in subsequent operations.

Source: Internet
Author: User
{Code...} reported an error: {code...} while using the object-oriented method is no problem. what is the problem?
$connect = mysqli_connect("host","user","password","db") or die("Error " . mysqli_error($connect));$result = mysql_query('select * from admin',$connnet);print(mysql_num_rows($result));mysql_close();

Error:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resourceWarning: mysql_num_rows(): supplied argument is not a valid MySQL result resourceWarning: mysql_close(): no MySQL-Link resource supplied

There is no problem with using the object-oriented method.
What is the problem?

Reply content:
$connect = mysqli_connect("host","user","password","db") or die("Error " . mysqli_error($connect));$result = mysql_query('select * from admin',$connnet);print(mysql_num_rows($result));mysql_close();

Error:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resourceWarning: mysql_num_rows(): supplied argument is not a valid MySQL result resourceWarning: mysql_close(): no MySQL-Link resource supplied

There is no problem with using the object-oriented method.
What is the problem?

Because you wrote the wrong letter...
The first variable is $ connect.
The second variable is $ connnect.
N More, okay?
Of course, you should also use mysqli_query instead of mysql_query.

Mysql_query-> mysqli_query
Mysql_num_rows-> mysqli_num_rows
Mysql_close-> mysqli_close

Dude, you have to use mysqli_xxx to use the connection created by mysqli_connect.
Mysqli_xxx and mysql_xxx cannot be mixed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.