Jump to content


Calling mysql store procedure to enter information from a form using PHP.

  • Please log in to reply
No replies to this topic

#1 nikkicade

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 15 August 2006 - 09:01 PM


I am new to this but have a database with a stored procedure to add a new product to the database. I have a form in which the user enters the new product information and click a submit button. The submit button then opens a new php page which calls the store procedure. I know everything is working as it should because the users have to login in order to get to the page with the form to add the new product. The form works fine and I can define the variables from the form and echo them out to the page called from the submit button using $ProductName = $_POST['ProductCode']; and echo $ProductName;. The problem I have is binding the parameters for the stored procedure. Does anyone know the correct method of binding the parameters to use with $query? Is it that I have to prepare, bind_param and execute? I have found the syntax for mysqli and have tried this

$stmt = $mysqli->prepare("call usp_NewProduct(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

$stmt->bind_param('ssssssssissdi', $ProductName, $ProductSubCategory, $ProductSubCategory2, $ProductSubCategory3, $ProductDesign, $ProductColour, $ProductSize, $ProductFragrance, $DeliveryBand, $ProductCode, $ProductDescription, $ProductPrice, $StockLevel);

$ProductName = $_POST['ProductName'];
$ProductSubCategory = $_POST['ProductSubCategory'];
$ProductSubCategory2 = $_POST['ProductSubCategory2'];
$ProductSubCategory3 = $_POST['ProductSubCategory3'];
$ProductDesign = $_POST['ProductDesign'];
$ProductColour = $_POST['ProductColour'];
$ProductSize = $_POST['ProductSize'];
$ProductFragrance = $_POST['ProductFragrance'];
$DeliveryBand = $_POST['DeliveryBand'];
$ProductCode = $_POST['ProductCode'];
$ProductDescription = $_POST['ProductDescription'];
$ProductPrice = $_POST['ProductPrice'];
$StockLevel = $_POST['StockLevel'];

/* execute prepared statement */

/* close statement and connection */

but cannot get it to work.

Any help would be gratefully received.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users