0

I am able to do in mysql which i pasted below. how to change into ms sql server DB. Please guide me because I am new in MS SQL server DB.

 *<?php
    $msg = '';
    if($_SERVER['REQUEST_METHOD']=='POST'){
        $image = $_FILES['image']['tmp_name'];
        $img = file_get_contents($image);
        $con = mysqli_connect('localhost','root','','mysqldb') or die('Unable To connect');
        $sql = "insert into images (image) values(?)";

        $stmt = mysqli_prepare($con,$sql);

        mysqli_stmt_bind_param($stmt, "s",$img);
        mysqli_stmt_execute($stmt);

        $check = mysqli_stmt_affected_rows($stmt);
        if($check==1){
            $msg = 'Successfullly UPloaded';
        }else{
            $msg = 'Could not upload';
        }
        mysqli_close($con);
    }
    ?>
    <form action="index.php" method="post" enctype="multipart/form-data">
        <input type="file" name="image" />
        <button>Upload</button>
    </form>
    <?php
        echo $msg;
    ?>*
rohit_g
  • 11
  • 2
  • 9

1 Answers1

0

In ms sql query execute like below Example :

$query = "insert into images (image) values(?)";
$result = sqlsrv_query($conn, $query);
if($result)
{
    echo "active";
}
else
{
    die( print_r( sqlsrv_errors(), true));
}

This is just example not your actual try above syntex.

Insert Data into MSSQL DB using PHP

Community
  • 1
  • 1
Sujal Patel
  • 2,444
  • 1
  • 19
  • 38