title: Error connecting to MSSQL server using PHP
body: <p>I am getting an error when trying to connect to my database using PHP.  If anybody wouldn't mind taking a look at it for me it would be greatly appreciated! (Need a different set of eyes lol).</p>
  
  <p>Here is the error I'm getting:</p>
  
  <pre><code>Warning: mssql_query() [function.mssql-query]: Unable to connect to server: (null) in H:\root\home\... on line 24
  
  Warning: mssql_query() [function.mssql-query]: A link to the server could not be established in H:\root\home\... on line 24
  
  Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in H:\root\home\... on line 25
  
  Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near ','. (severity 15) in H:\root\home\... on line 35
  
  Warning: mssql_query() [function.mssql-query]: Query failed in H:\root\home\... on line 35
  </code></pre>
  
  <p>Here is the PHP file:</p>
  
  <pre><code>&lt;?php
      $hostname_localhost ="********";
      $database_localhost ="*****";
      $username_localhost ="******";
      $password_localhost ="*****";
  
      $table_name = "VehicleInformation";
      //$phone = $_REQUEST['Phone'];
      //$rpm = $_REQUEST['RPM'];
      //$fuelLevel = $_REQUEST['FuelLevel'];
      //$engineRunTime = $_REQUEST['EngineRunTime'];
      //$speed = $_REQUEST['Speed'];
      //$troubleCode = $_REQUEST['TroubleCodes'];
      //$oilPressure = "0";
          $phone = "2125559852";
          $rpm = "1000";
          $fuelLevel = "20";
          $engineRunTime = "200";
          $speed = "25";
          $oilPressure = "420";
  
  
      $ownedByQuery = "Select o.Id from OwnedBy o JOIN tblUser u ON o.UserId = u.ID where u.Phone = '$phone'";
          $sql2 = mssql_query($ownedByQuery);
          $row = mssql_fetch_array($sql2);
  
      $query = "INSERT INTO $table_name (OwnedById,RPM,FuelLevel,OilPressure,EngineRunTime,Speed) VALUES ($row[0],$rpm,$fuelLevel,$oilPressure,$engineRunTime,$speed)";
  
      $server = mssql_connect($hostname_localhost,$username_localhost,$password_localhost)
      or
      die('MSSQL Error: ' . mssql_get_last_message());
  
      mssql_select_db("*******", $server);
      //$sql2 = mssql_query($ownedByQuery);
      $sql=mssql_query($query);
  
      //$row = mssql_fetch_array($sql2);
          //$row = mssql_fetch_array($sql);
  
      //echo $row[0];
  
  
  ?&gt;
  </code></pre>