问:
MSSQL_CONNECT returns nothing - no error but no response either
I have MSSQL and an IIS7 server but would like to write a PHP website that can retrieve data from my database.

I have switched all my mysql_ instances with mssql_, but it simply won't connect when I try:

```<code>$this->connection = mssql_connect(DB_HOST, DB_USER, DB_PASSWORD);
</code>```

I have echo'd out the 3 pieces of data above and all are correct. I cannot echo anything after the line above, it completely kills it.

I have custom error reporting and have even tried taking it off, to no avail - just a blank page:

```<code>set_error_handler("customError");
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
</code>```

Can some one point me in the right direction for setting up IIS to be able to connect through mssql_connect please? I enjoy programming but server config is not my forte!

Here is the mssql block in my php.ini file located: C:\Program Files (x86)\PHP\v5.3

```<code>[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent).  -1 means no limit.
mssql.max_links = -1

; Minimum error severity to display.
mssql.min_error_severity = 10

; Minimum message severity to display.
mssql.min_message_severity = 10

; Compatibility mode with old versions of PHP 3.0.
mssql.compatability_mode = Off

; Connect timeout
;mssql.connect_timeout = 5

; Query timeout
;mssql.timeout = 60

; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textlimit = 4096

; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textsize = 4096

; Limits the number of records in each batch.  0 = all records in one batch.
;mssql.batchsize = 0

; Specify how datetime and datetim4 columns are returned
; On => Returns data converted to SQL server settings
; Off => Returns values as YYYY-MM-DD hh:mm:ss
;mssql.datetimeconvert = On

; Use NT authentication when connecting to the server
mssql.secure_connection = Off

; Specify max number of processes. -1 = library default
; msdlib defaults to 25
; FreeTDS defaults to 4096
;mssql.max_procs = -1

; Specify client character set.
; If empty or not set the client charset from freetds.comf is used
; This is only used when compiled with FreeTDS
;mssql.charset = "ISO-8859-1"
</code>```

Here is my phpinfo(INFO_MODULES)

