i struggled with sqlsrv_connect for some time, first i had to get native client 2008 to get it to work, 2005 was not enough.
then i got som note that dll was compiled with wrong version, so i had to use test version 1.1 istead of 1.0 of the client and pick the version called php_sqlsrv_53_ts_vc6.dll
but still no success with connect.
finally i spent 7 hours testing things before i found out:
$serverName = "(local)"; ERROR for me
$serverName = "localhost\myinstansofdatabase"; //WOHOOOO
Microsoft SQL Server
- Introdução
- Instalação/Configuração
- Constantes pré-definidas
- Funções para Mssql
- mssql_bind — Adiciona um parâmetro a um stored procedure ou a um remote stored procedure
- mssql_close — Fecha a conexão com o servidor MS SQL
- mssql_connect — Abre uma conexão com o servidor MS SQL
- mssql_data_seek — Move o ponteiro interno da linha
- mssql_execute — Executa uma stored procedure num banco de dados de um servidor MS SQL
- mssql_fetch_array — Retorna uma linha como uma matriz associativa, matriz numérica ou ambas
- mssql_fetch_assoc — Retorna um array associativo da linha atual no resultado
- mssql_fetch_batch — Retorna o próximo lote de registros
- mssql_fetch_field — Retorna informação sobre o campo
- mssql_fetch_object — Devolve a linha como um objeto
- mssql_fetch_row — Retorna uma matriz enumerada
- mssql_field_length — Retorna o tamanho de um campo
- mssql_field_name — Retorna o nome de um campo
- mssql_field_seek — Estabelece o índice do campo
- mssql_field_type — Retorna o tipo de um campo
- mssql_free_result — Limpa o resultado da memória
- mssql_free_statement — Libera comando da memória
- mssql_get_last_message — Retorna a ultima mensagem do servidor
- mssql_guid_string — Converte um 16 byte binary GUID para uma string
- mssql_init — Inicializa um stored procedure ou um remote stored procedure
- mssql_min_error_severity — Estabelece a menor severidade a erros
- mssql_min_message_severity — Estabelece a menor severidade a mensagens
- mssql_next_result — Move o ponteiro interno do resultado para o próximo resultado
- mssql_num_fields — Retorna o número de campos em um resultado
- mssql_num_rows — Retorna o número de linhas em um resultado
- mssql_pconnect — Abre uma conexão persistente com MS SQL
- mssql_query — Envia uma query ao MS SQL
- mssql_result — Retorna dados do resultado
- mssql_rows_affected — Retorna o número de registros afetados pela query
- mssql_select_db — Seleciona um banco de dados do MS SQL
Mssql
tummen at jgd dot se
05-Sep-2009 10:28
05-Sep-2009 10:28
michal dot kocarek at brainbox dot cz
19-Aug-2009 09:05
19-Aug-2009 09:05
Microsoft has issued in nearly past Native SQL driver for PHP.
This driver works with MSSQL 2000, 2005 and 2008 servers. Driver is issued as PHP extension. Source codes also available.
The driver supports native conversion to UTF-8, scrollable cursors and other features which this (old) library does not.
For more information and extension download please see
http://www.codeplex.com/SQLSRVPHP
They have also blog on http://blogs.msdn.com/sqlphp/
ccsalway at yahoo dot co dot uk
15-Aug-2009 07:02
15-Aug-2009 07:02
Im running PHP 5.3 and used the php development ini and when I use the Microsoft SQL for PHP driver, I get the following error:
[15-Aug-2009 07:48:13] PHP Warning: PHP Startup: sqlsrv: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20090626
These options need to match
in Unknown on line 0
exidas at madnes dot eu
05-Aug-2009 07:43
05-Aug-2009 07:43
Hi, i was need some short and simple script to list all tables and columns of MSSQL database. There was nothing easy to explain on the net, so i've decided to share my short script, i hope it will help.
<?php
$all = MSSQL_Query("select TABLE_NAME, COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS order by TABLE_NAME, ORDINAL_POSITION");
$tables = array();
$columns = array();
while($fet_tbl = MSSQL_Fetch_Assoc($all)) { // PUSH ALL TABLES AND COLUMNS INTO THE ARRAY
$tables[] = $fet_tbl[TABLE_NAME];
$columns[] = $fet_tbl[COLUMN_NAME];
}
$sltml = array_count_values($tables); // HOW MANY COLUMNS ARE IN THE TABLE
foreach($sltml as $table_name => $id) {
echo "<h2>". $table_name ." (". $id .")</h2><ol>";
for($i = 0; $i <= $id-1; $i++) {
echo "<li>". $columns[$i] ."</li>";
}
echo"</ol>";
}
?>
hlex dot hlex at gmail dot com
27-Jun-2009 05:04
27-Jun-2009 05:04
if your sql server use ANSI encoding and your page use UTF-8, this is method to convert to UTF-8
<?php
function convertAnsi2UTF8($array){
foreach ($array as $key=>$item) {
if(is_array($item)) $array[$key]=convertAnti2UTF8($item);
else $array[$key]=iconv("TIS-620","UTF-8",$item);
}
return $array;
}
?>
opc dot three at gmail dot com
02-Jun-2009 03:50
02-Jun-2009 03:50
After extensive research trying to get PHP on Linux communicating with SQL Server 2005 and 2008 including support for all Unicode, MAX and XML data types I could not find any open source solutions...yes, I spent a lot of time trying to get FreeTDS to work to no avail.
I found one free solution that runs on Windows which is to use the "SQL Server Driver for PHP" provided by Microsoft (http://sql2k5php.codeplex.com). The driver relies on the Microsoft Native Client ODBC drivers for SQL Server 2008 (part of the "Microsoft SQL Server 2008 Native Client" which is downloadable from Microsoft) which is why this solution will not work on anything except Windows.
I did find a solution that works for PHP on Linux but it's not free...use the standard PHP::ODBC lib (free) and the Easysoft ODBC driver for SQL Server (not free, but reasonable by Enterprise standards). You can check out the ODBC driver by going here http://www.easysoft.com/products/data_access and looking for "Easysoft ODBC-SQL Server Driver"
thanhha dot phan at yahoo dot com
04-May-2009 02:03
04-May-2009 02:03
I got a serious problem with Unicode data when working with PHP and MSSQL. I have to say the PHP and MSSQL doesn't seem to be a good combination.
MSSQL is really complicated to work with since the whole server uses a single character encoding[ucs-2]. In order to store unicode information, the column data types must be specified as one of the national character types, NVARCHAR, NCHAR or NTEXT.
In order to retrieve data saved in unicode format, M$ suggest users to cast columns to binary data.Unfortunately php_mssql extension doesn't support binary data to be returned in string columns.
My advice is to use FreeTDS driver [it's just an php extension]. This driver seems to handle unicode data better. I can put and receive unicode with casting or change encoding.
A good tutorial "Using freeTDS" can be found here
http://docs.moodle.org/en/Installing_MSSQL_for_PHP
However, freeTDS is not a perfect solution for unicode data. I'm not able to execute stored procedures with mssql_bind, mssql_bind without having my text changed.
AA
11-Mar-2009 08:26
11-Mar-2009 08:26
On windows, do not use this for mssql 2005 of later. The methods of access are deprecated.
Use the Microsoft SQL Server 2005 Driver for PHP instead.
Current link is.
http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx
