-2

I am trying to convert a file name into a binary data type by using sqlsrv and save it in a mysql database but I receive this error:

fatal-error-call-to-undefined-function-sqlsrv-connect

My PHP code is:

$conn=mysqli_connect("localhost","root","","musiccloud");

if(!empty($_FILES['file'])){
  $ext = pathinfo($_FILES['file']['name'],PATHINFO_EXTENSION);
  $image =$ext;
  Echo"File Copied Successfully";
  sqlsrv_query($conn, 'INSERT INTO musiclist(name) VALUES (?)', array(
    array($ext, SQLSRV_PARAM_IN, SQLSRV_PHPTYPE_STRING, 
          SQLSRV_SQLTYPE_BINARY)
  ));

  echo "successfully uploaded";
}
moopet
  • 6,014
  • 1
  • 29
  • 36
Eddy
  • 361
  • 2
  • 4
  • 12

2 Answers2

1

You state that your trying to insert to mysql - but are using sqlsrv_query this is for MS Sql Server try http://php.net/manual/en/mysqli.query.php

Shaun Hare
  • 3,771
  • 2
  • 24
  • 36
0

you used mysqli driver to connect to your DB that can only connect to MySQL/MariaDB.

if you are using SQL Server then you have to use PDO or sqlsrv_connect in your case.

Mohammad Salehi
  • 565
  • 1
  • 12
  • 33