PHP和数据库SQL2000的问题
如何用PHP链接数据库SQL2000并读取数据。比如实现下面程序:PHP中有数组$ARRAY要读取SQL2000中表:速度;列:X轴;时间:30---60将值存入$ARR...
如何用PHP链接数据库SQL2000并读取数据。
比如实现下面程序:
PHP中有数组$ARRAY
要读取SQL2000中表:速度; 列:X轴;时间:30---60
将值存入$ARRAY中
如何实现。 展开
比如实现下面程序:
PHP中有数组$ARRAY
要读取SQL2000中表:速度; 列:X轴;时间:30---60
将值存入$ARRAY中
如何实现。 展开
1个回答
展开全部
resource mssql_connect ([ string $servername [, string $username [, string $password [, bool $new_link ]]]] )
<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'KALLESPC\SQLEXPRESS';
$link = mssql_connect($server, 'sa', 'phpfi');
if(!$link)
{
die('Something went wrong while connecting to MSSQL');
}
?>
///////////////////////////////////////////////////////////
mixed mssql_query ( string $query [, resource $link_identifier [, int $batch_size= 0 ]] )
<?php
// Connect to MSSQL
$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi');
if(!$link || !mssql_select_db('php', $link))
{
die('Unable to connect or select database!');
}
// Do a simple query, select the version of
// MSSQL and print it.
$version = mssql_query('SELECT @@VERSION');
$row = mssql_fetch_array($version);
echo $row[0];
// Clean up
mssql_free_result($version);
?>
//////////////////////////////////////////////////////////
array mssql_fetch_array ( resource $result [, int $result_type= MSSQL_BOTH ] )
result
The result resource that is being evaluated. This result comes from a call to mssql_query().
<?php
// Send a select query to MSSQL
$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]');
// Check if there were any records
if(!mssql_num_rows($query))
{
echo 'No records found';
}
else
{
// The following is equal to the code below:
//
// while($row = mssql_fetch_row($query))
while($row = mssql_fetch_array($query, MSSQL_NUM))
{
// ...
}
}
// Free the query result
mssql_free_result($query);
?>
<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'KALLESPC\SQLEXPRESS';
$link = mssql_connect($server, 'sa', 'phpfi');
if(!$link)
{
die('Something went wrong while connecting to MSSQL');
}
?>
///////////////////////////////////////////////////////////
mixed mssql_query ( string $query [, resource $link_identifier [, int $batch_size= 0 ]] )
<?php
// Connect to MSSQL
$link = mssql_connect('KALLESPC\SQLEXPRESS', 'sa', 'phpfi');
if(!$link || !mssql_select_db('php', $link))
{
die('Unable to connect or select database!');
}
// Do a simple query, select the version of
// MSSQL and print it.
$version = mssql_query('SELECT @@VERSION');
$row = mssql_fetch_array($version);
echo $row[0];
// Clean up
mssql_free_result($version);
?>
//////////////////////////////////////////////////////////
array mssql_fetch_array ( resource $result [, int $result_type= MSSQL_BOTH ] )
result
The result resource that is being evaluated. This result comes from a call to mssql_query().
<?php
// Send a select query to MSSQL
$query = mssql_query('SELECT [username], [name] FROM [php].[dbo].[userlist]');
// Check if there were any records
if(!mssql_num_rows($query))
{
echo 'No records found';
}
else
{
// The following is equal to the code below:
//
// while($row = mssql_fetch_row($query))
while($row = mssql_fetch_array($query, MSSQL_NUM))
{
// ...
}
}
// Free the query result
mssql_free_result($query);
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询