```    bcmath
BCMath support  enabled

Directive   Local Value Master Value
bcmath.scale    0   0

calendar
Calendar support    enabled

cgi-fcgi
Directive   Local Value Master Value
cgi.check_shebang_line  1   1
cgi.discard_path    0   0
cgi.fix_pathinfo    1   1
cgi.force_redirect  0   0
cgi.nph 0   0
cgi.redirect_status_env no value    no value
cgi.rfc2616_headers 0   0
fastcgi.impersonate 1   1
fastcgi.logging 1   1

com_dotnet
COM support enabled
DCOM support    disabled
.Net support    enabled

Directive   Local Value Master Value
com.allow_dcom  0   0
com.autoregister_casesensitive  1   1
com.autoregister_typelib    0   0
com.autoregister_verbose    0   0
com.code_page   no value    no value
com.typelib_file    no value    no value

Core
PHP Version     5.3.6

Directive   Local Value Master Value
allow_call_time_pass_reference  Off Off
allow_url_fopen On  On
allow_url_include   Off Off
always_populate_raw_post_data   Off Off
arg_separator.input &   &
arg_separator.output    &   &
asp_tags    Off Off
auto_append_file    no value    no value
auto_globals_jit    On  On
auto_prepend_file   no value    no value
browscap    no value    no value
default_charset no value    no value
default_mimetype    text/html   text/html
define_syslog_variables Off Off
disable_classes no value    no value
disable_functions   no value    no value
display_errors  On  On
display_startup_errors  Off Off
doc_root    no value    no value
docref_ext  no value    no value
docref_root no value    no value
enable_dl   Off Off
error_append_string no value    no value
error_log   C:\Windows\temp\php53_errors.log    C:\Windows\temp\php53_errors.log
error_prepend_string    no value    no value
error_reporting 32767   32767
exit_on_timeout Off Off
expose_php  On  On
extension_dir   C:\Program Files (x86)\PHP\v5.3\ext\    C:\Program Files (x86)\PHP\v5.3\ext\
file_uploads    On  On
highlight.bg    #FFFFFF #FFFFFF
highlight.comment   #FF8000 #FF8000
highlight.default   #0000BB #0000BB
highlight.html  #000000 #000000
highlight.keyword   #007700 #007700
highlight.string    #DD0000 #DD0000
html_errors On  On
ignore_repeated_errors  Off Off
ignore_repeated_source  Off Off
ignore_user_abort   Off Off
implicit_flush  Off Off
include_path    .;C:\php\pear   .;C:\php\pear
log_errors  On  On
log_errors_max_len  1024    1024
magic_quotes_gpc    Off Off
magic_quotes_runtime    Off Off
magic_quotes_sybase Off Off
mail.add_x_header   On  On
mail.force_extra_parameters no value    no value
mail.log    no value    no value
max_execution_time  300 300
max_file_uploads    20  20
max_input_nesting_level 64  64
max_input_time  60  60
memory_limit    128M    128M
open_basedir    no value    no value
output_buffering    4096    4096
output_handler  no value    no value
post_max_size   8M  8M
precision   14  14
realpath_cache_size 16K 16K
realpath_cache_ttl  120 120
register_argc_argv  Off Off
register_globals    Off Off
register_long_arrays    Off Off
report_memleaks On  On
report_zend_debug   On  On
request_order   GP  GP
safe_mode   Off Off
safe_mode_exec_dir  no value    no value
safe_mode_gid   Off Off
safe_mode_include_dir   no value    no value
sendmail_from   no value    no value
sendmail_path   no value    no value
serialize_precision 17  17
short_open_tag  Off Off
SMTP    localhost   localhost
smtp_port   25  25
sql.safe_mode   Off Off
track_errors    On  On
unserialize_callback_func   no value    no value
upload_max_filesize 2M  2M
upload_tmp_dir  C:\Windows\temp C:\Windows\temp
user_dir    no value    no value
user_ini.cache_ttl  300 300
user_ini.filename   .user.ini   .user.ini
variables_order GPCS    GPCS
xmlrpc_error_number 0   0
xmlrpc_errors   Off Off
y2k_compliance  On  On
zend.enable_gc  On  On

ctype
ctype functions     enabled

curl
cURL support    enabled
cURL Information    7.21.2
Age     3
Features
AsynchDNS   Yes
Debug   No
GSS-Negotiate   No
IDN     No
IPv6    Yes
Largefile   Yes
NTLM    Yes
SPNEGO  No
SSL     Yes
SSPI    Yes
krb4    No
libz    Yes
CharConv    No
Protocols   dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host    i386-pc-win32
SSL Version     OpenSSL/0.9.8r
ZLib Version    1.2.3
libSSH Version  libssh2/1.2.7

date
date/time support   enabled
"Olson" Timezone Database Version   2011.4
Timezone Database   internal
Default timezone    Europe/Minsk

Directive   Local Value Master Value
date.default_latitude   31.7667 31.7667
date.default_longitude  35.2333 35.2333
date.sunrise_zenith 90.583333   90.583333
date.sunset_zenith  90.583333   90.583333
date.timezone   Europe/Minsk    Europe/Minsk

dom
DOM/XML     enabled
DOM/XML API Version     20031129
libxml Version  2.7.7
HTML Support    enabled
XPath Support   enabled
XPointer Support    enabled
Schema Support  enabled
RelaxNG Support     enabled

ereg
Regex Library   Bundled library enabled

exif
EXIF Support    enabled
EXIF Version    1.4 $Id: exif.c 308362 2011-02-15 14:02:26Z pajoye $
Supported EXIF Version  0220
Supported filetypes     JPEG,TIFF

Directive   Local Value Master Value
exif.decode_jis_intel   JIS JIS
exif.decode_jis_motorola    JIS JIS
exif.decode_unicode_intel   UCS-2LE UCS-2LE
exif.decode_unicode_motorola    UCS-2BE UCS-2BE
exif.encode_jis no value    no value
exif.encode_unicode ISO-8859-15 ISO-8859-15

filter
Input Validation and Filtering  enabled
Revision    $Revision: 306939 $

Directive   Local Value Master Value
filter.default  unsafe_raw  unsafe_raw
filter.default_flags    no value    no value

ftp
FTP support     enabled

gd
GD Support  enabled
GD Version  bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.4.3
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support    enabled
libJPEG Version     6b
PNG Support     enabled
libPNG Version  1.2.44
WBMP Support    enabled
XBM Support     enabled

Directive   Local Value Master Value
gd.jpeg_ignore_warning  0   0

gettext
GetText Support     enabled

hash
hash support    enabled
Hashing Engines     md2 md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost adler32 crc32 crc32b salsa10 salsa20 haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5

iconv
iconv support   enabled
iconv implementation    "libiconv"
iconv library version   1.11

Directive   Local Value Master Value
iconv.input_encoding    ISO-8859-1  ISO-8859-1
iconv.internal_encoding ISO-8859-1  ISO-8859-1
iconv.output_encoding   ISO-8859-1  ISO-8859-1

imap
IMAP c-Client Version   2007e
SSL Support     enabled

json
json support    enabled
json version    1.2.1

libxml
libXML support  active
libXML Compiled Version     2.7.7
libXML Loaded Version   20707
libXML streams  enabled

mbstring
Multibyte Support   enabled
Multibyte string engine     libmbfl
HTTP input encoding translation     disabled

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

Multibyte (japanese) regex support  enabled
Multibyte regex (oniguruma) version     4.7.1

Directive   Local Value Master Value
mbstring.detect_order   no value    no value
mbstring.encoding_translation   Off Off
mbstring.func_overload  0   0
mbstring.http_input pass    pass
mbstring.http_output    pass    pass
mbstring.http_output_conv_mimetypes ^(text/|application/xhtml\+xml) ^(text/|application/xhtml\+xml)
mbstring.internal_encoding  no value    no value
mbstring.language   neutral neutral
mbstring.strict_detection   Off Off
mbstring.substitute_character   no value    no value

mcrypt
mcrypt support  enabled
mcrypt_filter support   enabled
Version     2.5.8
Api No  20021217
Supported ciphers   cast-128 gost rijndael-128 twofish cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes arcfour
Supported modes     cbc cfb ctr ecb ncfb nofb ofb stream

Directive   Local Value Master Value
mcrypt.algorithms_dir   no value    no value
mcrypt.modes_dir    no value    no value

mhash
MHASH support   Enabled
MHASH API Version   Emulated Support

mysql
MySQL Support   enabled
Active Persistent Links     0
Active Links    0
Client API version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $

Directive   Local Value Master Value
mysql.allow_local_infile    On  On
mysql.allow_persistent  On  On
mysql.connect_timeout   60  60
mysql.default_host  no value    no value
mysql.default_password  no value    no value
mysql.default_port  no value    no value
mysql.default_socket    no value    no value
mysql.default_user  no value    no value
mysql.max_links Unlimited   Unlimited
mysql.max_persistent    Unlimited   Unlimited
mysql.trace_mode    Off Off

mysqli
MysqlI Support  enabled
Client API library version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $
Active Persistent Links     0
Inactive Persistent Links   0
Active Links    0

Directive   Local Value Master Value
mysqli.allow_local_infile   On  On
mysqli.allow_persistent On  On
mysqli.default_host no value    no value
mysqli.default_port 3306    3306
mysqli.default_pw   no value    no value
mysqli.default_socket   no value    no value
mysqli.default_user no value    no value
mysqli.max_links    Unlimited   Unlimited
mysqli.max_persistent   Unlimited   Unlimited
mysqli.reconnect    Off Off

mysqlnd
mysqlnd enabled
Version     mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $
Compression     supported
SSL     supported
Command buffer size     4096
Read buffer size    32768
Read timeout    31536000
Collecting statistics   Yes
Collecting memory statistics    No
Tracing     n/a

Client statistics
bytes_sent  0
bytes_received  0
packets_sent    0
packets_received    0
protocol_overhead_in    0
protocol_overhead_out   0
bytes_received_ok_packet    0
bytes_received_eof_packet   0
bytes_received_rset_header_packet   0
bytes_received_rset_field_meta_packet   0
bytes_received_rset_row_packet  0
bytes_received_prepare_response_packet  0
bytes_received_change_user_packet   0
packets_sent_command    0
packets_received_ok     0
packets_received_eof    0
packets_received_rset_header    0
packets_received_rset_field_meta    0
packets_received_rset_row   0
packets_received_prepare_response   0
packets_received_change_user    0
result_set_queries  0
non_result_set_queries  0
no_index_used   0
bad_index_used  0
slow_queries    0
buffered_sets   0
unbuffered_sets     0
ps_buffered_sets    0
ps_unbuffered_sets  0
flushed_normal_sets     0
flushed_ps_sets     0
ps_prepared_never_executed  0
ps_prepared_once_executed   0
rows_fetched_from_server_normal     0
rows_fetched_from_server_ps     0
rows_buffered_from_client_normal    0
rows_buffered_from_client_ps    0
rows_fetched_from_client_normal_buffered    0
rows_fetched_from_client_normal_unbuffered  0
rows_fetched_from_client_ps_buffered    0
rows_fetched_from_client_ps_unbuffered  0
rows_fetched_from_client_ps_cursor  0
rows_affected_normal    0
rows_affected_ps    0
rows_skipped_normal     0
rows_skipped_ps     0
copy_on_write_saved     0
copy_on_write_performed     0
command_buffer_too_small    0
connect_success     0
connect_failure     0
connection_reused   0
reconnect   0
pconnect_success    0
active_connections  0
active_persistent_connections   0
explicit_close  0
implicit_close  0
disconnect_close    0
in_middle_of_command_close  0
explicit_free_result    0
implicit_free_result    0
explicit_stmt_close     0
implicit_stmt_close     0
mem_emalloc_count   0
mem_emalloc_amount  0
mem_ecalloc_count   0
mem_ecalloc_amount  0
mem_erealloc_count  0
mem_erealloc_amount     0
mem_efree_count     0
mem_efree_amount    0
mem_malloc_count    0
mem_malloc_amount   0
mem_calloc_count    0
mem_calloc_amount   0
mem_realloc_count   0
mem_realloc_amount  0
mem_free_count  0
mem_free_amount     0
mem_estrndup_count  0
mem_strndup_count   0
mem_estndup_count   0
mem_strdup_count    0
proto_text_fetched_null     0
proto_text_fetched_bit  0
proto_text_fetched_tinyint  0
proto_text_fetched_short    0
proto_text_fetched_int24    0
proto_text_fetched_int  0
proto_text_fetched_bigint   0
proto_text_fetched_decimal  0
proto_text_fetched_float    0
proto_text_fetched_double   0
proto_text_fetched_date     0
proto_text_fetched_year     0
proto_text_fetched_time     0
proto_text_fetched_datetime     0
proto_text_fetched_timestamp    0
proto_text_fetched_string   0
proto_text_fetched_blob     0
proto_text_fetched_enum     0
proto_text_fetched_set  0
proto_text_fetched_geometry     0
proto_text_fetched_other    0
proto_binary_fetched_null   0
proto_binary_fetched_bit    0
proto_binary_fetched_tinyint    0
proto_binary_fetched_short  0
proto_binary_fetched_int24  0
proto_binary_fetched_int    0
proto_binary_fetched_bigint     0
proto_binary_fetched_decimal    0
proto_binary_fetched_float  0
proto_binary_fetched_double     0
proto_binary_fetched_date   0
proto_binary_fetched_year   0
proto_binary_fetched_time   0
proto_binary_fetched_datetime   0
proto_binary_fetched_timestamp  0
proto_binary_fetched_string     0
proto_binary_fetched_blob   0
proto_binary_fetched_enum   0
proto_binary_fetched_set    0
proto_binary_fetched_geometry   0
proto_binary_fetched_other  0
init_command_executed_count     0
init_command_failed_count   0
com_quit    0
com_init_db     0
com_query   0
com_field_list  0
com_create_db   0
com_drop_db     0
com_refresh     0
com_shutdown    0
com_statistics  0
com_process_info    0
com_connect     0
com_process_kill    0
com_debug   0
com_ping    0
com_time    0
com_delayed_insert  0
com_change_user     0
com_binlog_dump     0
com_table_dump  0
com_connect_out     0
com_register_slave  0
com_stmt_prepare    0
com_stmt_execute    0
com_stmt_send_long_data     0
com_stmt_close  0
com_stmt_reset  0
com_stmt_set_option     0
com_stmt_fetch  0
com_deamon  0
bytes_received_real_data_normal     0
bytes_received_real_data_ps     0

odbc
ODBC Support    enabled
Active Persistent Links     0
Active Links    0
ODBC library    Win32

Directive   Local Value Master Value
odbc.allow_persistent   On  On
odbc.check_persistent   On  On
odbc.default_cursortype Static cursor   Static cursor
odbc.default_db no value    no value
odbc.default_pw no value    no value
odbc.default_user   no value    no value
odbc.defaultbinmode return as is    return as is
odbc.defaultlrl return up to 4096 bytes return up to 4096 bytes
odbc.max_links  Unlimited   Unlimited
odbc.max_persistent Unlimited   Unlimited

openssl
OpenSSL support     enabled
OpenSSL Library Version     OpenSSL 0.9.8r 8 Feb 2011
OpenSSL Header Version  OpenSSL 0.9.8r 8 Feb 2011

pcre
PCRE (Perl Compatible Regular Expressions) Support  enabled
PCRE Library Version    8.11 2010-12-10

Directive   Local Value Master Value
pcre.backtrack_limit    100000  100000
pcre.recursion_limit    100000  100000

PDO
PDO support enabled
PDO drivers     mysql, sqlite

pdo_mysql
PDO Driver for MySQL    enabled
Client API version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $

pdo_sqlite
PDO Driver for SQLite 3.x   enabled
SQLite Library  3.7.4

Phar
Phar: PHP Archive support   enabled
Phar EXT version    2.0.1
Phar API version    1.1.1
SVN revision    $Revision: 307915 $
Phar-based phar archives    enabled
Tar-based phar archives     enabled
ZIP-based phar archives     enabled
gzip compression    enabled
bzip2 compression   disabled (install pecl/bz2)
OpenSSL support     enabled

Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.

Directive   Local Value Master Value
phar.cache_list no value    no value
phar.readonly   On  On
phar.require_hash   On  On

Reflection
Reflection  enabled
Version     $Revision: 307971 $

session
Session Support     enabled
Registered save handlers    files user
Registered serializer handlers  php php_binary wddx

Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   Off Off
session.bug_compat_warn Off Off
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly Off Off
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   C:\Windows\temp C:\Windows\temp
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    On  On
session.use_trans_sid   0   0

SimpleXML
Simplexml support   enabled
Revision    $Revision: 308262 $
Schema support  enabled

soap
Soap Client     enabled
Soap Server     enabled

Directive   Local Value Master Value
soap.wsdl_cache 1   1
soap.wsdl_cache_dir /tmp    /tmp
soap.wsdl_cache_enabled 1   1
soap.wsdl_cache_limit   5   5
soap.wsdl_cache_ttl 86400   86400

SPL
SPL support enabled
Interfaces  Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes     AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

standard
Dynamic Library Support     enabled
Internal Sendmail Support for Windows   enabled

Directive   Local Value Master Value
assert.active   1   1
assert.bail 0   0
assert.callback no value    no value
assert.quiet_eval   0   0
assert.warning  1   1
auto_detect_line_endings    0   0
default_socket_timeout  60  60
from    no value    no value
safe_mode_allowed_env_vars  PHP_    PHP_
safe_mode_protected_env_vars    LD_LIBRARY_PATH LD_LIBRARY_PATH
url_rewriter.tags   a=href,area=href,frame=src,input=src,form=fakeentry a=href,area=href,frame=src,input=src,form=fakeentry
user_agent  no value    no value

tidy
Tidy support    enabled
libTidy Release     25 March 2009
Extension Version   2.0 ($Id: tidy.c 306939 2011-01-01 02:19:59Z felipe $)

Directive   Local Value Master Value
tidy.clean_output   no value    no value
tidy.default_config no value    no value

tokenizer
Tokenizer Support   enabled

wddx
WDDX Support    enabled
WDDX Session Serializer     enabled

xml
XML Support     active
XML Namespace Support   active
libxml2 Version     2.7.7

xmlreader
XMLReader   enabled

xmlrpc
core library version    xmlrpc-epi v. 0.51
php extension version   0.51
author  Dan Libby
homepage    http://xmlrpc-epi.sourceforge.net
open sourced by     Epinions.com

xmlwriter
XMLWriter   enabled

zip
Zip     enabled
Extension Version   $Id: php_zip.c 308107 2011-02-07 16:20:16Z pajoye $
Zip version     1.9.1
Libzip version  0.9.0

zlib
ZLib Support    enabled
Stream Wrapper support  compress.zlib://
Stream Filter support   zlib.inflate, zlib.deflate
Compiled Version    1.2.5
Linked Version  1.2.5

Directive   Local Value Master Value
zlib.output_compression Off Off
zlib.output_compression_level   -1  -1
zlib.output_handler no value    no value

Additional Modules
Module Name

1
```

答:
The PHP manual is the best place to look for information about things like this.

http://php.net/manual/en/book.mssql.php

As far as installing MSSQL extensions, you will need to "change" your installation of PHP and enable the MSSQL extension.  This will automatically install the extension for you.  Then, just make sure your php.ini file has the extension enabled (there will be a [MSSQL] block).

Body:
I have MSSQL and an IIS7 server but would like to write a PHP website that can retrieve data from my database.

I have switched all my mysql_ instances with mssql_, but it simply won't connect when I try:

$this->connection = mssql_connect(DB_HOST, DB_USER, DB_PASSWORD);

I have echo'd out the 3 pieces of data above and all are correct. I cannot echo anything after the line above, it completely kills it.

I have custom error reporting and have even tried taking it off, to no avail - just a blank page:

set_error_handler("customError");
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

