duanmei1850
duanmei1850
2017-02-14 11:08

IONIC:从MYSQL到MSSQL

  • php
  • mysql

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条回答

为你推荐

换一换