jump to navigation

Character conversión in UTF-8 between Actionscript PHP and Mysql April 30, 2008

Posted by maxmil in : Flash,MySql,php , add a comment

Always a tricky one. The best solution that i’ve found is

1) Mysql database and/or tables with the utf-8 character set and utf_general_ci collation.
2) PHP files encoded in UTF8
3) After the initial connection with the database send the querySET NAMES `utf8`

Install Apache Php Mysql on Windows February 15, 2007

Posted by maxmil in : Apache,MySql,php , 3 comments

Instalation of Apache
1) Download and open installer (apache_2.2.4-win32-x86-no_ssl.msi in my case)
2) Doesn’t matter what you put as domain, server and admin email as this is a private instalation. I’ve put MyDomain, MyServer and admin@mydomain.com
3) After installation you should see the apache service monitor in the system tray with a green arrow denoting that apache is running. If you navegate to http://localhost in your browser you should see a page that says “it works!”
4) Notes: Apache may not be able to start if IIS is running or Skype is online as both may use port 80.

Install php5
5) Download zip package from php.net (php-5.2.1-Win32.zip in my case). DO NOT DOWNLOAD INSTALLER.
6) Unzip to c:\php
7) Move (DON’T COPY) c:\php\php5ts.dll to c:\WINDOWS\php5ts.dll (An alternative would be to add c:\php to the PATH environmental variable but i haven’t tried this).
8) Copy c:\php\php.ini.dist to c:\php\php.ini
9) Edit extension_dir = “./” in php.ini. Replace with extension_dir = “”C:\php\ext\”. This is necessary when php executes within apache since the relative path “./” is no longer valid.

Configure php with apache
10) Open C:\Archivos de programa\Apache Software Foundation\Apache2.2\conf\httpd.conf
11) Edit doc root from “C:\Archivos de programa\Apache Software Foundation\Apache2.2\htdocs” to the doc root of your choice (2 instances to change).
12) Add php executable script after “AddType application/x-gzip .gz .tgz” in :

	ScriptAlias /php/ "c:/php/"
	AddType application/x-httpd-php .php .php5
	Action application/x-httpd-php "/php/php-cgi.exe"
	SetEnv PHPRC "C:/php"

13) Add permissions to the executable (don’t think that it matters where you put this, i put it after the definition of the above <IfModule mime_module>

	# Add access to php directory
	<Directory "C:/php">
		Options ExecCGI Indexes FollowSymLinks 
		AllowOverride None 
		Order allow,deny 
		Allow from all

14) Add .php extention to directory index module. Search for “IfModule dir_module” and add index.php after index.html. After editing it should look like this:

<IfModule dir_module>
    DirectoryIndex index.html index.php

15) Create index.php file in doc root of apache with the text
16) Stop apache. Start apache (from system tray – for some reason restart apache is not working for me)
17) Go to http://localhost and you should see the typical phpinfo page.

Install Mysql
18) Download mysql community edition from mysql site (in my case its mysql-5.0.27-win32.zip)
19) Extract Setup.exe and execute
20) When prompted you don’t have to sign in/up
21) When prompted accept “Configure the Mysql Server now”
22) Choose “Detailed Configuration”
23) Choose “Developer Machine”
24) Choose “Multifunctional Database”
25) Customize, if you want, where the innodb table space will be created (note: this is not the mysql data dir. To relocate the data dir you must stop the server, copy all files except log files from the current data dir, delete the log files, update the datadir in my.ini and restart the server).
26) Choose Decision Support
27) Choose Enable TCP/IP Networking and accept port 3306
28) Choose best support for multilingualism (UTF8 character set)
29) Choose install as a Windows service. I have unmarked the “Launch the MySQL Server automatically” option because i prefer to start it only when i want to use it (the service can be started from the command line with “net start mysql”). I also mark the “include Bin directory..” as i sometimes connect from the command line using the mysql client)
30) Choose your root password
31) Execute and finish
32) If
33) Test instalation by connecting (use your preferred method) and executing the query “select version();”. You should get:

	| version()           |
	| 5.0.27-community-nt |
	1 row in set (0.02 sec)

Configure php with mysql
34) Open c:\php\php.ini and uncomment the line: extension=php_mysqli.dll
35) Stop and Start Apache
36) Create file testMysql.php in you apache document root with the text (replace ‘root_pswd’ with your real root password:

$mysqli = new mysqli('localhost','root','root_pswd');
$result = $mysqli->query("SELECT version()");
while($row = $result->fetch_assoc()) {
	print $row['version()'];	

37) Navegate to http://localhost/testMysql.php and you should see the text “5.0.27-community-nt” (or equivalent if you have installed a different version of mysql.

Set up virtual host in apache
38) In httpd.conf add default virtual host so that your document root folder is not affected. At the end of httpd.conf add:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot "path/to/document/root"

39) Add declaration for each virtual host. This is a minimal example:

<VirtualHost *:80>
	ServerName  my-virtual-host
	DocumentRoot "path/to/my/virtual/host/doc/root"
	<Directory "path/to/my/virtual/host/doc/root">
		AllowOverride All
		Order allow,deny
		Allow from all

40) In c:\WINDOWS\System32\drivers\etc\hosts add your virtual host to the line that starts       localhost my-virtual-host

41) Restart apache and navigate to http://my-virtual-host

Manipulating images and pdf’s in php October 31, 2006

Posted by maxmil in : php , add a comment

After a quick google the best free options are:

– imageMagick with the Magic Wand For PHP extension for creating images on the fly
– Pdftk for splitting and joining pdf’s although i haven’t found if this is capable of extracting text from pages.

The spenny option is pdflib

ZendStudio and php extentions October 27, 2006

Posted by maxmil in : php , add a comment

Just installed and started to work with ZendStudio. My first problem was getting the internal debugger to function properly. It could’nt load the mysqli extention. The error that i was getting was:

Class 'mysqli' not found

As described in this knowledge base article you have to specify the php extentions directoy in the Zend Studio php.ini. I copied my php extentions from another installation of php to my Zend directory and edited php.ini. However after doing this it still didn’t work.

Eventually i found the solution. The php version that my Zend Studio uses is 5.1.1 whilst i had copied extentions from 5.1.6

After downloading the binaries for version 5.1.1 and extracting the extentions it worked without a problem.

ZenCart links April 25, 2006

Posted by maxmil in : php , add a comment

Template: http://zencart.template-help.com/

Updated Apache Module PHP4 to PHP5 on Debian Sarge

Posted by maxmil in : Apache,Debian,MySql,php , add a comment

Added these lines to my /etc/apt/sources.list

# Use dotdeb.org for LAMP related packages not available in Sarge
deb http://dotdeb.pimpmylinux.org/ stable all
deb-src http://dotdeb.pimpmylinux.org/ stable all

And then executed:

$> apt-get update
$> apt-get install libapache2-mod-php5

Check out the article from where i got this info: http://www.debian-administration.org/articles/357