Tag: PHP

If setting charset using meta tag doesn’t seem to work

Been busy those days. But when I came across this problem I couldn’t resist not writing about it because I definitely had it before but always left unresolved … now, finally I know how to solve it 🙂

1. If your file encoding is definitely UTF-8

2. If you definitely have the right version of META tag, that is: <meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″> (note that you don’t necessarily need to close this tag… )

3. If browser still shows page in some encoding but not UTF-8 (by checking in View->Character Encoding menu in a browser)

It means there is only 1 place left to look for, it’s in WebServer 🙂

Solution is simple, while page is being served WebServer, apparently, notifies web browser about what is coming in page headers (you can check it using Firebug)… and in my case it was windows-1251 (Russian). Hence, you will need to modify what your WebServer sends in headers.There are 2 solutions for this:

1. Change settings of your WebServer

2. Change the charset of the page dynamically when it is being served (which is more viable, because usually we don’t have access to the WebServer settings…. or we don’t want to change those settings not to break something else)

Ex: In PHP this is done using “header” function (this should be called before anything else) as follows:

<?php header(‘Content-type: text/html; charset=utf-8’);?>

Web services server on PHP

The easiest and the most portable solution for a web service server is a NuSOAP library.
It’s VERY useful when one has nothing but an FTP access to a remote hosting website.
All you need is just copy-paste the library and it works.

So… let’s proceed to create the simplest web server script.
It will just accept String value and return String value (that is modified based on the accepted value).

1. Create a folder named “soap_test” (or whatever …) within your remote website.
Copy-paste “lib” into that folder and rename it to “soap_lib” (or whatever…).
“Lib” is taken from here:
http://sourceforge.net/project/showfiles.php?group_id=57663
(don’t worry, there is just one lib, so you shouldn’t miss it)

2. Within the “soap_test” folder create the file named server.php (again, or whatever you want) and start coding:

3. Include the library and a namespace:
require_once(“soap_lib/nusoap.php”);
$namespace=”http://www.examplesite.com/soap_test“;

4. Some settings:
$server = new soap_server();
$server->configureWSDL(“soap_test”, $namespace);
$server->wsdl->schemaTargetNamespace = $namespace;

5. Declare the function and describe what (arguments) it will accept and return:
$server->register(‘ReturnConfirmNumber’,
array(‘amount’ => ‘xsd:string’),
array(‘return’ => ‘xsd:string’),
$namespace);

6. Write the function itself:
function ReturnConfirmNumber($amount){
$result=$amount . “_this_was_appended_by_server!”;
return new soapval(‘return’,’xsd:string’,$result);
}

7. Finally make a lazy server do what it was born for:
$server->service($HTTP_RAW_POST_DATA);
?>

8. Now time to test it, go to:
http://www.examplesite.com/soap_test/server.php?wsdl

Here you should see some XML file guts… if you see them! You are done!
Congratulations! … let’s go further >>>

To accept more input parameters add value pairs within the first array and separate them by comma.
Ex:
array(‘name’ => ‘xsd:string’, ‘company’ => ‘xsd:string’, ‘initialname’ => ‘xsd:string’ ),

Sources used:
http://webservices.xml.com/lpt/a/1388

To consume web services in ASP.NET refer to “web programming” -> ASP (.NET) -> Web services client on VB.NET

How to install PHP on Windows

Installing PHP >= 4.3.1 & 4.1 on Windows 2000 IIS Server

Windows PHP Installation (from the WebSite)

1)       Download the full PHP windows binaries from http://www.php.net. Do NOT use the small installer. Extract the ZIP to c:\php\.
2)       Copy the php.ini-recommended to c:\winnt\php.ini.
3)       Copy php.exe, php4ts.dll, & php4ts.lib to c:\winnt\system32.
4)       Copy the entire contents of c:\php\dlls to c:\winnt\system32.
5)       In IIS, add PHP as an application mapping .php to “c:\php\php.exe %s %s” (minus the quotes, and note the double %s).
6)       Be sure your IIS user (I_USR_xxxxx) has read and execute privileges on c:\php\ and all subfolders.
7)       Edit your c:\winnt\php.ini and be sure the following line is in it.

