Magic8Computing 0 Newbie Poster

The following code is erroring on the connection string line 5 it used to work but then i had to move the sql server to another box and now it fails have i forgotten to do something on the sql server or is there error in my code

my error is

Fatal error: Uncaught PDOException: SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53]. in C:\xampp\htdocs\dailysales\includes\CPeriodOrdersJson.php:5 Stack trace: #0 C:\xampp\htdocs\dailysales\includes\CPeriodOrdersJson.php(5): ->('sqlsrv:Server=F...', 'LocalAdmin', 'CrispyCrackers') #1 {main} thrown in C:\xampp\htdocs\dailysales\includes\CPeriodOrdersJson.php on line 5



$db = new PDO("sqlsrv:Server=FFP-X3DB\X3;Database=FFP_WebServices", "LocalAdmin", "CrispyCrackers");


$row->execute();//execute the query

//create the array
$json_data['cols'] = array(
  array('label' => 'Mon', 'type' => 'string'),
  array('label' => 'COrdersTP', 'type' => 'number'),
  array('label' => 'COrdersAP', 'type' => 'number')

$rows = array();
foreach($row as $rec)//foreach loop
  $temp = array();
  $temp[] = array('v' => (string) $rec['Mon']);
  $temp[] = array('v' => (float) $rec['COrdersTP']);
  If ((int)$rec['Per'] < ($CurrentPeriod)) {
    $temp[] = array('v' => (float) $rec['COrdersAP']);}
  Else {}   
  $rows[] = array('c' => $temp);
$json_data['rows'] = $rows;

//built in PHP function to encode the data in to JSON format
echo json_encode($json_data, JSON_NUMERIC_CHECK);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.