Guest User

Untitled

a guest
Feb 13th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. //Prep the variables for insert
  2. $p1 = $_POST['description'];
  3. $p2 = intval($_POST['visible']);
  4. $p3 = strval($_POST['whoToShow']);
  5.  
  6. //Build an array with those variables
  7. $params = array(&$p1, &$p2, &$p3);
  8.  
  9. //Build the SQL
  10. $sql = "INSERT INTO notifications (description, visible, whoToShow) VALUES (?, ?, ?)";
  11.  
  12. //Execute the sql using a prepared statement, passing the variables in an array
  13. $stmt = sqlsrv_prepare($conn, $sql, $params) or die(FormatErrors(sqlsrv_errors()));
  14.  
  15. $myServer = "xxxxxxx";
  16. $myUser = "xxxxxxxx";
  17. $myPass = "xxxxxxx";
  18. $myDB = "myDatabase";
  19. //connection to the database
  20. $dbhandle = mssql_connect($myServer, $myUser, $myPass)
  21. or die("Couldn't connect to SQL Server on $myServer");
  22. //select a database to work with
  23. $selected = mssql_select_db($myDB, $dbhandle)
  24. or die("Couldn't open database $myDB");
  25.  
  26. $query = "exec eCommerce.dbo.cart_GET_Detail @sid = ".$_SESSION['sid']." , @cc = '".$_SESSION['cc']."'";
  27.  
  28. $result = mssql_query($query);
  29. $numRows = mssql_num_rows($result);
  30. $hasItems = (($numRows == 0) ? 'N' : 'Y');
  31.  
  32. while ($RSLoop = mssql_fetch_array($result)) {
  33. //var_dump($RSLoop); //var_dump will show you everything in the recordset
  34. echo '<tr><td colspan=6 width=720 class=cartDivider>&nbsp;</td></tr>';
  35. echo '<form name=frmProduct'.$idx.' method=POST action=_action.asp>';
  36. echo '<input type=hidden name=pid value="'.$RSLoop['product_id'].'">';
  37. }
Add Comment
Please, Sign In to add comment