I want to display Posts details in WordPress page. I have added MySQL query in WordPress page(All
Pages -> Add New Page --> Added the Code). I am using
INSERT PHP WordPress plugin for that.. Still it displays the error..
How to do this..? The Code which I have used is given below...
$sqli="select * from cre_term_relationships where term_taxonomy_id=1";
$res=mysqli_query($sqli) or die(mysqli_error());
Best How To :
There are a few problems with your code.
Firstly, you're not passing your DB connection parameter to the query.
^ missing the 1st parameter.
Modify it to read as:
mysqli_error() requires DB connection be passed as a parameter
However, WordPress has its own MySQL core functions. I don't know why you're using
remove the excess brackets and the order:
DB_USERNAME is a pre-defined constant that isn't showing in your question.
However, constants do not get wrapped in quotes:
$con=mysqli_connect("localhost", DB_USERNAME, DB_PW, DB_NAME);
if you have in fact defined your constants.
You will need to elaborate on this, and to update your question, should my answer not provide the solution.
Consult the following regarding the use of constants: