谢谢!
可是我有的代码:
$result_rs="select * from wjb" ;
$conn_rs=odbc_connect($dns,$user,$password);
$result_id=odbc_do($conn_rs,$result_rs);
$i=0;
while(odbc_fetch_row($result_id))
{ $xh=odbc_result($result_id,1);
$cyhm=odbc_result($result_id,2);
$i++;
?>
<table>
<tr>
<td width="50%"><?php echo "$xh" ?></td>
<td width="50%"><a href="<?php echo "$cyhm" ?>"><?php echo "$cyhm" ?></a></td>
</tr>
</table><?php
}
可是我有的代码:
$result_rs="select * from wjb" ;
$conn_rs=odbc_connect($dns,$user,$password);
$result_id=odbc_do($conn_rs,$result_rs);
$i=0;
while(odbc_fetch_row($result_id))
{ $xh=odbc_result($result_id,1);
$cyhm=odbc_result($result_id,2);
$i++;
?>
<table>
<tr>
<td width="50%"><?php echo "$xh" ?></td>
<td width="50%"><a href="<?php echo "$cyhm" ?>"><?php echo "$cyhm" ?></a></td>
</tr>
</table><?php
}
$dns="***";
$user="****";
$password="****";
$result_rs="select * from wjb" ;
$conn_rs=odbc_connect($dns,$user,$password);
$result_id=odbc_do($conn_rs,$result_rs);
$i=0;
echo "<table>";while (odbc_fetch_row($result_id))
{
$xh=odbc_result($result_id,1);
$cyhm=odbc_result($result_id,2);
$i++;
echo "<tr>";
echo "<td width='50%'>$xh</td>";
echo "<td width='50%'><a href=$cyhm>$cyhm</a></td></tr>";
}
echo "</table>";
?>
在我的机子上运行时出现FATAL: emalloc(): Unable to allocate 1073741824 bytes 或:Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.--------------------------------------------------------------------------------Apache/1.3.23 Server at localhost Port 80
[MSSQL]
extension=php_mssql70.dll
mssql.allow_persistent = On ; allow or prevent persistent link
mssql.max_persistent = -1 ; maximum number of persistent links. -1 means no limit
mssql.max_links = -1 ; maximum number of links (persistent+non persistent). -1 means no limit
mssql.min_error_severity = 10 ; minimum error severity to display
mssql.min_message_severity = 10 ; minimum message severity to display
mssql.compatability_mode = On ; compatability mode with old versions of PHP 3.0.
我的PHP.ini为:;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.
;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;
;extension=php_bz2.dll
;extension=php_ctype.dll
;extension=php_cpdf.dll
;extension=php_curl.dll
;extension=php_cybercash.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
;extension=php_dotnet.dll
;extension=php_exif.dll
;extension=php_fbsql.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd.dll
;extension=php_gettext.dll
;extension=php_hyperwave.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_ingres.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_printer.dll
;extension=php_sablot.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_xslt.dll
;extension=php_yaz.dll
;extension=php_zlib.dll
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;[Syslog]
; Whether or not to define the various syslog variables (e.g. $LOG_PID,
; $LOG_CRON, etc.). Turning it off is a good idea performance-wise. In
; runtime, you can define these variables by calling define_syslog_variables().
define_syslog_variables = Off[mail function]
; For Win32 only.
SMTP = localhost; For Win32 only.
sendmail_from = [email protected]; For Unix only. You may supply arguments as well (default: 'sendmail -t -i').
;sendmail_path =[Logging]
; These configuration directives are used by the example logging mechanism.
; See examples/README.logging for more explanation.
;logging.method = db
;logging.directory = /path/to/log/directory[Java]
;java.class.path = .\php_java.jar
;java.home = c:\jdk
;java.library = c:\jdk\jre\bin\hotspot\jvm.dll
;java.library.path = .\[SQL]
sql.safe_mode = Off[ODBC]
;odbc.default_db = Not yet implemented
;odbc.default_user = Not yet implemented
;odbc.default_pw = Not yet implemented; Allow or prevent persistent links.
odbc.allow_persistent = On; Check that a connection is still valid before reuse.
odbc.check_persistent = On; Maximum number of persistent links. -1 means no limit.
odbc.max_persistent = -1; Maximum number of links (persistent + non-persistent). -1 means no limit.
odbc.max_links = -1 ; Handling of LONG fields. Returns number of bytes to variables. 0 means
; passthru.
odbc.defaultlrl = 40960000 ; Handling of binary data. 0 means passthru, 1 return as is, 2 convert to char.
; See the documentation on odbc_binmode and odbc_longreadlen for an explanation
; of uodbc.defaultlrl and uodbc.defaultbinmode
odbc.defaultbinmode = 1 [MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
' at MYSQL_PORT.
mysql.default_port =; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =[mSQL]
; Allow or prevent persistent links.
msql.allow_persistent = On; Maximum number of persistent links. -1 means no limit.
msql.max_persistent = -1; Maximum number of links (persistent+non persistent). -1 means no limit.
msql.max_links = -1[PostgresSQL]
; Allow or prevent persistent links.
pgsql.allow_persistent = On; Maximum number of persistent links. -1 means no limit.
pgsql.max_persistent = -1; Maximum number of links (persistent+non persistent). -1 means no limit.
pgsql.max_links = -1[Sybase]
; Allow or prevent persistent links.
sybase.allow_persistent = On; Maximum number of persistent links. -1 means no limit.
sybase.max_persistent = -1; Maximum number of links (persistent + non-persistent). -1 means no limit.
sybase.max_links = -1;sybase.interface_file = "/usr/sybase/interfaces"; Minimum error severity to display.
sybase.min_error_severity = 10; Minimum message severity to display.
sybase.min_message_severity = 10; Compatability mode with old versions of PHP 3.0.
; If on, this will cause PHP to automatically assign types to results according
; to their Sybase type, instead of treating them all as strings. This
; compatability mode will probably not stay around forever, so try applying
; whatever necessary changes to your code, and turn it off.
sybase.compatability_mode = Off[Sybase-CT]
; Allow or prevent persistent links.
sybct.allow_persistent = On; Maximum number of persistent links. -1 means no limit.
sybct.max_persistent = -1; Maximum number of links (persistent + non-persistent). -1 means no limit.
sybct.max_links = -1; Minimum server message severity to display.
sybct.min_server_severity = 10; Minimum client message severity to display.
sybct.min_client_severity = 10[bcmath]
; Number of decimal digits for all bcmath functions.
bcmath.scale = 0[browscap]
;browscap = extra/browscap.ini
我有E_mail:[email protected]
还有一个问题:
在连接MS-SQL时用odbc_connect可以但用mssql_connect($hostname,$dbuser,$dbpasswd)就不行。
$dbuser = "sa"; //用户名
$dbpasswd = ""; //密码
$id = mssql_connect($hostname,$dbuser,$dbpasswd);
$db = mssql_select_db("gwwbgxt",$id) or die("无法连接数据库!");
$query = "select * from yhb";
$rresult = mssql_query($query) or die("无法执行SQL:$query");
....
有的人说可以,但不知如何说!
我用了不行!在MS_SQL国TEXT类仍不显示!
在PHP.ini中加入“extension=php_mssql70.dll”.
本人的PHP为4.2版