Can some one point me in the right direction for setting up IIS to be able to connect through mssql_connect please? I enjoy programming but server config is not my forte!

Here is the mssql block in my php.ini file located: C:\Program Files (x86)\PHP\v5.3

[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent).  -1 means no limit.
mssql.max_links = -1

; Minimum error severity to display.
mssql.min_error_severity = 10

; Minimum message severity to display.
mssql.min_message_severity = 10

; Compatibility mode with old versions of PHP 3.0.
mssql.compatability_mode = Off

; Connect timeout
;mssql.connect_timeout = 5

; Query timeout
;mssql.timeout = 60

; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textlimit = 4096

; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textsize = 4096

; Limits the number of records in each batch.  0 = all records in one batch.
;mssql.batchsize = 0

; Specify how datetime and datetim4 columns are returned
; On => Returns data converted to SQL server settings
; Off => Returns values as YYYY-MM-DD hh:mm:ss
;mssql.datetimeconvert = On

; Use NT authentication when connecting to the server
mssql.secure_connection = Off

; Specify max number of processes. -1 = library default
; msdlib defaults to 25
; FreeTDS defaults to 4096
;mssql.max_procs = -1

; Specify client character set.
; If empty or not set the client charset from freetds.comf is used
; This is only used when compiled with FreeTDS
;mssql.charset = "ISO-8859-1"

Here is my phpinfo(INFO_MODULES)

    bcmath
BCMath support  enabled

Directive   Local Value Master Value
bcmath.scale    0   0

calendar
Calendar support    enabled

cgi-fcgi
Directive   Local Value Master Value
cgi.check_shebang_line  1   1
cgi.discard_path    0   0
cgi.fix_pathinfo    1   1
cgi.force_redirect  0   0
cgi.nph 0   0
cgi.redirect_status_env no value    no value
cgi.rfc2616_headers 0   0
fastcgi.impersonate 1   1
fastcgi.logging 1   1

com_dotnet
COM support enabled
DCOM support    disabled
.Net support    enabled

Directive   Local Value Master Value
com.allow_dcom  0   0
com.autoregister_casesensitive  1   1
com.autoregister_typelib    0   0
com.autoregister_verbose    0   0
com.code_page   no value    no value
com.typelib_file    no value    no value

Core
PHP Version     5.3.6

Directive   Local Value Master Value
allow_call_time_pass_reference  Off Off
allow_url_fopen On  On
allow_url_include   Off Off
always_populate_raw_post_data   Off Off
arg_separator.input &   &
arg_separator.output    &   &
asp_tags    Off Off
auto_append_file    no value    no value
auto_globals_jit    On  On
auto_prepend_file   no value    no value
browscap    no value    no value
default_charset no value    no value
default_mimetype    text/html   text/html
define_syslog_variables Off Off
disable_classes no value    no value
disable_functions   no value    no value
display_errors  On  On
display_startup_errors  Off Off
doc_root    no value    no value
docref_ext  no value    no value
docref_root no value    no value
enable_dl   Off Off
error_append_string no value    no value
error_log   C:\Windows\temp\php53_errors.log    C:\Windows\temp\php53_errors.log
error_prepend_string    no value    no value
error_reporting 32767   32767
exit_on_timeout Off Off
expose_php  On  On
extension_dir   C:\Program Files (x86)\PHP\v5.3\ext\    C:\Program Files (x86)\PHP\v5.3\ext\
file_uploads    On  On
highlight.bg    #FFFFFF #FFFFFF
highlight.comment   #FF8000 #FF8000
highlight.default   #0000BB #0000BB
highlight.html  #000000 #000000
highlight.keyword   #007700 #007700
highlight.string    #DD0000 #DD0000
html_errors On  On
ignore_repeated_errors  Off Off
ignore_repeated_source  Off Off
ignore_user_abort   Off Off
implicit_flush  Off Off
include_path    .;C:\php\pear   .;C:\php\pear
log_errors  On  On
log_errors_max_len  1024    1024
magic_quotes_gpc    Off Off
magic_quotes_runtime    Off Off
magic_quotes_sybase Off Off
mail.add_x_header   On  On
mail.force_extra_parameters no value    no value
mail.log    no value    no value
max_execution_time  300 300
max_file_uploads    20  20
max_input_nesting_level 64  64
max_input_time  60  60
memory_limit    128M    128M
open_basedir    no value    no value
output_buffering    4096    4096
output_handler  no value    no value
post_max_size   8M  8M
precision   14  14
realpath_cache_size 16K 16K
realpath_cache_ttl  120 120
register_argc_argv  Off Off
register_globals    Off Off
register_long_arrays    Off Off
report_memleaks On  On
report_zend_debug   On  On
request_order   GP  GP
safe_mode   Off Off
safe_mode_exec_dir  no value    no value
safe_mode_gid   Off Off
safe_mode_include_dir   no value    no value
sendmail_from   no value    no value
sendmail_path   no value    no value
serialize_precision 17  17
short_open_tag  Off Off
SMTP    localhost   localhost
smtp_port   25  25
sql.safe_mode   Off Off
track_errors    On  On
unserialize_callback_func   no value    no value
upload_max_filesize 2M  2M
upload_tmp_dir  C:\Windows\temp C:\Windows\temp
user_dir    no value    no value
user_ini.cache_ttl  300 300
user_ini.filename   .user.ini   .user.ini
variables_order GPCS    GPCS
xmlrpc_error_number 0   0
xmlrpc_errors   Off Off
y2k_compliance  On  On
zend.enable_gc  On  On

ctype
ctype functions     enabled

curl
cURL support    enabled
cURL Information    7.21.2
Age     3
Features
AsynchDNS   Yes
Debug   No
GSS-Negotiate   No
IDN     No
IPv6    Yes
Largefile   Yes
NTLM    Yes
SPNEGO  No
SSL     Yes
SSPI    Yes
krb4    No
libz    Yes
CharConv    No
Protocols   dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host    i386-pc-win32
SSL Version     OpenSSL/0.9.8r
ZLib Version    1.2.3
libSSH Version  libssh2/1.2.7

date
date/time support   enabled
"Olson" Timezone Database Version   2011.4
Timezone Database   internal
Default timezone    Europe/Minsk

Directive   Local Value Master Value
date.default_latitude   31.7667 31.7667
date.default_longitude  35.2333 35.2333
date.sunrise_zenith 90.583333   90.583333
date.sunset_zenith  90.583333   90.583333
date.timezone   Europe/Minsk    Europe/Minsk

dom
DOM/XML     enabled
DOM/XML API Version     20031129
libxml Version  2.7.7
HTML Support    enabled
XPath Support   enabled
XPointer Support    enabled
Schema Support  enabled
RelaxNG Support     enabled

ereg
Regex Library   Bundled library enabled

exif
EXIF Support    enabled
EXIF Version    1.4 $Id: exif.c 308362 2011-02-15 14:02:26Z pajoye $
Supported EXIF Version  0220
Supported filetypes     JPEG,TIFF

Directive   Local Value Master Value
exif.decode_jis_intel   JIS JIS
exif.decode_jis_motorola    JIS JIS
exif.decode_unicode_intel   UCS-2LE UCS-2LE
exif.decode_unicode_motorola    UCS-2BE UCS-2BE
exif.encode_jis no value    no value
exif.encode_unicode ISO-8859-15 ISO-8859-15

filter
Input Validation and Filtering  enabled
Revision    $Revision: 306939 $

Directive   Local Value Master Value
filter.default  unsafe_raw  unsafe_raw
filter.default_flags    no value    no value

ftp
FTP support     enabled

gd
GD Support  enabled
GD Version  bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.4.3
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support    enabled
libJPEG Version     6b
PNG Support     enabled
libPNG Version  1.2.44
WBMP Support    enabled
XBM Support     enabled

Directive   Local Value Master Value
gd.jpeg_ignore_warning  0   0

gettext
GetText Support     enabled

hash
hash support    enabled
Hashing Engines     md2 md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost adler32 crc32 crc32b salsa10 salsa20 haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5

iconv
iconv support   enabled
iconv implementation    "libiconv"
iconv library version   1.11

Directive   Local Value Master Value
iconv.input_encoding    ISO-8859-1  ISO-8859-1
iconv.internal_encoding ISO-8859-1  ISO-8859-1
iconv.output_encoding   ISO-8859-1  ISO-8859-1

imap
IMAP c-Client Version   2007e
SSL Support     enabled

json
json support    enabled
json version    1.2.1

libxml
libXML support  active
libXML Compiled Version     2.7.7
libXML Loaded Version   20707
libXML streams  enabled

mbstring
Multibyte Support   enabled
Multibyte string engine     libmbfl
HTTP input encoding translation     disabled

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

Multibyte (japanese) regex support  enabled
Multibyte regex (oniguruma) version     4.7.1

Directive   Local Value Master Value
mbstring.detect_order   no value    no value
mbstring.encoding_translation   Off Off
mbstring.func_overload  0   0
mbstring.http_input pass    pass
mbstring.http_output    pass    pass
mbstring.http_output_conv_mimetypes ^(text/|application/xhtml\+xml) ^(text/|application/xhtml\+xml)
mbstring.internal_encoding  no value    no value
mbstring.language   neutral neutral
mbstring.strict_detection   Off Off
mbstring.substitute_character   no value    no value

mcrypt
mcrypt support  enabled
mcrypt_filter support   enabled
Version     2.5.8
Api No  20021217
Supported ciphers   cast-128 gost rijndael-128 twofish cast-256 loki97 rijndael-192 saferplus wake blowfish-compat des rijndael-256 serpent xtea blowfish enigma rc2 tripledes arcfour
Supported modes     cbc cfb ctr ecb ncfb nofb ofb stream

Directive   Local Value Master Value
mcrypt.algorithms_dir   no value    no value
mcrypt.modes_dir    no value    no value

mhash
MHASH support   Enabled
MHASH API Version   Emulated Support

mysql
MySQL Support   enabled
Active Persistent Links     0
Active Links    0
Client API version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $

Directive   Local Value Master Value
mysql.allow_local_infile    On  On
mysql.allow_persistent  On  On
mysql.connect_timeout   60  60
mysql.default_host  no value    no value
mysql.default_password  no value    no value
mysql.default_port  no value    no value
mysql.default_socket    no value    no value
mysql.default_user  no value    no value
mysql.max_links Unlimited   Unlimited
mysql.max_persistent    Unlimited   Unlimited
mysql.trace_mode    Off Off

mysqli
MysqlI Support  enabled
Client API library version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $
Active Persistent Links     0
Inactive Persistent Links   0
Active Links    0

Directive   Local Value Master Value
mysqli.allow_local_infile   On  On
mysqli.allow_persistent On  On
mysqli.default_host no value    no value
mysqli.default_port 3306    3306
mysqli.default_pw   no value    no value
mysqli.default_socket   no value    no value
mysqli.default_user no value    no value
mysqli.max_links    Unlimited   Unlimited
mysqli.max_persistent   Unlimited   Unlimited
mysqli.reconnect    Off Off

