-1

I've got a MySQL database where I've setup a store procedure, I know the stored procedure works because I can execute it from the phpMyAdmin control panel.

I'm now trying to execute the procedure from my website, I get no errors but nothing is getting inserted into the various tables that I'm expecting. This is the code I'm running from my php page.

  $link = new mysqli($host_name, $user_name, $password, $database);
  if ($link->connect_error)
  {
    die('<p>Failed to connect to MySQL: '. $link->connect_error .'</p>');
  }
  else
  {
    $sp = $link->prepare("CALL sp_InsertNewSchematic(?, ?, ?, ?, ?, ?, ?)");
    $sp->bind_Param('ssissss', $imageFilename, $schematicFileName, $Creator, $youtube, $description, $tags, $versions);
    $sp->execute();
  }
Dharman
  • 30,962
  • 25
  • 85
  • 135
Ali Beasley
  • 77
  • 1
  • 2
  • 9
  • 1
    What is the return value from `execute()`? Is there any error? You always have to check for errors after every call to `prepare()` or `execute()`. Or alternatively, [enable mysqli exceptions](https://www.php.net/manual/en/mysqli-driver.report-mode.php). – Bill Karwin May 19 '21 at 21:03
  • thank you, didn't realise I needed to output the error specifically, I've adjusted my code and found that I'd forgot about an output param on my stored procedure. – Ali Beasley May 19 '21 at 21:10

1 Answers1

-1

Just figured it out, for anyone that has a similar issue

I changed the execute line to this;

if (!$sp->execute()){
  echo "Execute failed: (" . $sp->errno . ") " . $sp->error;
}

which output the error, turned out I'd forgot my stored procedure had an output variable and so the number of params didn't match the procedure, all working now.

Thank you for the reply Bill.

Ali Beasley
  • 77
  • 1
  • 2
  • 9