mysqli_connect does not report an error, but subsequent operations show not a valid MySQL-Link resource.

WBOY
Release: 2016-08-04 09:18:58
Original
1675 people have browsed it

<code>$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();
</code>
Copy after login
Copy after login

Error report:

<code>Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Warning: mysql_close(): no MySQL-Link resource supplied
</code>
Copy after login
Copy after login

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

Reply content:

<code>$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();
</code>
Copy after login
Copy after login

Error report:

<code>Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Warning: mysql_close(): no MySQL-Link resource supplied
</code>
Copy after login
Copy after login

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

Because you wrote the wrong letters...
The first variable is $connect
The second variable is $connnect
There is an extra n, okay?
Of course, use mysqli_query instead of mysql_query

mysql_query -> mysqli_query
mysql_num_rows -> mysqli_num_rows
mysql_close -> mysqli_close

Brother, the connection you create with mysqli_connect must be used with mysqli_xxx
mysqli_xxx and mysql_xxx cannot be mixed

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!