cgi.force_redirect = 0

MY OWN METHOD:

1. Download binary… the bigger file
2. copy paste php.ini to C:/windows
– must change : extension_dir = “C:\php\extensions\”
– might change: include_path = “.;c:\php\includes”
– might change: extension=php_curl.dll (remove ; in front of line)
3. copy php4ts.lib, php4ts.dll, php.exe to windows\system32
4. copy all files withing dlls into windows\system32
5. make sure php directory has access to “I_USR xxx” enabled
6. in IIS, computer name->properties->Internet Information Services-> WWWService-> Edit
– home page-> settings->add .php (c:\php\isapi\php4isapi.dll)
– Isapi FIlters-> add-> PHP (c:\php\isapi\php4isapi.dll)
7. might do : make necessary directory Public Website..

8. test… <? phpinfo();?>

also check this:

How To Install PHP on IIS 6.0

http://www.webpronews.com/expertarticles/2006/06/19/installing-php-on-iis-windows-xp-pro
http://www.php.net/install.windows

Installing PHP >= 4.3.1 & 4.1 on Windows 2000 IIS Server

 

Windows PHP Installation (from the WebSite)

 

1)       Download the full PHP windows binaries from http://www.php.net. Do NOT use the small installer. Extract the ZIP to c:\php\.

2)       Copy the php.ini-recommended to c:\winnt\php.ini.

3)       Copy php.exe, php4ts.dll, & php4ts.lib to c:\winnt\system32.

4)       Copy the entire contents of c:\php\dlls to c:\winnt\system32.

5)       In IIS, add PHP as an application mapping .php to “c:\php\php.exe %s %s” (minus the quotes, and note the double %s).

6)       Be sure your IIS user (I_USR_xxxxx) has read and execute privileges on c:\php\ and all subfolders.

7)       Edit your c:\winnt\php.ini and be sure the following line is in it.

 

cgi.force_redirect = 0

 

MY OWN METHOD:

 

1. Download binary… the bigger file

2. copy paste php.ini to C:/windows

– must change : extension_dir = “C:\php\extensions\”

– might change: include_path = “.;c:\php\includes”

– might change: extension=php_curl.dll (remove ; in front of line)

3. copy php4ts.lib, php4ts.dll, php.exe to windows\system32

4. copy all files withing dlls into windows\system32

5. make sure php directory has access to “I_USR xxx” enabled

6. in IIS, computer name->properties->Internet Information Services-> WWWService-> Edit

– home page-> settings->add .php (c:\php\isapi\php4isapi.dll)

– Isapi FIlters-> add-> PHP (c:\php\isapi\php4isapi.dll)

7. might do : make necessary directory Public Website..

 

8. test… <? phpinfo();?>

 

also check this:

http://www.iisadmin.co.uk/?p=4

http://www.webpronews.com/expertarticles/2006/06/19/installing-php-on-iis-windows-xp-pro

http://www.php.net/install.windows

 

PHP does not connect to MSSQL 2005 (but mssql_connect works)

Error:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: NOMADS_TOSHIBA\MSSQL2005 in C:\WebServers\home\localhost\www\salarymanager\includes\system\db.inc.php on line 20

Solution:

Download file: how_to_make_PHP_work_with_MSSQL.rar (couldn’t upload file here, please email me, I will send them)

Microsoft SQL Server 2005 and Vista.

The following steps enabled MSSQL 2005 support on Vista Home Permium.
(native drivers, not odbc which works out-of-the-box)

1) Place ntwdblib.dll in C:\Windows\System32
2) Place php_mssql.dll in C:\Windows\System32
(I gave IUSR full access to these files, maybe read is enough)

3) uncomment php_mssql.dll in php.ini

4) Changed my default SQLSERVER 2005 install so it accepts named pipes.
start -> Sql server surface area configuration ->
surface area configuration for services and connections->
MSSQLXXX-> database engine -> remote connections -> using both TCP/IP and named pipes

5) reboot.

After that I could use the mssql_* functions.

Hope that helps. I guess same applies to Windows 7