Working with MySQL records from separate servers

A recent project required my script to access and store records in a MySQL table hosted on another server. It can be done fairly quickly within a few clicks.

On the server that is hosting the MySQL database, we need to set the permission that will allow the other servers to connect to it. From cPanel:

1. Under Databases, click on "Remote MySQL".

Image via Siteground.com

2. Fill in the IP address of the other server that will be granted access to work with our MySQL database.

3. We're done!

On the other server, just point the database connection script to the MySQL host server.

 

Upgrading Issues from phpBB 3.0.4 to 3.0.5

I recently upgraded one of our phpBB forums from 3.0.4 to 3.0.5. The process was fairly painless - until I realized that the user registration page was totally screwed up.

The layout was distorted, and the CAPTCHA doesn't display, both in the user registration page and in the Administrator Control Panel (under Visualization).

At the top of the User Registration page were these error messages:

[phpBB Debug] PHP Notice: in file /includes/ucp/ucp_register.php on line 488: mt_rand() expects parameter 1 to be long, string given
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3824: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3247)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3826: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3247)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3827: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3247)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3828: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3247)

 

Stumped, I checked the official phpBB forum and the general advise was to re-upload the 3.0.5 files, EXCEPT for "config.php" and the "images" and "files" folder.

Logged in to the Admininistrator Control Panel and cleared the cache, but the error messages remained.

In the end, the script that turned out to be the culprit was includes/constants.php. All I had to do was to re-upload the script, and the problem was solved.

References:

 

Embedding Playable Audio Files

Support you're part of an awesome rock band, and want to offer audio clips of your equally awesome tracks on your website. Or you speak at events, and would like to make available your talks online.

With the "Embeddable Flash MP3 Player", you can offer visitors the ability to play the audio files from your web page itself.

It uses a simple Flash player interface, originally designed as a Wordpress plugin but can be used on any other sites.

Integrating PHP with web services like PayPal, Twitter, etc

You don't actually need to learn the native API functionalities of all the various web services that you want to integrate PHP with.

Chances are, someone has already taken the trouble to write PHP classes that work seamlessly with them. All you have to do it plug them in, and RTFM.

The PHP PayPal IPN Integration Class, for example, eventhough a mouthful, does all the hard work and the codes are well commented.

Similarly, the PHP-Twitter Class allows you to conjure up your own Twitter box very quickly. Here's a handy tutorial.

Increasing the target area for clickable links via CSS

Let's say we have a vertical menu, made up of a bunch of links. The "clickable" target area for the links is confined to the text. Fair enough.

But we can do better. To improve usability, we want to enlargen the clickable area, as pictured below.

It can be done using CSS' display:block property. Just append it into the anchor link, as follows:

<a href="link.htm" style="display:block;">FAQ</a>

CSS Horizontal Menu with Lists

CSS allows you to create horizontal menu using lists. While you can also do it with a series of <divs>, having them in lists can help to make the scripts cleaner, clearer and easier to maintain. Here are the very basic codes needed. Just copy and paste the CSS bits, and modify as necessary to suit your menu.

<style type="text/css">
#menu li {
    display: inline;
    list-style-type: none;
    padding-right: 20px;
}
</style>

<!-- Start the list here! //-->
<ul id="menu">

    <li>Home</li>
    <li>Products</li>
    <li>Services</li>
    <li>About Us</li>
    <li>Contact Us</li>
</ul>