Recent Posts

CSS Vertical Overlapping of floating divs

I thought this involved some trickiness. I needed to have a row of floating divs have the content underneath it pulled up over it, just a little bit, so that some body tabs appeared to the right of one of the floating images in the header.

After much testing and trial and error I figured out that the content below overlaps the content above depending on the dimensions of the div above it. The content below will STOP overlapping when it hits the image above UNLESS you make the height of the above div (that contains the image/content) to be smaller than the image/content itself. It appears by default, the height of the div containing the image is the same as the image (makes sense).

So the trickiness is in fooling the div below to overlap the div above, when the div below sees the above div as smaller in height than the image it contains.

I’ll post my html in the off-chance that someone can find and use this info.

PHP and MySQL setup on Mac OS X 10.5 Leopard

Full fledged open-source MAMP development environment with php, mysql, and apache on Mac OS X 10.5 Leopard

Goal: A complete php development environment using Mac OS X 10.5 Leopard’s out of the box apache2/php install, and an install of the latest mysql and eclipse software with all the necessary plugins for php debugging. ALL 64-BIT!

Admittedly, it was a challenge to get a fully functioning php dev environment up based on Mac OS X 10.5 Leopard’s configuration. But I succeeded in not installing a separate apache/php 32-bit install, or bailing out to use a linux Virtual Box.

Enabling PHP

PHP5

This one was pretty easy. Just uncomment out the line

#LoadModule php5_module        libexec/apache2/libphp5.so

in the httpd.conf apache config (/etc/apache2/httpd.conf) so it includes the php5 module that comes with the OS.

Make sure your extension_dir in php.ini points to /usr/lib/php5/extensions/no-debug-non-zts-20060613/ or go nuts and do your own extension directory.

Debugging 64-bit

This was one of the trickier things. You need to get an X-Debug extension setup. Hopefully you can just use my 64-bit extension file, and put that in your extensions directory (/usr/lib/php5/extensions/no-debug-non-zts-20060613/). Then add the zend_extension directive to the php.ini, along with the X-Debug settings, pointing to your (local or remote) host. In your php.ini:

(left bracket)xdebug(right bracket)
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=natest.crimereports.com  ; if debugging on remote server, put client IP here
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

xbedug.so (specific to 64-bit Mac OS X)

If that short version doesn’t work, you need to compile a 64-bit extension from the xdebug source, which was sort of tricky. You’ll need to get a compiler installed on your Mac OS if you haven’t got the right developer tools installed (XCode from the install disk or mac;s website), and then follow the instructions in this article.

http://www.vividreflection.com/blog/installing-xdebug-on-macosx/
http://www.designified.com/blog/article/60/compiling-installing-xdebug-for-php-525-entropych-build-on-os-x-105

Installing MySQL

Use the installer from MySQL’s site, and it goes pretty seamlessly. You may have to edit the php.ini to use the mysql server.

The tricky part of this is if you use a framework, or your code uses the pdo database interface. Again, you can try my 64-bit version, or compile your own pdo_mysql extension. Enable the extension in the php.ini by addin gthe line extension=pdo_mysql.so

pdo_mysql.so (specific to 64-bit Mac OS X)

http://www.hoboes.com/Mimsy/hacks/adding-pdo-mysql-mac-os-x-leopard-server/
http://www.spiration.co.uk/post/1332/install%20PDO_MYSQL%20-%20mysql_config%20and%20header%20files%20problem

Eclipse

So there is a Cacao version that is 64-bit. I guess the difference here, as I’ve read online, is that the Carbon version is more stable, but also legacy and in the future will be deprecated soon.

I love using the update site to get plugins. That seemed to work best for PDT php, aptana, SVN (subclipse), and various editors, etc.

Flex

I sort of copped-out here when I learned the 64-bit version of eclipse doesn’t work well with Flex-Builder as an Eclipse plugin. I’m planning on installing the stand-alone version of flex builder, and using that separately (a little but resource wasteful, but far more convenient).

