<?php
$mysqli=mysqli_connect('localhost','root','123','test');
if(mysqli_connect_errno()){
printf("Connect failed:%s\n",mysqli_connect_error());
exit();
}
else
{
$sql="CREATE TABLE testTable(
id int not null primary key auto_increment,
testField varchar(20)
)";
$res=mysql_query($mysql,$sql); //I wrote $mysqli as $mysql, so it doesn't operate on the specified database.
var_dump($res);
echo "<br/>";
if($res===true){
echo "Table testTable successfully created.";
}
else{
printf("Could not create table:%s\n",mysqli_error($mysqli));
}
mysqli_close($mysqli);
}
?>
Output result: (mysqli_error() returns no error message)
The first argument to mysqli_query() should be $mysqli, but I wrote $mysql, which doesn’t exist. So mysqli_query() doesn’t actually find it
Specified database, so no table build operation is performed. So mysqli_error() does not return a value.
Since my VIM configuration is not complete, this error should be detectable by IDE syntax correction.
So an operation error to the database, and mysqli_error() does not return a value, could be a parameter error passed to mysqli_query().
Mysqli_error () returns an error from the last database operation. If the first parameter was written incorrectly, no operation was performed to the specified database
Error message.
Read More:
- Mysqli::stmt Fatal error: Call to a member function bind_param() on a non-object in …
- [Solved] mysqli::__construct(): Server sent charset (255) unknown to the client. Please, report to the developers in
- MySQL 8.0 error 1114 (HY000): the table’sbtest1’is full (Fixed)
- ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’ (Fixed)
- Error 1406 (22001) in MySQL: data too long for column (Fixed)
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- Error 1418 (HY000): this function has none of deterministic, no SQL
- [SQL ERROR] SQL Error: could not execute statement & query did not return a unique result: 2; nested excepti
- [Solved] Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as
- [Solved] ORA-04063: package body “SYS.DBMS_DATAPUMP“ has errors
- General error: 2006 MySQL server has gone away [How to Solve]
- Linux Error: [ERROR] –initialize specified but the data directory has files in it. Aborting.
- MySQL server has gone away Error [How to Solve]
- [Solved] Description: Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded
- Zabbix import MySQL database error ERROR 1046 (3D000) at line 1: No database selected
- [Solved] Pyodbc.ProgrammingError: No results. Previous SQL was not a query.
- How to Solve MYSQL Error: No module named MySQLdb
- C# System.Data.SQLite.SQLiteException:“SQL logic error or missing database no such table: XX”
- mysql workbench Error Code: 1046. No database selected Select the default DB to be used by doubl
- MySQL Error: Error writing file ‘/tmp/MY4WYVlC‘ (Errcode: 28 – No space left on device)