mysqlnd
mysqlnd enabled
Version     mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $
Compression     supported
SSL     supported
Command buffer size     4096
Read buffer size    32768
Read timeout    31536000
Collecting statistics   Yes
Collecting memory statistics    No
Tracing     n/a

Client statistics
bytes_sent  0
bytes_received  0
packets_sent    0
packets_received    0
protocol_overhead_in    0
protocol_overhead_out   0
bytes_received_ok_packet    0
bytes_received_eof_packet   0
bytes_received_rset_header_packet   0
bytes_received_rset_field_meta_packet   0
bytes_received_rset_row_packet  0
bytes_received_prepare_response_packet  0
bytes_received_change_user_packet   0
packets_sent_command    0
packets_received_ok     0
packets_received_eof    0
packets_received_rset_header    0
packets_received_rset_field_meta    0
packets_received_rset_row   0
packets_received_prepare_response   0
packets_received_change_user    0
result_set_queries  0
non_result_set_queries  0
no_index_used   0
bad_index_used  0
slow_queries    0
buffered_sets   0
unbuffered_sets     0
ps_buffered_sets    0
ps_unbuffered_sets  0
flushed_normal_sets     0
flushed_ps_sets     0
ps_prepared_never_executed  0
ps_prepared_once_executed   0
rows_fetched_from_server_normal     0
rows_fetched_from_server_ps     0
rows_buffered_from_client_normal    0
rows_buffered_from_client_ps    0
rows_fetched_from_client_normal_buffered    0
rows_fetched_from_client_normal_unbuffered  0
rows_fetched_from_client_ps_buffered    0
rows_fetched_from_client_ps_unbuffered  0
rows_fetched_from_client_ps_cursor  0
rows_affected_normal    0
rows_affected_ps    0
rows_skipped_normal     0
rows_skipped_ps     0
copy_on_write_saved     0
copy_on_write_performed     0
command_buffer_too_small    0
connect_success     0
connect_failure     0
connection_reused   0
reconnect   0
pconnect_success    0
active_connections  0
active_persistent_connections   0
explicit_close  0
implicit_close  0
disconnect_close    0
in_middle_of_command_close  0
explicit_free_result    0
implicit_free_result    0
explicit_stmt_close     0
implicit_stmt_close     0
mem_emalloc_count   0
mem_emalloc_amount  0
mem_ecalloc_count   0
mem_ecalloc_amount  0
mem_erealloc_count  0
mem_erealloc_amount     0
mem_efree_count     0
mem_efree_amount    0
mem_malloc_count    0
mem_malloc_amount   0
mem_calloc_count    0
mem_calloc_amount   0
mem_realloc_count   0
mem_realloc_amount  0
mem_free_count  0
mem_free_amount     0
mem_estrndup_count  0
mem_strndup_count   0
mem_estndup_count   0
mem_strdup_count    0
proto_text_fetched_null     0
proto_text_fetched_bit  0
proto_text_fetched_tinyint  0
proto_text_fetched_short    0
proto_text_fetched_int24    0
proto_text_fetched_int  0
proto_text_fetched_bigint   0
proto_text_fetched_decimal  0
proto_text_fetched_float    0
proto_text_fetched_double   0
proto_text_fetched_date     0
proto_text_fetched_year     0
proto_text_fetched_time     0
proto_text_fetched_datetime     0
proto_text_fetched_timestamp    0
proto_text_fetched_string   0
proto_text_fetched_blob     0
proto_text_fetched_enum     0
proto_text_fetched_set  0
proto_text_fetched_geometry     0
proto_text_fetched_other    0
proto_binary_fetched_null   0
proto_binary_fetched_bit    0
proto_binary_fetched_tinyint    0
proto_binary_fetched_short  0
proto_binary_fetched_int24  0
proto_binary_fetched_int    0
proto_binary_fetched_bigint     0
proto_binary_fetched_decimal    0
proto_binary_fetched_float  0
proto_binary_fetched_double     0
proto_binary_fetched_date   0
proto_binary_fetched_year   0
proto_binary_fetched_time   0
proto_binary_fetched_datetime   0
proto_binary_fetched_timestamp  0
proto_binary_fetched_string     0
proto_binary_fetched_blob   0
proto_binary_fetched_enum   0
proto_binary_fetched_set    0
proto_binary_fetched_geometry   0
proto_binary_fetched_other  0
init_command_executed_count     0
init_command_failed_count   0
com_quit    0
com_init_db     0
com_query   0
com_field_list  0
com_create_db   0
com_drop_db     0
com_refresh     0
com_shutdown    0
com_statistics  0
com_process_info    0
com_connect     0
com_process_kill    0
com_debug   0
com_ping    0
com_time    0
com_delayed_insert  0
com_change_user     0
com_binlog_dump     0
com_table_dump  0
com_connect_out     0
com_register_slave  0
com_stmt_prepare    0
com_stmt_execute    0
com_stmt_send_long_data     0
com_stmt_close  0
com_stmt_reset  0
com_stmt_set_option     0
com_stmt_fetch  0
com_deamon  0
bytes_received_real_data_normal     0
bytes_received_real_data_ps     0

odbc
ODBC Support    enabled
Active Persistent Links     0
Active Links    0
ODBC library    Win32

Directive   Local Value Master Value
odbc.allow_persistent   On  On
odbc.check_persistent   On  On
odbc.default_cursortype Static cursor   Static cursor
odbc.default_db no value    no value
odbc.default_pw no value    no value
odbc.default_user   no value    no value
odbc.defaultbinmode return as is    return as is
odbc.defaultlrl return up to 4096 bytes return up to 4096 bytes
odbc.max_links  Unlimited   Unlimited
odbc.max_persistent Unlimited   Unlimited

openssl
OpenSSL support     enabled
OpenSSL Library Version     OpenSSL 0.9.8r 8 Feb 2011
OpenSSL Header Version  OpenSSL 0.9.8r 8 Feb 2011

pcre
PCRE (Perl Compatible Regular Expressions) Support  enabled
PCRE Library Version    8.11 2010-12-10

Directive   Local Value Master Value
pcre.backtrack_limit    100000  100000
pcre.recursion_limit    100000  100000

PDO
PDO support enabled
PDO drivers     mysql, sqlite

pdo_mysql
PDO Driver for MySQL    enabled
Client API version  mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $

pdo_sqlite
PDO Driver for SQLite 3.x   enabled
SQLite Library  3.7.4

Phar
Phar: PHP Archive support   enabled
Phar EXT version    2.0.1
Phar API version    1.1.1
SVN revision    $Revision: 307915 $
Phar-based phar archives    enabled
Tar-based phar archives     enabled
ZIP-based phar archives     enabled
gzip compression    enabled
bzip2 compression   disabled (install pecl/bz2)
OpenSSL support     enabled

Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.

Directive   Local Value Master Value
phar.cache_list no value    no value
phar.readonly   On  On
phar.require_hash   On  On

Reflection
Reflection  enabled
Version     $Revision: 307971 $

session
Session Support     enabled
Registered save handlers    files user
Registered serializer handlers  php php_binary wddx

Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   Off Off
session.bug_compat_warn Off Off
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly Off Off
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   C:\Windows\temp C:\Windows\temp
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    On  On
session.use_trans_sid   0   0

SimpleXML
Simplexml support   enabled
Revision    $Revision: 308262 $
Schema support  enabled

soap
Soap Client     enabled
Soap Server     enabled

Directive   Local Value Master Value
soap.wsdl_cache 1   1
soap.wsdl_cache_dir /tmp    /tmp
soap.wsdl_cache_enabled 1   1
soap.wsdl_cache_limit   5   5
soap.wsdl_cache_ttl 86400   86400

SPL
SPL support enabled
Interfaces  Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes     AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException

standard
Dynamic Library Support     enabled
Internal Sendmail Support for Windows   enabled

Directive   Local Value Master Value
assert.active   1   1
assert.bail 0   0
assert.callback no value    no value
assert.quiet_eval   0   0
assert.warning  1   1
auto_detect_line_endings    0   0
default_socket_timeout  60  60
from    no value    no value
safe_mode_allowed_env_vars  PHP_    PHP_
safe_mode_protected_env_vars    LD_LIBRARY_PATH LD_LIBRARY_PATH
url_rewriter.tags   a=href,area=href,frame=src,input=src,form=fakeentry a=href,area=href,frame=src,input=src,form=fakeentry
user_agent  no value    no value

tidy
Tidy support    enabled
libTidy Release     25 March 2009
Extension Version   2.0 ($Id: tidy.c 306939 2011-01-01 02:19:59Z felipe $)

Directive   Local Value Master Value
tidy.clean_output   no value    no value
tidy.default_config no value    no value

tokenizer
Tokenizer Support   enabled

wddx
WDDX Support    enabled
WDDX Session Serializer     enabled

xml
XML Support     active
XML Namespace Support   active
libxml2 Version     2.7.7

xmlreader
XMLReader   enabled

xmlrpc
core library version    xmlrpc-epi v. 0.51
php extension version   0.51
author  Dan Libby
homepage    http://xmlrpc-epi.sourceforge.net
open sourced by     Epinions.com

xmlwriter
XMLWriter   enabled

zip
Zip     enabled
Extension Version   $Id: php_zip.c 308107 2011-02-07 16:20:16Z pajoye $
Zip version     1.9.1
Libzip version  0.9.0

zlib
ZLib Support    enabled
Stream Wrapper support  compress.zlib://
Stream Filter support   zlib.inflate, zlib.deflate
Compiled Version    1.2.5
Linked Version  1.2.5

Directive   Local Value Master Value
zlib.output_compression Off Off
zlib.output_compression_level   -1  -1
zlib.output_handler no value    no value

Additional Modules
Module Name

1


来源: stackexchange

问:
NoClassDefFoundError: wrong name
I wrote a java program to test RESTful web services by using Netbeans7.0.1 and it works fine there. Now I wrote the build.xml file to compile the code and when I try to run the generated .class file I always got this exception:

```<code>Exception in thread "main" java.lang.NoClassDefFoundError: ClientREST (wrong name: clientrest/ClientREST)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: ClientREST. Program will exit.
</code>```

The name and path are correct, so any thoughts why I'm getting this exception?

答:
Here is my class structure

```<code>package org.handson.basics;

public class WithoutMain {

    public static void main() {
        System.out.println("With main()...");
    }
}
</code>```

To compile this program, I had to use absolute path. So from src/main/java I ran:

```<code>javac org/handson/basics/WithoutMain.java
</code>```

Initially I tried with the below command from basics folder and it didn't work

```<code>basics % java WithoutMain
Error: Could not find or load main class WithoutMain
Caused by: java.lang.NoClassDefFoundError: org/handson/basics/WithoutMain (wrong name: WithoutMain)
</code>```

Later I went back to src\main\java folder and ran the class with relevant package structure, which worked as expected.

```<code>java % java org.handson.basics.WithoutMain
With main()...
</code>```

ContentLicense: CC BY-SA 3.0

Title: NoClassDefFoundError: wrong name

