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;
    ?>*

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.