Category Archives: PHP

PHP

Warning: Cannot modify header information – headers already sent by ..

error message:

Warning: Cannot modify header information – headers already sent by (output started at C:\…\…\…\…\filexpto.php:1) in C:\…\…\…\…\….php on line xx

 

resolution:

open file filexpto.php and add ob_start(); like

 
<?php
ob_start();
....

 

ob_startTurn on output buffering

This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

 
more in:
http://www.php.net/manual/en/function.ob-start.php
 

PHP

Geotargeting database

Source link: http://ekstreme.com/geotargeting/flags-comments.php

Requirements

  • A database of worldwide IP addresses. (I’ll show you where to get one in a second.)
  • A database, like MySQL, and a server-side programming language, like PHP. The examples in this tutorial are PHP/MySQL based, but any combination should work.
  • Optionally, a set of country flags – again, I’ll show where you get them.

Geo IP database: setup

The first thing you need is a database of world wide IP addresses. A freely available one is MaxMind’s GeoLite Country Database. Download the CSV version, not the binary format version.

A note about the database:

  • It is updated once a month, so you can (and should) update your copy frequently.
  • It is claimed to be 97% accurate. This is sufficient for most users, but if you want a more accurate version, download the MaxMind GeoIP Country Database version, which is not free.

Once you download the IP database in CSV format, you need to upload it into your MySQL database. Here are the instructions:

  • Create a new table in your database; call it IPCountries.
  • In the IPCountries table, create 6 (six) new fields.
  • The fields are:
    Field Type
    IP_START VARCHAR, length 50
    IP_END VARCHAR, length 50
    IP_FROM Double
    IP_TO Double
    COUNTRY_CODE2 Char, length 2
    COUNTRY_NAME VARCHAR, length 50
  • Import the CSV file into the MySQL table. If you are using phpMyAdmin, at the very bottom of the table view is a link that says ‘Insert data from a text file into the table’. Click that and then make sure the settings are the following:
    Setting Value
    Fields terminated by , (a comma)
    Fields enclosed by ” (a double-quote)
    Lines terminated by \n (a linefeed)

    read more »

IIS PHP

PHP5 with IIS6 on Windows Server 2003

How to install and configure PHP5 with IIS6 on Windows Server 2003 in five easy steps.

read more »

Apache MySQL PHP

Instalando Apache + MySQL + PHP 5 no Windows

1. Download dos itens necessários
Primeiro, faça o download dos programas a serem usados.

Quanto ao Apache, usaremos o Apache 1.3.*, visto que na documentação do PHP existe a seguinte recomendação: “Não use Apache 2.0 e PHP em um sistema de produção, seja no Unix ou no Windows” (http://www.php.net/manual/pt_BR/install.apache2.php).

Apache: http://httpd.apache.org/download.cgi
MySQL: http://dev.mysql.com/downloads/
PHP: http://www.php.net/downloads.php

2. Instalação
– Execute a instalação do Apache e o instale com as configurações padrões. Se quiser, pode escolher outro diretório para a instalação.
РExtraia o MySQL em uma pasta qualquer. Recomendo dentro da pasta onde voc̻ instalou o Apache. Ex: C:\Arquivos de Programas\Apache Group\Apache\mysql
– Extraia o PHP 5 na pasta C:\php5

3. Configuração do PHP
Vá para a pasta c:\php5 e copie o arquivo php5ts.dll para a seguinte pasta, de acordo com o seu Windows:
– c:\windows\system (em Windows 9x/Me)
– c:\windows\system32 (em WindowsXP)
– c:\winnt\system32 (para Windows NT/2000)

Copie também o arquivo c:\php5\libmysql.dll para umas das pastas ditas acima, de acordo com o Windows em uso. Esse arquivo é necessário para o funcionamento do MySQL no PHP.Ainda no c:\php5, renomeie o arquivo “php.ini-dist” para “php.ini” e abra-o. Procure a linha extension_dir = “./” e a altere para extension_dir = “c:/php5/ext/”, é o diretório onde ficam as extensões do php (MySQL, Curl, GD, etc). Agora, localize a linha ;extension=php_mysql.dll e tire o ; do início dela. Se quiser também, já aproveite e faça o mesmo na linha ;extension=php_gd2.dll, caso queira a biblioteca GD para a manipulação de imagens.

Salve as alterações e mova o “php.ini” para a pasta:
– c:\windows (em Windows 9x/Me/XP)
– c:\winnt (para Windows NT/2000)

4. Configuração do Apache
Vá para a pasta onde você instalou o Apache e abra o arquivo conf/httpd.conf em qualquer editor de texto. (Ex: Bloco de Notas).

1º) Localize a linha #LoadModule unique_id_module modules/mod_unique_id.so e logo abaixo dela adicione:
LoadModule php5_module “c:/php5/php5apache.dll”

2º) Localize a linha AddModule mod_setenvif.c e logo abaixo, adicione:
AddModule mod_php5.c

3º) Localize AddType application/x-tar .tgz e logo abaixo, adicione:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

4º) Localize:



DirectoryIndex index.html

E logo ao lado do index.html adicione:
index.php default.php main.php

5. Configuração do MySQL
Não há nada para se configurar no MySQL, você só deve iniciar o mesmo. Vá para a pasta que instalou o MySQL, então abra o bin/mysqld.exe, iniciando o servidor do MySQL.Lembre-se que sempre você terá de iniciar o MySQL. Se não quiser ir na pasta toda vez que iniciar o computador, crie um atalho para o bin/mysqld.exe e coloque no “Iniciar, Programas, Inicializar (ou Iniciar, de acordo com o windows)”.

6. Falta pouco!
Agora, vá em “Iniciar, Programas, Apache HTTP Server, Control Apache Server, Restart”, para reinicializar o Apache com as alterações feitas. Pronto! Agora você pode tem PHP5 + MySQL em seu Windows!.

Para efetuar um teste, crie um arquivo chamado phpinfo.php, com o conteúdo:


();
?>

e o coloque na pasta htdocs dentro da pasta do Apache. Abra seu navegador e digite http://localhost/phpinfo.php. Se a página abrir com as informações do PHP, significa que tudo deu certo.

Observações: Lembrando que nos caminhos que mostrei, o C:\ deve ser substituído pela letra do HD em que está seu Windows e onde foram instalados os programas. Uso o C:\ no artigo, pois é a letra que é normalmente usada.

Caso queira register_globals no PHP, abra o c:\windows\php.ini, localize a linha “register_globals = Off” e arrume para “register_globals = On”. Veja mais aqui: http://www.php.net/manual/pt_BR/security.registerglobals.php

Faça o download do php.ini e do httpd.conf já configurados, você só precisará enviar cada um para as pastas aqui explicadas. Download: http://alfred.auriumsoft.com.br/galeria/arquivos_wamp.zip

Até a próxima!
Alfred Reinold Baudisch
alfred.baudisch@gmail.com
Blog: http://www.auriumsoft.com.br/blog/

Auriumsoft :: Inteligência, Tecnologia e Vídeo
http://www.auriumsoft.com.br

Auriumsoft Hosting
http://www.auriumhost.com.br

por Alfred R. Baudisch

http://phpbrasil.com/articles/article.php/id/847