Prepared statement errors with PHP 5.3 and mysqli. call_user_func_array returns null. Type error?

Prepared statements using mysqli seems to be having issues with PHP 5.3. I kept getting null from a prepared statement command that worked fine in PHP 5.2, namely, the mysqli_stmt_bind_param

Null means that the array you passed didn’t match the function signature.

The following worked in php 5.2, but when I updated my Mac to Snow Leopard (PHP 5.3 included) the following function stopped working

call_user_func_array(‘mysqli_stmt_bind_param’, array($stmt,’isis’,$args));

I kept getting a null return value (note – different than false). See bottom of the following bug:  http://bugs.php.net/bug.php?id=47554&edit=1

"Returns the function result, NULL for an invalid callback, and FALSE
for all other errors."

Toying with the array (translates to method signature of the callback function) passed to call_user_func_array was key. After much head banging (on desk) and much head banging (to music) I found that the following made my one specific test query work:

call_user_func_array(‘mysqli_stmt_bind_param’, array($stmt,’isis’,(int) $args[2],(string) $args[3],(int) $args[4],(string) $args[5]));

I wonder if the library that mysqli uses is in c (so that mysqli_stmt_bind_param is eventually run at a level where typing needs to be determined), and is requiring typed values that the php is screwing up somewhere in the translation. Or on the mysqli level. And I wonder what other explanations there could be for this behavior.

Usually when code is this buggy it is a developer’s coding errors, but someday I hope to run into a bug that isn’t my fault. On second thought, finding a bug in your development language probably causes a lot more pain in trying to figure it out, so I’m not sure that would be much of an accomplishment.

Importing an existing folder as a new Eclipse Project

I absolutely hate the new project dialog in eclipse. It seems like each plugin (PHP, Flex, Aptana, SVN, etc.) has its own way of doing a new project.

Here’s one reason I hate these dialogs – If I want to add a new project into my workspace, I can’t put the files there first and then make it a project. Why would I want to do this? 1)I want to clone a git project from a remote repository into my workspace. Right now there is no way to do this with an add project dialog. So the files get to my workspace, but they don’t show up as a project. Same goes for SVN stuff where I want to re-add the files as a new project without having to check the whole stinking repository out again. Plus, it would be nice if I wanted to add files first, then make projects. Is that so hard? I understand eclipse doesn’t want to muck around in a folder with no project data to make a new project, but really, is it so hard to make a non-project folder a project folder? And if eclipse isn’t meant to do this, GET RID OF THE ‘Create project from existing source’ option because it doesn’t work with many project types.

So here is a way I found that works swimmingly. I wonder if this came as an option with a plugin. If so, I am using PDT php, Aptana, Subclipse, and I think those are the main ones. If you don’t get this option in your menu, than who knows what plugin you may need. I’m just glad I got it to work for me.

SOLUTION: Screw the new project dialog. Do File->import then select the folder ‘Other’->Existing Folder as New Project. This works great for my goal of 1)having files in my workspace that are not a project in eclipse and then making that folder and all its files a new project.

bash: git-receive-pack: command not found, git-upload-pack

When doing a push to master I was getting

bash: git-upload-pack: command not found
bash: git-receive-pack: command not found

For me my server was not recognizing the git command. I had to add the server paths to my local git config

receivepack = /home3/<myusername>/local/git-1.6.4/git-receive-pack
uploadpack = /home3/<myusername>/local/git-1.6.4/git-upload-pack

where the config file is in the .git directory of my project on local. This line is under the entry for the remote I had set up called ‘origin’ (use the path on the server where the git install is located and make sure git-receive-pack is in there on the server).

BUT,I think the following is be the better solution. Editing the .bashrc worked like a charm. I added the following line to my .bashrc file (look in /etc or you home/ directory if on a shared server) and things worked swimmingly.

