Advertisement
Guest User

Untitled

a guest
Apr 10th, 2017
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2. $serverName = 'SRB-Nick_DesktopSQLEXPRESS';
  3. $connectionInfo = array('Database'=>'cslogs', 'UID'=>'cslogslogin',
  4. 'PWD'=>'123456');
  5. $connection = sqlsrv_connect($serverName, $connectionInfo);
  6. if( $connection === false )
  7. {
  8. echo "Connection could not be established.n";
  9. die( print_r( sqlsrv_errors(), true));
  10. }
  11. $tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num,
  12. num_payments, ach_cc, date, notes) VALUES (?,?,?,?,?,?,?,?)";
  13. $parameters = array( "forteid", "LOC", "NCXXXXXXX4", "SRB-000004", "0",
  14. "cc", "2012-11-01", "gave LOC instructions");
  15. $stmt = sqlsrv_query($connection, $tsql, $parameters);
  16. if( $stmt === false ){
  17. echo "Statement could not be executed.n";
  18. die( print_r( sqlsrv_errors(), true));
  19. }
  20. else
  21. {
  22. echo "Rows affected: ".sqlsrv_rows_affected( $stmt )."n";
  23. }
  24. sqlsrv_free_stmt( $stmt);
  25. sqlsrv_close( $connection);
  26. ?>
  27.  
  28. <?php
  29. $servername = "localhost";
  30. $username = "username";
  31. $password = "password";
  32. $dbname = "myDB";
  33.  
  34. // Create connection
  35. $conn = sqlsrv_connect($servername, $username, $password, $dbname);
  36. // Check connection
  37. if (!$conn) {
  38. die("Connection failed: " . sqlsrv_errors());
  39. }
  40.  
  41. $sql = "INSERT INTO MyGuests (firstname, lastname, email)
  42. VALUES ('John', 'Doe', 'john@example.com')";
  43.  
  44. if (sqlsrv_query($conn, $sql)) {
  45. echo "New record created successfully";
  46. } else {
  47. echo "Error: " . $sql . "<br>" . sqlsrv_errors($conn);
  48. }
  49.  
  50. sqlsrv_close($conn);
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement