-3

I need to develop a php code to create a double level array. When I run the file this error appears:

Parse error: syntax error, unexpected ';' in C:\inetpub\wwwroot\file.php on line 20

I think that my error is a typo or some sentence bad closing but I can't find it.

<?php
$serverName = "serverName\SQLEXPRESS";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"user", "PWD"=>"pass");
$conn = sqlsrv_connect( $serverName, $connectionInfo);


if( $conn === false ) {                                  
    die( print_r( sqlsrv_errors(), true));
}

$sql = "SELECT * FROM table1";
$stmt = sqlsrv_query( $conn, $sql);
if ($stmt === false) {
    die( print_r( sqlsrv_errors(), true) );
}

$bbs = array();
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC){
    $bbs = array_merge($bbs, array_values($row));
}

print_r($bbs);

?>
Tilan04
  • 86
  • 1
  • 7

3 Answers3

1

You forgot to close the ) in line 20:

<?php

$serverName = "serverName\SQLEXPRESS";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"user", "PWD"=>"pass");
$conn = sqlsrv_connect($serverName, $connectionInfo);


if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
}

$sql = "SELECT * FROM table1";
$stmt = sqlsrv_query($conn, $sql);
if ($stmt === false) {
    die(print_r(sqlsrv_errors(), true));
}

$bbs = array();
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) {
    $bbs = array_merge($bbs, array_values($row));
}

print_r($bbs);
Ravi Sachaniya
  • 1,641
  • 18
  • 20
  • Thank you very much, it works perfectly. In spite of being something so small and simple had not been able to see it. – Tilan04 Jun 30 '17 at 07:10
0
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC){

You are missing a close parenthesis, you have two ( but only one )

paullb
  • 4,293
  • 6
  • 37
  • 65
0
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC){

You miss the final parenthesis, to close the while

Ryosaku
  • 453
  • 4
  • 14