2

I want store html input data store sql server database using php, just may know give it your solution Ignore as possible here is the code ...

    <?php
    $serverName = 'SRB-Nick_Desktop\SQLEXPRESS';
    $connectionInfo = array('Database'=>'cslogs', 'UID'=>'cslogslogin', 
   'PWD'=>'123456');
    $connection = sqlsrv_connect($serverName, $connectionInfo);
   if( $connection === false )
   {
    echo "Connection could not be established.\n";
   die( print_r( sqlsrv_errors(), true));
    }
   $tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num, 
   num_payments,   ach_cc, date, notes) VALUES (?,?,?,?,?,?,?,?)";
   $parameters = array( "forteid", "LOC", "NCXXXXXXX4", "SRB-000004", "0", 
   "cc", "2012-11-01", "gave LOC instructions");
  $stmt = sqlsrv_query($connection, $tsql, $parameters);
   if( $stmt === false ){
  echo "Statement could not be executed.\n";
  die( print_r( sqlsrv_errors(), true));
  } 
else
{
echo "Rows affected: ".sqlsrv_rows_affected( $stmt )."\n";
}
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $connection);
?>
mickmackusa
  • 43,625
  • 12
  • 83
  • 136
  • Sorry, but it is completely unclear what you actually ask. Please take time to revise your question (there is an `edit` link below it...) and tell more details about your situation and about what it is you actually want to do. – arkascha Apr 10 '17 at 07:01
  • @KalithasanGovindarajan You must explain what is wrong in your question. If you do not edit your question soon it will likely be downvoted by many users and/or closed. – mickmackusa Apr 10 '17 at 07:19
  • @KalithasanGovindarajan This entire page is worth a read: http://stackoverflow.com/a/36899361/2943403 – mickmackusa Apr 10 '17 at 07:26
  • hey dude, I Changed in My Unclear Mistake now, I want store html form data into mssql database not mysql using php – Kalithasan Govindarajan Apr 10 '17 at 07:27
  • Dude, please tell us what exactly is not working with your code. – mickmackusa Apr 10 '17 at 07:28
  • I have exist db connection problem! – Kalithasan Govindarajan Apr 10 '17 at 07:33
  • @KalithasanGovindarajan Your credentials must be wrong because your code looks just like the the manual. http://php.net/manual/en/function.sqlsrv-connect.php I don't think there is a lot we can do for you. Only the case-sensitivity is the only difference. – mickmackusa Apr 10 '17 at 07:40

1 Answers1

-5

Really not clear on what you are asking but here is the normal procedure.

    <?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = sqlsrv_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . sqlsrv_errors());
}

$sql = "INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";

if (sqlsrv_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . sqlsrv_errors($conn);
}

sqlsrv_close($conn);
?>

Check out php documentation for further reference. http://php.net/manual/en/book.sqlsrv.php

Vihanga Bandara
  • 363
  • 2
  • 14
  • 1
    Really? That doesn't look like the manual. Did this actually fix the issue? The manual needs to be updated, I reckon. – mickmackusa Apr 10 '17 at 07:48
  • That's not correct at all... sqlsrv_connect only takes too parameters. This is very misleading – A Friend Apr 09 '18 at 15:02