export PATH=”$PATH:/home3/<myusername>/local/git-1.6.4″

replace /home3/… with whatever the path to your git install may be.

I’m still not clear on why the path would be different for a bash ssh command, and a client sending a request over ssh to the server. It seems as if even though my server environment variable $PATH includes the path to the git install, the $PATH variables does not include that path if the git commands are invoked over a remote ssh request (like my eclipse working with git). But if I was logged in on a bash shell, the git commands worked great, with no ‘command not found’ errors. Make sure when you install git, that you understand how to make your server recognize the git executable commands, both from the bash and also from remote requests. I’m still unclear on the difference between 1) editing the $PATH environment variable to include your git directory 2) Editing the .bashrc with the export $PATH setting. 3) Making symbolic links from the bin folder to your git install.

See http://stackoverflow.com/questions/225291/git-upload-pack-command-not-found-how-to-fix-this-correctly

make[2]: execvp: Permission denied

make[2]: execvp: true: Permission denied

You need to do chmod 755 true on the true script on your bin, For me I had followed the instructions at:

http://blogs.koolwal.net/2009/07/20/howto-installing-git-on-bluehost-domain-hosted-websites/

for installing git on bluehost. I had to make a script called ‘true’, and put it in my local bin to get git to compile.

make[2]: execvp: <YOUR FILE HERE>: Permission denied

These errors mean that your script does not have execute rights. You can ‘chmod 755 <YOUR FILE>’ and it should work.

Using PEAR classes with bluehost php – Edit your include_path

Getting an HTTP_Request class was pissing me off. So it seems like you can’t install PECL classes on your php install because of rights issues on a shared hosting environment.

BUT, you can get PEAR classes installed through the cPanel, using the PHP PEAR Packages link. I was adding the HTTP_Request package (HTTP_Request2 won’t install because there is no stable release as of yet).

But even after the install, the classes could not be found. Like when I did require_once(‘HTTP/Request.php’) I was getting the classic not found warning and error:

Warning: include(HTTP/Request.php) [function.include]: failed to open stream: No such file or directory
Warning: include() [function.include]: Failed opening ‘HTTP/Request.php’ for inclusion
Fatal error: Class ‘HTTP_Request’ not found

You have to edit the php.ini (or ini_set the include_path ) to include :/home/yourusername/php, or in my case the home directory is now home3 for some reason, with some weird aliasing allowing for home I think. The PEAR packages install to /home/yourusername/php, so this needs to be added to the include path.

If you still get:
PHP Fatal error:  main(): Failed opening required ‘PEAR.php’
Then your include_path may be missing :/usr/lib/php, this is the main (not your local user) php lib folder that, I think, has the main PEAR files (The ones that your local PEAR package installs like HTTP_Request will be calling). So when you install a PEAR package via the cPanel, it puts them in /home/yourusername/php, and those files will need to know about the main PEAR install in /usr/lib/php by having /usr/lib/php in the include path.

XML to HTML entities – Encoding XML document text for HTML

private function XMLtoHTMLEntities($string){
//get rid of any XML entity encoding that may have been applied (like in an RSS feed)
$unXMLEntify = str_replace ( array ( '&' , '"', '&apos;' , '<' , '>'), ->
array ( '&', '"', "'", '<', '>') , $string );
return htmlentities($unXMLEntify);
}

How to install the pdo myql drivers for php

First install pdo.

I already had php 5 with the pdo extension included in the build. But I needed the mysql driver for the php extension since it only came with 2 (sqlLite, sqlLite2).

To add the mysql driver for pdo in your php install, put (pdo_mysql.so – you’ll have to compile this) in your extensions directory and then enable that extension in php.ini. WTF, pretty simple but there are no web pages with instructions. And compiling in Mac OS X sucks because you need to install extra Developer tools and than run the command line compile commands.

http://pecl.php.net/package/PDO_MYSQL