Home > Article > Backend Development > mysqli_connect does not report an error, but subsequent operations show not a valid MySQL-Link resource.
<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>
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>
There is no problem using the object-oriented method
What is the problem?
<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>
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>
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