My current connection and echo code is as follwed:

 <?php
            $myServer = "Server_Name";
            $myUser = "User";
            $myPass = "Pass";
            $myDB = "DB_Name"; 

        //connection to the database
            $dbhandle = sqlsrv_connect($myServer, $myUser, $myPass)
                or die("Couldn't connect to SQL Server on $myServer"); 

        //select a database to work with
            $selected = mssql_select_db($myDB, $dbhandle)
                or die("Couldn't open database $myDB"); 

        //declare the SQL statement that will query the database
            $query = "SELECT col1, col3, col4, col5, col6,  ";
            $query .= "FROM dbo.Quotes ";

        //execute the SQL query and return records
            $result = mssql_query($query)
                or die('A error occured: ' . mysql_error());

        //Show results in table

        $o = '<table id="myTable">
                <thead>
                <tr>
                <th>Col 1</th>
                <th>Col 2</th>
                <th>Col 2</th>
                <th>Col 2</th>
                <th>Col 2</th>

                </tr>
                </thead><tbody>';

               while ( $record = mssql_fetch_array($result) )
         {
             $o .= '<tr><td>'.$record ['col1'].'</td><td>'.$record ['col3'].'</td></tr>' .$record ['col4'].'</td></tr>' .$record ['col5'].'</td></tr>' .$record ['col6'].'</td></tr>';
         } 




        //free result set memory
            mssql_free_result($result);

        //close the connection
            mssql_close($dbhandle);
        ?>

My current connection and echo code is as follwed

And what is the question?

I seem to through errors when I launch the code It doesn't go into the table it should and instead looks like this on the webpage:

Col 1 Col 2 Col 2 Col 2 Col 2 '; while ( $record = mssql_fetch_array($result) ) { $o .= ''.$record ['col1'].''.$record ['col3'].'' .$record ['col4'].'' .$record ['col5'].'' .$record ['col6'].''; } //free result set memory mssql_free_result($result); //close the connection mssql_close($dbhandle); ?>

On line 16 remove the comma at the end (after col6). Although that should end the code on line 20 with an error instead of rendering what you are showing.

Although that should end the code on line 20 with an error instead of rendering what you are showing.

Its still showing the same message, with updated code:

   <?php
                $myServer = "Server_Name";
                $myUser = "User";
                $myPass = "PassWord";
                $myDB = "Db_Name"; 

            //connection to the database
                $dbhandle = sqlsrv_connect($myServer, $myUser, $myPass)
                    or die("Couldn't connect to SQL Server on $myServer"); 

            //select a database to work with
                $selected = mssql_select_db($myDB, $dbhandle)
                    or die("Couldn't open database $myDB"); 

            //declare the SQL statement that will query the database
                $query = "SELECT col1, col3, col4, col5, col6  ";
                $query .= "FROM dbo.Quotes ";

            //execute the SQL query and return records
                $result = mssql_query($query)
                    or die('A error occured: ' . mysql_error());

            //Show results in table

            $o = '<table id="myTable">
                    <thead>
                    <tr>
                    <th>Col 1</th>
                    <th>Col 2</th>
                    <th>Col 2</th>
                    <th>Col 2</th>
                    <th>Col 2</th>

                    </tr>
                    </thead><tbody>';

                   while ( $record = mssql_fetch_array($result) )
             {
                 $o .= '<tr><td>'.$record ['col1'].'</td><td>'.$record ['col3'].'</td></tr>' .$record ['col4'].'</td></tr>' .$record ['col5'].'</td></tr>' .$record ['col6'].'</td></tr>';
             } 




            //free result set memory
                mssql_free_result($result);

            //close the connection
                mssql_close($dbhandle);
            ?>

UPDATE It now doesn't display anything, no errors no code!

Plus it doesn't display a table or anything the page returns blank.

Any Ideas???

Shouldn't you be using mssql_connect instead ?

Be a part of the DaniWeb community

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