Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:52:17+00:00 2026-05-31T10:52:17+00:00

I am currently working on a clients web site and I ran into a

  • 0

I am currently working on a clients web site and I ran into a bit of a problem. I am using a log in system that was shown to me by a colleague that uses MySQL strings. I plugged the client’s info into it and loaded it and got a connection error. After combing through my code I found some errors but fixing them did not fix the connection issue. After digging around on the client’s web host I noticed that their database is hosted on a Microsoft SQL server instead of a MySQL server. Now here comes the questions:

1.) How do I change my MySQL strings into SQL Server strings?

2.) Can I still use PHP to manipulate the SQL Server strings?

3.) Are there any good tutorials that you guys recommend that will help me understand this better?


Reference

Here is the MySQL strings I’m using including the lines that are manipulated by PHP:

    // Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Define $myusername and $mypassword 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE user_name='$myusername' and user_pswd='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
    $_SESSION['myusername'];
    $_SESSION['mypassword']; 

    header("location:Inside.php");
} else {
    echo "Wrong Username or Password";
}

Any suggestions would be greatly appreciated. Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:52:19+00:00Added an answer on May 31, 2026 at 10:52 am

    Since the database is no longer MySQL, you will have to rewrite some of the code that uses MySQL functions. This is easily done with PDO (PHP Data Objects) and is far more portable for future changes.

    Look at this SQL Server example:

    <?php
    
       $user = 'myUsername';
       $pass = 'myPassword';
    
       // Connect to mssql database
       $conn = new PDO('mssql:host=127.0.0.1; dbname=tempdb;', $user, $pass);
    
       $query = "SELECT * FROM table1";
    
       // Prepare query and run it. This is where you can use prepared statements
       // to avoid SQL injection
       $sth = $conn->prepare($query);
       $sth->execute();
    
       // Fetch the returned db rows and dump them as output
       $retRows = $sth->fetchAll();
       var_dump($retRows);
    
       // Clean up resources
       unset($sth); unset($conn);
    
    ?>
    

    Anywhere you find a function like mysql_* in your code, you will want to lookup the proper way to do that using PDO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently am working a CSS navigation system on my client's website at http://cjcdigital.net/clients/andrea
I'm currently working on a web site which involves a data upload process. The
I am currently working on some prototypes for a web site I am wanting
I have a Wordpress site that I am currently working on and have set
I'm working on a clients pre-existing web site. I would like to take the
I am currently working on system that generated product recommendations like those on Amazon
I'm working on building a small web app connecting into the instagram API. Currently
I'm currently working on a small web application using Visual Studio 2008 Express. I'm
I'm currently working on a project that has a sizable amount of both client
I am working on an IMAP client using java mail. We currently have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.