Body:
I wrote a java program to test RESTful web services by using Netbeans7.0.1 and it works fine there. Now I wrote the build.xml file to compile the code and when I try to run the generated .class file I always got this exception:

Exception in thread "main" java.lang.NoClassDefFoundError: ClientREST (wrong name: clientrest/ClientREST)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: ClientREST. Program will exit.

The name and path are correct, so any thoughts why I'm getting this exception?

Body:
Here is my class structure

package org.handson.basics;

public class WithoutMain {

    public static void main() {
        System.out.println("With main()...");
    }
}

To compile this program, I had to use absolute path. So from src/main/java I ran:

javac org/handson/basics/WithoutMain.java

Initially I tried with the below command from basics folder and it didn't work

basics % java WithoutMain
Error: Could not find or load main class WithoutMain
Caused by: java.lang.NoClassDefFoundError: org/handson/basics/WithoutMain (wrong name: WithoutMain)

Later I went back to src\main\java folder and ran the class with relevant package structure, which worked as expected.

java % java org.handson.basics.WithoutMain
With main()...

ContentLicense: CC BY-SA 4.0


问:
Does Google Apps Script Session Information Work Different for Gmail accounts vs other Workspace Domain Accounts?
I'm writing a signoff script in Google Apps Script for GSheets that allows users to select their name from a dropdown list in a cell, then if the name matches the currently active account, another function will run to lock the row etc. Everything is working perfectly on my gmail account, but when the client tries to run the script using an account managed by google but with a non-gmail domain, the email address check fails. I'm waiting on the client to send me the log info as I don't have permissions to access it in their file, but wanted to see if anyone else had run into this issue.

In the example code with modified company and username, the code does NOT work, but if I set atDomainString to "@gmail.com" and name to my gmail address and run under my account, it does.

```<code>const atDomainString = "@redactedcompany.com";
const name = "JSmith";

    function userMatchesSignature(name) {
      let user = Session.getEffectiveUser().toString().toLowerCase();
      let signUser = (name + atDomainString).toLowerCase();
      Logger.log("User: <"+user + "> vs <" + signUser +">");

      return user === signUser;
    }
</code>```

答:
Try to grab their error message to confirm what's going on. But most likely they're blocking access to the client ID. Since the scripts that try to access user data might be blocked.

Depending on the scopes you're using on your project, they might need to verify the app https://support.google.com/cloud/answer/7454865

Best practice

Create the project using a domain account instead of a free Gmail account. Because they might run into scopes issues. In their domain, they can mark the app as internal.

Body:
I'm writing a signoff script in Google Apps Script for GSheets that allows users to select their name from a dropdown list in a cell, then if the name matches the currently active account, another function will run to lock the row etc. Everything is working perfectly on my gmail account, but when the client tries to run the script using an account managed by google but with a non-gmail domain, the email address check fails. I'm waiting on the client to send me the log info as I don't have permissions to access it in their file, but wanted to see if anyone else had run into this issue.

In the example code with modified company and username, the code does NOT work, but if I set atDomainString to "@gmail.com" and name to my gmail address and run under my account, it does.

const atDomainString = "@redactedcompany.com";
const name = "JSmith";

    function userMatchesSignature(name) {
      let user = Session.getEffectiveUser().toString().toLowerCase();
      let signUser = (name + atDomainString).toLowerCase();
      Logger.log("User: <"+user + "> vs <" + signUser +">");

      return user === signUser;
    }


问:
consul deregister_critical_service_after is not woring
Hello everyone I have a healthcheck on my consul service, my goal is whenever the service is unhealthy then the consul should remove them from the service catalog.

Bellow is my config

```<code>{
  "service": {
    "name": "api",
    "tags": [ "api-tag" ],
    "port": 80
  },
  "check": {
    "id": "api_up",
    "name": "Fetch health check from local nginx",
    "http": "http://localhost/HealthCheck",
    "interval": "5s",
    "timeout": "1s",
    "deregister_critical_service_after": "15s"
  },
  "data_dir": "/consul/data",
  "retry_join": [
    "192.168.0.1",
    "192.168.0.2",
  ]
}
</code>```

Thanks for all the helps

答:
The reason the service is not being de-registered is that the check is being specified outside of the service {} block in your JSON. This makes the check a node-level check, not a service-level check.

Here's a pretty-printed version of the config you provided.

{
  "service": {
    "name": "api",
    "tags": [
      "api-tag"
    ],
    "port": 80
  },
  "check": {
    "id": "api_up",
    "name": "Fetch health check from local nginx",
    "http": "http://localhost/HealthCheck",
    "interval": "5s",
    "timeout": "1s",
    "deregister_critical_service_after": "15s"
  },
  "data_dir": "/consul/data",
  "retry_join": [
    "192.168.0.1",
    "192.168.0.2",
  ]
}
```
<p>Below is the configuration you should be using in order to correctly associate the check with the configured service, and de-register the service after the check has been marked as critical for more than 15 seconds.</p>
<pre class="lang-json prettyprint-override"><code>{
  "service": {
    "name": "api",
    "tags": [
      "api-tag"
    ],
    "port": 80,
    "check": {
      "id": "api_up",
      "name": "Fetch health check from local nginx",
      "http": "http://localhost/HealthCheck",
      "interval": "5s",
      "timeout": "1s",
      "deregister_critical_service_after": "15s"
    }
  },
  "data_dir": "/consul/data",
  "retry_join": [
    "192.168.0.1",
    "192.168.0.2"
  ]
}
</code>```

Note this statement from the docs for DeregisterCriticalServiceAfter.

If a check is in the critical state for more than this configured value, then its associated service (and all of its associated checks) will automatically be deregistered. The minimum timeout is 1 minute, and the process that reaps critical services runs every 30 seconds, so it may take slightly longer than the configured timeout to trigger the deregistration. This should generally be configured with a timeout that's much, much longer than any expected recoverable outage for the given service.

Body:
Hello everyone I have a healthcheck on my consul service, my goal is whenever the service is unhealthy then the consul should remove them from the service catalog.

Bellow is my config

{
  "service": {
    "name": "api",
    "tags": [ "api-tag" ],
    "port": 80
  },
  "check": {
    "id": "api_up",
    "name": "Fetch health check from local nginx",
    "http": "http://localhost/HealthCheck",
    "interval": "5s",
    "timeout": "1s",
    "deregister_critical_service_after": "15s"
  },
  "data_dir": "/consul/data",
  "retry_join": [
    "192.168.0.1",
    "192.168.0.2",
  ]
}

Thanks for all the helps

Body:
The reason the service is not being de-registered is that the check is being specified outside of the service {} block in your JSON. This makes the check a node-level check, not a service-level check.

Here's a pretty-printed version of the config you provided.

{
  "service": {
    "name": "api",
    "tags": [
      "api-tag"
    ],
    "port": 80
  },
  "check": {
    "id": "api_up",
    "name": "Fetch health check from local nginx",
    "http": "http://localhost/HealthCheck",
    "interval": "5s",
    "timeout": "1s",
    "deregister_critical_service_after": "15s"
  },
  "data_dir": "/consul/data",
  "retry_join": [
    "192.168.0.1",
    "192.168.0.2",
  ]
}

Below is the configuration you should be using in order to correctly associate the check with the configured service, and de-register the service after the check has been marked as critical for more than 15 seconds.

{
  "service": {
    "name": "api",
    "tags": [
      "api-tag"
    ],
    "port": 80,
    "check": {
      "id": "api_up",
      "name": "Fetch health check from local nginx",
      "http": "http://localhost/HealthCheck",
      "interval": "5s",
      "timeout": "1s",
      "deregister_critical_service_after": "15s"
    }
  },
  "data_dir": "/consul/data",
  "retry_join": [
    "192.168.0.1",
    "192.168.0.2"
  ]
}

Note this statement from the docs for DeregisterCriticalServiceAfter.

If a check is in the critical state for more than this configured value, then its associated service (and all of its associated checks) will automatically be deregistered. The minimum timeout is 1 minute, and the process that reaps critical services runs every 30 seconds, so it may take slightly longer than the configured timeout to trigger the deregistration. This should generally be configured with a timeout that's much, much longer than any expected recoverable outage for the given service.


问:
git-p4 import trees contain subdirectory .git
Our company uses Perfoce to manage projects, and I am using git-p4 to sync Perforce repository on my local side.
But on P4 repository, it is combined with many module and may contain .git folder for some module. Someone uses git on local and put the .git/ to Perforce  :(

When I clone the P4 by git-p4 clone, then it always say some files were removed.

```<code># On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    module-by-git/.git/FETCH_HEAD
#       deleted:    module-by-git/.git/HEAD
#       deleted:    module-by-git/.git/ORIG_HEAD
#       deleted:    module-by-git/.git/config
#       deleted:    module-by-git/.git/description
#       deleted:    module-by-git/.git/hooks/commit-msg
#       deleted:    module-by-git/.git/hooks/pre-auto-gc
#       deleted:    module-by-git/.git/index
#       deleted:    module-by-git/.git/info/exclude
#       deleted:    module-by-git/.git/logs/HEAD
#       deleted:    module-by-git/.git/logs/refs/remotes/m/master
</code>```

I try to use "git filter-branch" to remove these files, but it forbid to use on a dirty working directory.

How can I do to fix this problem?
In my previous workaround, I just remove these .git folders by Perforce tool, and then clone the entire project again.

答:
You can modify the git-p4 code and convert the path that contains .git dir to a
fake path replaced .git with some_fake_git dir while writing the git stream, for example:

```<code>  def writeToGitStream(self, gitMode, relPath, contents):
    fakePath = self.convertToSubGitFakePath(relPath)
    self.gitStream.write(encode_text_stream(u'M {} inline {}\n'.format(gitMode, fakePath)))
</code>```

The above method is not perfect but could keep the git records in sub directories.

ContentLicense: CC BY-SA 2.5

Body:
Our company uses Perfoce to manage projects, and I am using git-p4 to sync Perforce repository on my local side.
But on P4 repository, it is combined with many module and may contain .git folder for some module. Someone uses git on local and put the .git/ to Perforce  :(

When I clone the P4 by git-p4 clone, then it always say some files were removed.

# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    module-by-git/.git/FETCH_HEAD
#       deleted:    module-by-git/.git/HEAD
#       deleted:    module-by-git/.git/ORIG_HEAD
#       deleted:    module-by-git/.git/config
#       deleted:    module-by-git/.git/description
#       deleted:    module-by-git/.git/hooks/commit-msg
#       deleted:    module-by-git/.git/hooks/pre-auto-gc
#       deleted:    module-by-git/.git/index
#       deleted:    module-by-git/.git/info/exclude
#       deleted:    module-by-git/.git/logs/HEAD
#       deleted:    module-by-git/.git/logs/refs/remotes/m/master

I try to use "git filter-branch" to remove these files, but it forbid to use on a dirty working directory.

How can I do to fix this problem?
In my previous workaround, I just remove these .git folders by Perforce tool, and then clone the entire project again.

Body:
You can modify the git-p4 code and convert the path that contains .git dir to a
fake path replaced .git with some_fake_git dir while writing the git stream, for example:

  def writeToGitStream(self, gitMode, relPath, contents):
    fakePath = self.convertToSubGitFakePath(relPath)
    self.gitStream.write(encode_text_stream(u'M {} inline {}\n'.format(gitMode, fakePath)))

The above method is not perfect but could keep the git records in sub directories.


问:
Pass data from Javascript to a PHP File and backwards
I'm trying to pass data (JSON) from a Javascript file to a PHP file and then return something. I already tried the PHP function file_get_contents('php://input') but unfortunately its not allowed in the system I'm using. But Curl is allowed, so I'm trying do do it with cURL.

Sadly, I don't get it to work properly.

JS Code:

var data = {
    'name': 'kevin'
};
var sendable = JSON.stringify(data);
console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "http://192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        // $loggable = JSON.parse(request.responseText);
        // $name = $loggable['name'];
        console.log("RESPONSE " + (request.responseText));
    }
}

