为什么脚本在php中用此代码返回Error? [英] Why script returning Error with this code in php?

查看:69
本文介绍了为什么脚本在php中用此代码返回Error?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用sqlsrv将文件名转换为二进制数据类型,并将其保存在mysql数据库中,但是我收到此错误:

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:

致命错误调用未定义函数sqlsrv-connect

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

我的PHP代码是:

$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";
}

推荐答案

您声明尝试插入mysql-但正在使用sqlsrv_query这是针对MS Sql Server的,请尝试 http://php.net/manual/zh-/mysqli.query.php

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

这篇关于为什么脚本在php中用此代码返回Error?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