0
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Doctor";

$conn = new mysqli($servername, $username, $password, $dbname);

if($conn === false){
   die("ERROR: Could not connect. ". mysqli_connect_error());
 }

$new = "INSERT INTO wp_ea_appointments (name,phone,email,description)
 VALUES

 ('Rambo',54132, 'johnrambo@mail.com','hello')";

if(mysqli_query($conn, $new))
{
    echo "Records added successfully.";
 } else{
echo "ERROR: Could not able to execute $new";
 }

 mysqli_close($conn);

My Database Name is Doctor, My Table Name Is wp_ea_appointments, error message

ERROR: Could not able to execute INSERT INTO wp_ea_appointments (name,phone,email,description) VALUES ('Rambo',54132, 'johnrambo@mail.com','hello');

jarlh
  • 40,041
  • 8
  • 39
  • 58
  • The issue is not same as the duplicate question answer show.. Therefore I vote for a reopening. – bestprogrammerintheworld Apr 15 '20 at 06:54
  • @bestprogrammerintheworld the issue _is_ the same, in that the first thing should be done here, is to get a _proper_ error message from the database. (And I would vote to close nearly all of these questions as “go read up on these basics in a beginner’s tutorial” to begin with, if that was an option.) – CBroe Apr 15 '20 at 07:11
  • @Cbroe - the issue is not handling errors. IMO the issue is that he is mixing procedural and OOP-style mysqli. – bestprogrammerintheworld Apr 15 '20 at 07:23
  • this issue is not same as the duplicate question answer. my question is how i can insert my data into wordpress plugin table? – Rajendrasinh Rathod Apr 15 '20 at 09:01
  • @RajendrasinhRathod - try $conn = mysqli_connect($servername, $username, $password, $dbname); instead of $conn = new mysqli($servername, $username, $password, $dbname); – bestprogrammerintheworld Apr 15 '20 at 10:06
  • @bestprogrammerintheworld I also try this way but this is not working for me – Rajendrasinh Rathod Apr 15 '20 at 11:56

0 Answers0