request.send(sendable);```
</div>
</div>
</p>
<p>PHP Code:</p>
```            <?php

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, 'php://input');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);

        $output = curl_exec($ch);

        if ($output === FALSE) {
            echo "cURL ERROR" . curl_error($ch);
        }
        curl_close($ch);

        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Headers: *');
        header('Access-Control-Allow-Method: POST, GET');

        echo($output);
```

答:
Your javascript looks good.
On the server side you don't want to use cURL.  CURL is for getting responses from other servers, not from a client.

Here is an example PHP script that should work with your example:

```<code><?php
header('Content-type: application/json');

$data = json_decode(file_get_contents('php://input'));

$msg =  'Hello ' . $data->name . '.  Nice to meet you.';

echo json_encode(['name' => 'david', 'msg' => $msg]);

?>
</code>```

Now in this example we are sending a JSON encoded object back in response.  I did this since you said you want to pass JSON back and forth not just a text string.  To accommodate this you have to modify your javascript slightly:

```<code>var data = {
    'name': 'kevin'
};
var sendable = JSON.stringify(data);
console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        console.log("RESPONSE: " + JSON.parse(request.responseText).msg);
    }
}

request.send(sendable);
</code>```

It looks like you will know how to take it from here, but leave a comment if you need more help.

So in the PHP script $data will contain the full data structure that was encoded into JSON and sent via POST, and in javascript you can use data = JSON.parse(request.responseText) to get all the data sent back from PHP.

Edit to add examples of using POST for systems where direct access to the file system is restricted:

According to Mozilla docs there are two ways to submit data with XMLHttpRequest: Ajax only and using the FormData API and the disadvantage of the FormData option is that the data can't be JSON (stringified with JSON.stringify()).  The advantage of the FormData API that we are interested in is that PHP will populate the $_GET, $_POST, $_REQUEST superglobals from data submitted in this way.  We can also think of an easy workaround to send JSON through the FormData API.

First example using the FormData API normally:

```<code>var data = {
    'name': 'kevin'
};
var sendable = new FormData();
for ( var key in data ) {
    sendable.append(key, data[key]);
}
console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        console.log("RESPONSE: " + JSON.parse(request.responseText).msg);
    }
}

request.send(sendable);
</code>```

sendable is now a FormData object and we append key/value pairs using the append method.  Mozilla has all the details on FormData. The problem here is that you can't send complex nested data.

note: you can create simple indexed arrays just by appending multiple values with the same key.

On the PHP side it would look like this:

```<code><?php
header('Content-type: application/json');

$msg =  'Hello ' . $_POST['name'] . '.  Nice to meet you.';

echo json_encode(['name' => 'david', 'msg' => $msg]);
?>
</code>```

To send more complex data with JSON we can do this:

```<code>var data = {
    'names': ['kevin', 'david']
};
var json_str = JSON.stringify(data);
var sendable = new FormData();
sendable.append('data', json_str);

console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        console.log("RESPONSE: " + JSON.parse(request.responseText).msg);
    }
}

request.send(sendable);
</code>```

And the corresponding PHP would look like this:

```<code><?php
header('Content-type: application/json');

$data = json_decode($_POST['data']);

$msg =  'Hello ' . $data->names[0] . '.  Nice to meet you.';

echo json_encode(['name' => 'david', 'msg' => $msg]);
?>
</code>```

Body:
I'm trying to pass data (JSON) from a Javascript file to a PHP file and then return something. I already tried the PHP function file_get_contents('php://input') but unfortunately its not allowed in the system I'm using. But Curl is allowed, so I'm trying do do it with cURL.

Sadly, I don't get it to work properly.

JS Code:

var data = {
    'name': 'kevin'
};
var sendable = JSON.stringify(data);
console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "http://192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        // $loggable = JSON.parse(request.responseText);
        // $name = $loggable['name'];
        console.log("RESPONSE " + (request.responseText));
    }
}

request.send(sendable);

PHP Code:

            <?php

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, 'php://input');
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);

        $output = curl_exec($ch);

        if ($output === FALSE) {
            echo "cURL ERROR" . curl_error($ch);
        }
        curl_close($ch);

        header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Headers: *');
        header('Access-Control-Allow-Method: POST, GET');

        echo($output);

Body:
Your javascript looks good.
On the server side you don't want to use cURL.  CURL is for getting responses from other servers, not from a client.

Here is an example PHP script that should work with your example:

<?php
header('Content-type: application/json');

$data = json_decode(file_get_contents('php://input'));

$msg =  'Hello ' . $data->name . '.  Nice to meet you.';

echo json_encode(['name' => 'david', 'msg' => $msg]);

?>

Now in this example we are sending a JSON encoded object back in response.  I did this since you said you want to pass JSON back and forth not just a text string.  To accommodate this you have to modify your javascript slightly:

var data = {
    'name': 'kevin'
};
var sendable = JSON.stringify(data);
console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        console.log("RESPONSE: " + JSON.parse(request.responseText).msg);
    }
}

request.send(sendable);

It looks like you will know how to take it from here, but leave a comment if you need more help.

So in the PHP script $data will contain the full data structure that was encoded into JSON and sent via POST, and in javascript you can use data = JSON.parse(request.responseText) to get all the data sent back from PHP.

Edit to add examples of using POST for systems where direct access to the file system is restricted:

According to Mozilla docs there are two ways to submit data with XMLHttpRequest: Ajax only and using the FormData API and the disadvantage of the FormData option is that the data can't be JSON (stringified with JSON.stringify()).  The advantage of the FormData API that we are interested in is that PHP will populate the $_GET, $_POST, $_REQUEST superglobals from data submitted in this way.  We can also think of an easy workaround to send JSON through the FormData API.

First example using the FormData API normally:

var data = {
    'name': 'kevin'
};
var sendable = new FormData();
for ( var key in data ) {
    sendable.append(key, data[key]);
}
console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        console.log("RESPONSE: " + JSON.parse(request.responseText).msg);
    }
}

request.send(sendable);

sendable is now a FormData object and we append key/value pairs using the append method.  Mozilla has all the details on FormData. The problem here is that you can't send complex nested data.

note: you can create simple indexed arrays just by appending multiple values with the same key.

On the PHP side it would look like this:

<?php
header('Content-type: application/json');

$msg =  'Hello ' . $_POST['name'] . '.  Nice to meet you.';

echo json_encode(['name' => 'david', 'msg' => $msg]);
?>

To send more complex data with JSON we can do this:

var data = {
    'names': ['kevin', 'david']
};
var json_str = JSON.stringify(data);
var sendable = new FormData();
sendable.append('data', json_str);

console.log(sendable);
var request = new XMLHttpRequest();

request.open("POST", "192.168.64.2/testJsRequest.php", true);

request.onreadystatechange = function() {
    if (request.readyState == 4 && request.status == 200) {
        console.log("RESPONSE: " + JSON.parse(request.responseText).msg);
    }
}

request.send(sendable);

And the corresponding PHP would look like this:

<?php
header('Content-type: application/json');

$data = json_decode($_POST['data']);

$msg =  'Hello ' . $data->names[0] . '.  Nice to meet you.';

echo json_encode(['name' => 'david', 'msg' => $msg]);
?>


问:
Can't run jupyter lab kernel
I am trying to run jupyter lab but the kernel is not connecting and I am not too sure the reason why. Any help will be appreciated thank you so much! This is the error I am getting:</p>
```<code>RuntimeError: This event loop is already running
[W 2022-02-11 09:54:20.931 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.931 ServerApp] Kernel c9bb27e5-56fc-4daf-9631-306d5d277217 died, removing from map.
[W 2022-02-11 09:54:20.949 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.949 ServerApp] Kernel d2ab9d87-1ddd-4cdb-a7a7-3bfaf3e91fc0 died, removing from map.
[W 2022-02-11 09:54:20.960 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.961 ServerApp] Kernel b17914dd-d148-4d22-af26-f1a0a9f6149e died, removing from map.
[W 2022-02-11 09:54:20.972 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.972 ServerApp] Kernel b37ce6bf-f2cb-428d-8188-f6b41ab3309e died, removing from map.
[W 2022-02-11 09:55:05.901 ServerApp] Timeout waiting for kernel_info reply from b37ce6bf-f2cb-428d-8188-f6b41ab3309e
[E 2022-02-11 09:55:05.904 ServerApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: b37ce6bf-f2cb-428d-8188-f6b41ab3309e)
[W 2022-02-11 09:55:06.196 ServerApp] Timeout waiting for kernel_info reply from c9bb27e5-56fc-4daf-9631-306d5d277217
[E 2022-02-11 09:55:06.197 ServerApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: c9bb27e5-56fc-4daf-9631-306d5d277217)

