duanmei1850
2017-02-14 11:08IONIC:从MYSQL到MSSQL
Am creating an ionic application using php, at the beginning I've linked the login form with a mysql database that I've created using wamp as a server and everything works fine! then my boss saids that I have to change it to another database which is on a Microsoft sql server, so I've linked the wamp server with MsSQL and the Connection with database on MSSQl established correctly
but I didn't know how to change the syntaxe on login.php
Here are the old and new cofig.php that works fine
(New config.php)
<?php
$serverName = "HAMDI-PC";
$connectionInfo = array ("Database"=>"MAINT","UID"=>"sa","PWD"=>"sql") ;
$conn = sqlsrv_connect( $serverName, $connectionInfo);
?>
(OLD config.php)
<?php
$conn = new mysqli("localhost", "root", "", "MAINT");
?>
And here is the (login.php) that works with mysql database
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
if(isset($_GET["username"]) && isset($_GET["password"]) ) {
if( !empty($_GET["username"]) && !($_GET["password"]) ) {
include"config.php";
$username=$_GET["username"];
$password=$_GET["password"];
$query=" SELECT * FROM D_PROTUSERS WHERE PROT_User='$username' AND PROT_Password ='$password' ";
$result = $conn->query($query);
$out="";
if ($rs=$result->fetch_array()) {
if($out != "") {$out .="";}
$out .='{"PROT_User":"'. $rs["PROT_User"] . '",';
$out .='"PROT_Password":"'. $rs["PROT_Password"] . '"}';
}
$out='{"recods":'.$out.'}';
$conn->close();
echo($out);
}
}
?>
So please I want to know what should I change to make it work at the new database'MSSQl) , I'll be thankful to everyone who will tries to help :*
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 如何将我的离子应用程序与MySQL数据库连接?
- rest
- ionic
- mysql
- php
- 2个回答
- Ionic + Ubuntu:连接到mysql / phpmyadmin
- angularjs
- ionic
- ubuntu
- php
- 1个回答
- IONIC:从MYSQL到MSSQL
- mysql
- php
- 1个回答
- 将AngularJs连接到本地服务器php MySQL
- angularjs
- mysql
- php
- 2个回答
- PHP SQL语法错误(没有线索为什么)[重复]
- mysql
- php
- 5个回答
换一换