The following figure shows how to connect to the MSSQL Server database code. & Lt ;? Php $ myServer & quot; localhost & quot; $ myUser & quot; your_name & quot; $ myPass & quot; your_password & quot; $ myDB & quot; examples & quot; how does co connect to ms SQL Server?
The following code is used to connect to the database of the MSSQL Server.
$ MyServer = "localhost ";
$ MyUser = "your_name ";
$ MyPass = "your_password ";
$ MyDB = "examples ";
// Connection to the database
$ Dbhandle = mssql_connect ($ myServer, $ myUser, $ myPass)
Or die ("Couldn't connect to SQL Server on $ myServer ");
// Select a database to work
$ Selected = mssql_select_db ($ myDB, $ dbhandle)
Or die ("Couldn't open database $ myDB ");
// Declare the SQL statement that will query the database
$ Query = "SELECT id, name, year ";
$ Query. = "FROM cars ";
$ Query. = "WHERE name = 'bmw '";
// Execute the SQL query and return records
$ Result = mssql_query ($ query );
$ NumRows = mssql_num_rows ($ result );
Echo "". $ numRows. "Row". ($ numRows = 1? "": "S"). "Returned
";
// Display the results
While ($ row = mssql_fetch_array ($ result ))
{
Echo"
". $ Row [" id "]. $ row [" name "]. $ row [" year "]."";
}
// Close the connection
Mssql_close ($ dbhandle );
?>
DSN claims 'data source name '. This is a simple way to allocate and easily rememberable useful data.
The source name may not be limited to a separate database. If you do not know how to establish a system DSN, read our
This document describes how to create a system DSN.
In the following example, we will show you how to use an MSSQL Server database DSN to connect
Examples. mdb and retrieve the 'chelan' in all the record tables '.
// Connect to a DSN "myDSN"
$ Conn = odbc_connect ('mydsn ','','');
If ($ conn)
{
// The SQL statement that will query the database
$ Query = "select * from cars ";
// Perform the query
$ Result = odbc_exec ($ conn, $ query );
Echo"
// Print field name
$ ColName = odbc_num_fields ($ result );
For ($ j = 1; $ j <= $ colName; $ j ++)
{
Echo"
// Fetch tha data from the database
While (odbc_fetch_row ($ result ))
{
Echo"
Echo" ";
Echo"
";
"; Echo odbc_field_name ($ result, $ j ); Echo" | ";}
";For ($ I = 1; $ I <= odbc_num_fields ($ result); $ I ++){Echo"
"; Echo odbc_result ($ result, $ I ); Echo" | ";}Echo"
";}
";
// Close the connection
Odbc_close ($ conn );
}
Else echo "odbc not connected ";
?>
======================================
How php converts a PDF file to a txt text file
Document Format (PDF) is a file exchange created in file format. Each PDF file encapsulates a fixed Layout
Complete description of 2D files (and, with Acrobat 3D software, embedded 3D files), including text, words
Body, image, and two-dimensional vector graphics.
Function 00002text ($ filename ){
// Read the data from pdf file
$ Infile = @ file_get_contents ($ filename, FILE_BINARY );
If (empty ($ infile ))
Return "";
// Get all text data.
$ Transformations = array ();
$ Texts = array ();
// Get the list of all objects.
Preg_match_all ("# obj (. *) endobj # ismU", $ infile, $ objects );
$ Objects = @ $ objects [1];
// Select objects with streams.
For ($ I = 0; $ I <count ($ objects); $ I ++ ){
$ CurrentObject = $ objects [$ I];
// Check if an object has des data stream.
If (preg_match ("# stream (. *) endstream # ismU", $ currentObject,
$ Stream )){
$ Stream = ltrim ($ stream [1]);
// Check object parameters and look for text data.
$ Options = getObjectOptions ($ currentObject );
If (! (Empty ($ options ["Length1"]) & empty ($ options ["Type"]) &
Empty ($ options ["Subtype"])
Continue;
// So, we have text data. Decode it.
$ Data = getDecodedStream ($ stream, $ options );
If (strlen ($ data )){
If (preg_match_all ("# BT (. *) ET # ismU", $ data,
$ TextContainers )){
$ TextContainers = @ $ textContainers [1];
GetDirtyTexts ($ texts, $ textContainers );
} Else
GetCharTransformations ($ transformations, $ data );
}
}
}
// Analyze text blocks taking into account character transformations
And return results.
Return getTextUsingTransformations ($ texts, $ transformations );
}