</code>```

答:
If you are using Anaconda to run Python then this post might be useful ...

http://www.techanswersweb.com/kernel-error-jupyter-notebook

Title: Can't run jupyter lab kernel

Body:
I am trying to run jupyter lab but the kernel is not connecting and I am not too sure the reason why. Any help will be appreciated thank you so much! This is the error I am getting:

RuntimeError: This event loop is already running
[W 2022-02-11 09:54:20.931 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.931 ServerApp] Kernel c9bb27e5-56fc-4daf-9631-306d5d277217 died, removing from map.
[W 2022-02-11 09:54:20.949 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.949 ServerApp] Kernel d2ab9d87-1ddd-4cdb-a7a7-3bfaf3e91fc0 died, removing from map.
[W 2022-02-11 09:54:20.960 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.961 ServerApp] Kernel b17914dd-d148-4d22-af26-f1a0a9f6149e died, removing from map.
[W 2022-02-11 09:54:20.972 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2022-02-11 09:54:20.972 ServerApp] Kernel b37ce6bf-f2cb-428d-8188-f6b41ab3309e died, removing from map.
[W 2022-02-11 09:55:05.901 ServerApp] Timeout waiting for kernel_info reply from b37ce6bf-f2cb-428d-8188-f6b41ab3309e
[E 2022-02-11 09:55:05.904 ServerApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: b37ce6bf-f2cb-428d-8188-f6b41ab3309e)
[W 2022-02-11 09:55:06.196 ServerApp] Timeout waiting for kernel_info reply from c9bb27e5-56fc-4daf-9631-306d5d277217
[E 2022-02-11 09:55:06.197 ServerApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: c9bb27e5-56fc-4daf-9631-306d5d277217)


问:
I can't center align my image border radius with the text
How to center text with the image having border-radius of 50%, horizontally.

Below is the code:

```<code><div>
<img src="images/kristen.png" alt=""  class="box">
<span>Kristen Wu</span>
</code>```

```<code>.box{
border-radius: 50%;
display: flex;
height: 40px;
align-items: center;
text-align: center;
margin-top: 20px;
}
</code>```

答:
Can you upload an image of what the expected outcome should look like?

To center the image within your div tag, you can achieve this by applying:margin: 0 auto; in your .box class.

This is equivalent to the following:

```<code>margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
</code>```

Basically centering your image horizontally.

Body:
How to center text with the image having border-radius of 50%, horizontally.

Below is the code:

Kristen Wu

.box{
border-radius: 50%;
display: flex;
height: 40px;
align-items: center;
text-align: center;
margin-top: 20px;
}

Body:
Can you upload an image of what the expected outcome should look like?

To center the image within your div tag, you can achieve this by applying:margin: 0 auto; in your .box class.

This is equivalent to the following:

margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;

Basically centering your image horizontally.


问:
multiple arguments in sqflite flutter
I want to search database based on the keyword. if it title or content contains the keyword then return the data. but it send backs nothing.

```<code>
  static Future<List<Note>> searchDocuments(String? keyword) async {
    final database = await DatabaseHelper.database();

    List<Map<String, dynamic>> allDocuments = await database.rawQuery(
        'SELECT * FROM docs WHERE title=? and content=?',
        ['$keyword%', '$keyword%']);

</code>```

checked - doesn't work.

答:
This works.</p>
```<code>await database.rawQuery(
        'SELECT * FROM docs WHERE title LIKE ? OR content LIKE ?',
        ['%$keyword%', '%$keyword%']);

</code>```

Title: multiple arguments in sqflite flutter

Body:
I want to search database based on the keyword. if it title or content contains the keyword then return the data. but it send backs nothing.

  static Future<List<Note>> searchDocuments(String? keyword) async {
    final database = await DatabaseHelper.database();

    List<Map<String, dynamic>> allDocuments = await database.rawQuery(
        'SELECT * FROM docs WHERE title=? and content=?',
        ['$keyword%', '$keyword%']);

checked - doesn't work.

Body:
This works.

await database.rawQuery(
        'SELECT * FROM docs WHERE title LIKE ? OR content LIKE ?',
        ['%$keyword%', '%$keyword%']);


问:
KMeans - OverflowError: cannot convert float infinity to integer
Below are the top 5 rows of the variables, I am using for the KMeans to find the optimal no of clusters-

```<code>store_code  PinCode sale_price_after_promo
0   2655    453441.0    55.00
1   2655    999999.0    30.00
2   2655    400064.0    418.95
3   2615    400099.0    70.00
4   2655    474001.0    34.20
</code>```

This is the error I am getting -

```<code>OverflowError                             Traceback (most recent call last)
<ipython-input-62-3802a2b79f71> in <module>()
      2 for i in range(0,11):
      3     kmeans=KMeans(n_clusters=i, init='k-means++', random_state=42)
----> 4     kmeans.fit(X)
      5     wcss.append(kmeans.inertia_)
      6 plt.plot(range(1, 11), wcss)

OverflowError: cannot convert float infinity to integer
</code>```

How to get rid of this error even I have tried using various combinations of variables but still getting the same error?

答:
I tried for i in range(1,11): but still it did not run properly. But instead mine was solved by using

```<code>for i in range(1,12):
</code>```

Body:
Below are the top 5 rows of the variables, I am using for the KMeans to find the optimal no of clusters-

store_code  PinCode sale_price_after_promo
0   2655    453441.0    55.00
1   2655    999999.0    30.00
2   2655    400064.0    418.95
3   2615    400099.0    70.00
4   2655    474001.0    34.20

This is the error I am getting -

OverflowError                             Traceback (most recent call last)
<ipython-input-62-3802a2b79f71> in <module>()
      2 for i in range(0,11):
      3     kmeans=KMeans(n_clusters=i, init='k-means++', random_state=42)
----> 4     kmeans.fit(X)
      5     wcss.append(kmeans.inertia_)
      6 plt.plot(range(1, 11), wcss)

OverflowError: cannot convert float infinity to integer

How to get rid of this error even I have tried using various combinations of variables but still getting the same error?

Body:
I tried for i in range(1,11): but still it did not run properly. But instead mine was solved by using

for i in range(1,12):


问:
Node Subpath Imports External Directory
In Vite/WebPack, we can define path aliases fairly easily, and we can even use the @ to define these.  However, in an ESM Node app, it's not as easy.  There's module-alias, but it's a little outdated, and doesn't work for ESM packages.  All of this led me to Subpath Imports.

Subpath Imports seem to work just fine (except I can't use @ instead of #) with files/directories in the package.json's directory, but it doesn't seems to work with directories outside.  e.g. this is my imports config in package.json:

```<code>"imports": {
  "#api/*": "./*",
  "#shared/*": "../shared/*"
}
</code>```

The #api works properly, but the #shared does not.  Is there some sort of extra config that I'm unaware of, or is this not possible with Subpath Imports?  I know the docs say it is possible to define internal package import maps that only apply to import specifiers from within the package itself, so if it's not possible, what are my alternatives?

答:
I think I found a solution that works a little better.  I'm using an npm workspace, which actually allows me to use the workspaces as if they're absolute paths.  My directory structure is as follows:

```<code>root/
  api/
    app.js
    package.json
  shared/
    test.js
    package.json
  ui/
    package.json
  package.json
</code>```

In the root package.json, I have specified the workspaces config to be the following:

```<code>"workspaces": [
  "ui",
  "api",
  "shared"
]
</code>```

And then in app.js, I can reference something from shared like import test from "shared/test.js".  I didn't realize this added benefit of workspaces, but it definitely solves the issue I was having.

Title: Node Subpath Imports External Directory

Body:
In Vite/WebPack, we can define path aliases fairly easily, and we can even use the @ to define these.  However, in an ESM Node app, it's not as easy.  There's module-alias, but it's a little outdated, and doesn't work for ESM packages.  All of this led me to Subpath Imports.

Subpath Imports seem to work just fine (except I can't use @ instead of #) with files/directories in the package.json's directory, but it doesn't seems to work with directories outside.  e.g. this is my imports config in package.json:

"imports": {
  "#api/*": "./*",
  "#shared/*": "../shared/*"
}

The #api works properly, but the #shared does not.  Is there some sort of extra config that I'm unaware of, or is this not possible with Subpath Imports?  I know the docs say it is possible to define internal package import maps that only apply to import specifiers from within the package itself, so if it's not possible, what are my alternatives?

Body:
I think I found a solution that works a little better.  I'm using an npm workspace, which actually allows me to use the workspaces as if they're absolute paths.  My directory structure is as follows:

root/
  api/
    app.js
    package.json
  shared/
    test.js
    package.json
  ui/
    package.json
  package.json

In the root package.json, I have specified the workspaces config to be the following:

"workspaces": [
  "ui",
  "api",
  "shared"
]

And then in app.js, I can reference something from shared like import test from "shared/test.js".  I didn't realize this added benefit of workspaces, but it definitely solves the issue I was having.


问:
How to update matplotlib's imshow() window interactively?
I'm working on some computer vision algorithm and I'd like to show how a numpy array changes in each step.

What works now is that if I have a simple imshow( array ) at the end of my code, the window displays and shows the final image.

However what I'd like to do is to update and display the imshow window as the image changes in each iteration.

So for example I'd like to do:

```<code>import numpy as np
import matplotlib.pyplot as plt
import time

array = np.zeros( (100, 100), np.uint8 )

for i in xrange( 0, 100 ):
    for j in xrange( 0, 50 ):
        array[j, i] = 1

        #_show_updated_window_briefly_
        plt.imshow( array )
        time.sleep(0.1)
</code>```

The problem is that this way, the Matplotlib window doesn't get activated, only once the whole computation is finished.

I've tried both native matplotlib and pyplot, but the results are the same. For plotting commands I found an .ion() switch, but here it doesn't seem to work.

Q1. What is the best way to continuously display updates to a numpy array (actually a uint8 greyscale image)?

Q2. Is it possible to do this with an animation function, like in the dynamic image example? I'd like to call a function inside a loop, thus I don't know how to achieve this with an animation function.

答:
I had a similar problem - want to update image, don't want to repeatedly replace the axes, but plt.imshow() (nor ax.imshow()) was not updating the figure displayed.

I finally discovered that some form of draw() was required. But fig.canvas.draw(), ax.draw() ... all did not work. I finally found the solution here:

```<code>%matplotlib notebook  #If using Jupyter Notebook
import matplotlib.pyplot as plt
import numpy as np

imData    = np.array([[1,3],[3,1]])

  # Setup and plot image
fig = plt.figure()
ax  = plt.subplot(111)
im  = ax.imshow(imData)

  # Change image contents
newImData = np.array([[2,2],[2,2]])
im.set_data( newImData )
im.draw()
</code>```

Body:
I'm working on some computer vision algorithm and I'd like to show how a numpy array changes in each step.

What works now is that if I have a simple imshow( array ) at the end of my code, the window displays and shows the final image.

However what I'd like to do is to update and display the imshow window as the image changes in each iteration.

So for example I'd like to do:

import numpy as np
import matplotlib.pyplot as plt
import time

array = np.zeros( (100, 100), np.uint8 )

for i in xrange( 0, 100 ):
    for j in xrange( 0, 50 ):
        array[j, i] = 1

        #_show_updated_window_briefly_
        plt.imshow( array )
        time.sleep(0.1)

The problem is that this way, the Matplotlib window doesn't get activated, only once the whole computation is finished.

I've tried both native matplotlib and pyplot, but the results are the same. For plotting commands I found an .ion() switch, but here it doesn't seem to work.

Q1. What is the best way to continuously display updates to a numpy array (actually a uint8 greyscale image)?

Q2. Is it possible to do this with an animation function, like in the dynamic image example? I'd like to call a function inside a loop, thus I don't know how to achieve this with an animation function.

Body:
I had a similar problem - want to update image, don't want to repeatedly replace the axes, but plt.imshow() (nor ax.imshow()) was not updating the figure displayed.

I finally discovered that some form of draw() was required. But fig.canvas.draw(), ax.draw() ... all did not work. I finally found the solution here:

%matplotlib notebook  #If using Jupyter Notebook
import matplotlib.pyplot as plt
import numpy as np

imData    = np.array([[1,3],[3,1]])

  # Setup and plot image
fig = plt.figure()
ax  = plt.subplot(111)
im  = ax.imshow(imData)

  # Change image contents
newImData = np.array([[2,2],[2,2]])
im.set_data( newImData )
im.draw()


答:
I'm sorry if my answer is not right, because i catch your mean is to make align center. Maybe it can help

<!DOCTYPE html>

<title>Web Page Design</title>

Kristen Wu

```

Title: I can't center align my image border radius with the text

Body:
I'm sorry if my answer is not right, because i catch your mean is to make align center. Maybe it can help

<!DOCTYPE html>
<html>
<title>Web Page Design</title>
<head>
<style type="text/css">
div
{
   width:100px;
   height:75px;
   background-color:red;
   border:1px solid black;
}
#div2
{
   transform:rotate(30deg);
   -ms-transform:rotate(30deg); /* IE 9 */
   -moz-transform:rotate(30deg); /* Firefox */
   -webkit-transform:rotate(30deg); /* Safari and Chrome */
   -o-transform:rotate(30deg); /* Opera */
   background-color:yellow;
}
.box{
border-radius: 50%;
display: flex;
height: 40px;
align-items: center;
text-align: center;
margin-top: 20px;
}
.wrapper{
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin-top: 20px;
}
</style>
</head>
<body>
<div class = "wrapper">
<img src="images/kristen.png" alt=""  class="box">
<span>Kristen Wu</span> </div>

</body>
</html>


问:
How does Swagger achieve the same route but different query parameters?
I created an asp.net core web api project, using the .net5 version, and I have a route like this.

```<code>[Route("api/detail")]
public IEnumerable<User> Get()
{
       //TODO
    return users;
}

[Route("api/detail")]
public IEnumerable<User> Get(string name)
{
        //TODO
    return users;
}
</code>```

Although my request method is the same and the request parameters are different, the 500 error will be reported in swagger. Is there any way to solve it? Any help is greatly appreciated.

答:
There could be multiple reasons why you're getting a 500 error. When I pasted your code into a new controller the first is error I received was:

Ambiguous HTTP method for action... Actions require an explicit HttpMethod binding for Swagger

It's telling you that you need to decorate each action in the controller with an HttpMethod binding, like [HttpGet]. More on that in a second...

The next issue is that you're using [Route] to bind two different action methods to the exact same route with the same HttpMethod. That's not possible in an API controller.

Conflicting method/path combination... Actions require a unique
method/path combination for Swagger

My preferred method for routing is to use Attribute routing with Http verb attributes.

The first step would be to move the route attribute to the controller. I'm going to assume you've created a DetailsController:

[Route("api/[controller]")]
[ApiController]
public class DetailsController : ControllerBase { }
```
<p>Now, update your actions. Remove the <code>[Route]</code> attribute, replace with the <code>HttpGet</code> attribute, and add the <code>name</code> parameter to your second endpoint. I also prefer to return an <code>IActionResult</code>:</p>
<pre class="lang-cs prettyprint-override"><code>[HttpGet]
public IActionResult Get()
{
    //TODO
    return Ok(users);
}

[HttpGet("{name}")]
public IActionResult Get(string name)
{
    //TODO
    return Ok(users);
}
</code>```

Note that parameters are identified by using curly braces around the variable {name} in the Http method attribute. Both endpoints work and are accessible through swagger. I urge you to read the linked page above for a better understanding of the possible routing options (linked again).

Body:
I created an asp.net core web api project, using the .net5 version, and I have a route like this.

[Route("api/detail")]
public IEnumerable<User> Get()
{
       //TODO
    return users;
}

[Route("api/detail")]
public IEnumerable<User> Get(string name)
{
        //TODO
    return users;
}

Although my request method is the same and the request parameters are different, the 500 error will be reported in swagger. Is there any way to solve it? Any help is greatly appreciated.

Body:
There could be multiple reasons why you're getting a 500 error. When I pasted your code into a new controller the first is error I received was:

Ambiguous HTTP method for action... Actions require an explicit HttpMethod binding for Swagger

It's telling you that you need to decorate each action in the controller with an HttpMethod binding, like [HttpGet]. More on that in a second...

The next issue is that you're using [Route] to bind two different action methods to the exact same route with the same HttpMethod. That's not possible in an API controller.

Conflicting method/path combination... Actions require a unique
method/path combination for Swagger

My preferred method for routing is to use Attribute routing with Http verb attributes.

The first step would be to move the route attribute to the controller. I'm going to assume you've created a DetailsController:

[Route("api/[controller]")]
[ApiController]
public class DetailsController : ControllerBase { }

Now, update your actions. Remove the [Route] attribute, replace with the HttpGet attribute, and add the name parameter to your second endpoint. I also prefer to return an IActionResult:

[HttpGet]
public IActionResult Get()
{
    //TODO
    return Ok(users);
}

[HttpGet("{name}")]
public IActionResult Get(string name)
{
    //TODO
    return Ok(users);
}

Note that parameters are identified by using curly braces around the variable {name} in the Http method attribute. Both endpoints work and are accessible through swagger. I urge you to read the linked page above for a better understanding of the possible routing options (linked again).


问:
Countdown timers and images in Xamarin.Forms
I have a question about countdown timers and images in Xamarin.Forms I am hoping you can help me with.

I have set up a timer which counts down from 5 to 0 and repeats at 0 with new text and image through a series. The issue I am having is that the image blinks with each count down number. I understand that the screen is refreshing but is there a way to stop the refresh of the image each second?

```<code>Device.StartTimer(TimeSpan.FromSeconds(1), () =>
        {
            _countSeconds--;

            if (_countSeconds == 0)
            {
                ndx++;
                _countSeconds = 5;
            };

            if (ndx < DailyT.Count && ndx >= 0)
            {
                BindingContext = DailyT[ndx];
                MyImage.Source = ImageSource.FromResource(DailyT[ndx].ImageA, typeof(BGLongsword).GetTypeInfo().Assembly);

                //ISSUE: Image blinks each count down second
            }
            else
            {
                return false;
            }

            CountLabel.Text = _countSeconds.ToString();

            return true;
        });
</code>```

答:
you only need to update the image when ndx changes

```<code>        if (_countSeconds == 0)
        {
            ndx++;
            _countSeconds = 5;

            if (ndx < DailyT.Count && ndx >= 0)
            {
               MyImage.Source = ImageSource.FromResource(DailyT[ndx].ImageA, typeof(BGLongsword).GetTypeInfo().Assembly);
            }
            else
            {
               return false;
            }
        };

</code>```

Body:
I have a question about countdown timers and images in Xamarin.Forms I am hoping you can help me with.

I have set up a timer which counts down from 5 to 0 and repeats at 0 with new text and image through a series. The issue I am having is that the image blinks with each count down number. I understand that the screen is refreshing but is there a way to stop the refresh of the image each second?

Device.StartTimer(TimeSpan.FromSeconds(1), () =>
        {
            _countSeconds--;

            if (_countSeconds == 0)
            {
                ndx++;
                _countSeconds = 5;
            };

            if (ndx < DailyT.Count && ndx >= 0)
            {
                BindingContext = DailyT[ndx];
                MyImage.Source = ImageSource.FromResource(DailyT[ndx].ImageA, typeof(BGLongsword).GetTypeInfo().Assembly);

                //ISSUE: Image blinks each count down second
            }
            else
            {
                return false;
            }

            CountLabel.Text = _countSeconds.ToString();

            return true;
        });

Body:
you only need to update the image when ndx changes

        if (_countSeconds == 0)
        {
            ndx++;
            _countSeconds = 5;

            if (ndx < DailyT.Count && ndx >= 0)
            {
               MyImage.Source = ImageSource.FromResource(DailyT[ndx].ImageA, typeof(BGLongsword).GetTypeInfo().Assembly);
            }
            else
            {
               return false;
            }
        };


问:
How to pass html textbox value to a javascript function
I have a HTML textbox where user will input some string which i want to pass to a JavaScript function:

```<code><input type="text" id="ad_search_query" style="width:295px">
<input type="button" value="<s:text name="button.search"/>" class="p-userButton"
 onClick="ADSEARCHGF.showTable('');"/>
</code>```

Please suggest how can i do it.

答:
If the event is raised by the button, you will not have the text input object to pass to the function without getting it first, getting it by id is the best way.

You can use the id of the text box:

```<code>var searchValue = document.getElementById('ad_search_query').value;
</code>```

in your function, or use Ahsan Rathod's method to use this code as parameter.

Body:
I have a HTML textbox where user will input some string which i want to pass to a JavaScript function:

<input type="text" id="ad_search_query" style="width:295px">
<input type="button" value="<s:text name="button.search"/>" class="p-userButton"
 onClick="ADSEARCHGF.showTable('');"/>

Please suggest how can i do it.

Body:
If the event is raised by the button, you will not have the text input object to pass to the function without getting it first, getting it by id is the best way.

You can use the id of the text box:

var searchValue = document.getElementById('ad_search_query').value;

in your function, or use Ahsan Rathod's method to use this code as parameter.


问:
SVG with 'svg' element embedded
I've a problem with a complicated SVG image.

It works on Chrome and Firefox, but there is no way to convert it into a PNG image even using an online tool or GIMP and also with Inkscape.

I'm not sure where the problem is. Maybe because is it an image built with two other SVG images embedded.

Here is the SVG file.

To reproduce the problem: open the SVG file linked with a browser: it works.

Open it with GIMP and the image is empty.

An easier example with the same problem:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">

  <defs>
      <svg id="pippo" viewBox="0 0 10 10" >
      <circle id="myCircle" cx="5" cy="5" r="5" />
    </svg>

    <linearGradient id="myGradient" gradientTransform="rotate(90)">
      <stop offset="20%" stop-color="gold" />
      <stop offset="90%" stop-color="red" />
    </linearGradient>
  </defs>

  <rect height="100%" width="100%" fill="#fc0" />

  <use x="0" y="0" href="#pippo" fill="url('#myGradient')" />
</svg>```

答:
Workaround: SVG to PDF via the native browser feature "save to PDF" (print modal)

Since Firefox, Chromium, and WebKit have powerful built-in PDF export functionalities combined with way better SVG support than any "desktop" application, we can convert complex SVG images to a flattened, 'visually hardwired' vector file.

Ideal result

all vector data is retained (can also be opened in a vector application like Inkscape, Adobe Illustrator, Figma, etc.)

complexities like nested SVG images or <use> elements as well as transforms are repositioned to hardcoded vector x/y coordinates.

... but curb your enthusiasm: common issues

patterns and some complex gradients might be rasterized

you will lose structural data like layers, IDs and other editable features.

Manual SVG export optimisations

as @Yukulélé already pointed out: some syntax conventions and newer attributes might be too progressive

try to replace CSS-based styling with attributes – svgomg can be helpful

reusable elements defined in <defs> or as <symbols> might have quirky recursive dependencies

try to clean up unnecessary or invalid properties (e.g., hexadecimal RGBA) and fix incomplete SVG nestings (missing end tags)

document dimensions and aspect ratios can often be better retained (by a graphic application),
when the parent SVG element was added a viewBox and width/height attributes (at least in Adobe Illustrator)

Title: SVG with 'svg' element embedded