Ipaya Welcome Access Pages Publish Pages Your Account
 
Overview Resources Sign up
Navigation
Technical details
  •Overview
  •Setup guides
  >  PHP and MySQL manual
  •How reported hits are checked
  •Special case: Frequently changing pages
  •API Specs
  •Back to Resources
 
PHP and MySQL manual
Setting up your server for publishing pages with Ipaya
Version 1.02 (March 21, 2003)

Contents
  1. Preparations
    1. System requirements
    2. Supplied files
    3. Site structure
    4. PayPal
  2. Ipaya sign up
  3. Database setup
  4. Adapting PHP files
    1. basics.php
    2. yourpage.php
  5. Checking, debugging
    1. 1st-test.php
    2. Sign up to access pages
    3. yourpage.php
    4. Reporting script
  6. Publishing your pages
    1. Basics
    2. Publishing in other directories
    3. Publishing as .html
    4. Publishing pages with less than 2 KB of information
    5. Publishing pages containing PHP code
    6. Publishing pages that use Perl, JSP, ASP or the like

1. Preparations
  1. System requirements
    For the set-up method described in this manual, the minimum system requirements are:

    If parts of these requirements are missing or out of date, now it's a good time to ask your hosting provider to install them or install them yourself.

  2. Supplied files
    This setup guide contains the following directories and files:



    They have the following purposes:
    • db_setup.sql: Script that automatically setups your MySQL database.
    • man_imgs: Directory containing the images you see in this manual.
    • manual.htm: This guide you're reading right now.
    • to_server: Directory containing 5 PHP files which you will adapt and copy to your webserver. They are:
      • 1st-test.php: Installation testing script. Call it to see if there are errors in your implementation. Can be deleted after everything works.
      • basics.php: Central script that contains code used by the other scripts. This is the file that you adapt once so that everything works. It won't be accessed from the web, only from other scripts.
      • report.php: Script that we call every 12 hours to get the latest pagehits from you. Nothing to adapt here.
      • setcooki.php: Script that a user is redirected to after being at Ipaya and sets a cookie. Nothing to adapt here.
      • yourpage.php: An example for the page subscribers will see. It contains only 4 lines of PHP code. Needs to be adapted. Use this file as a template to create the pages you will publish. The file itself may be deleted from your server after everything works.

  3. Site structure
    Ask yourself where you plan to put the "to_server" files on your webserver. We suggest that, for starters, you place them all in a single directory. Please keep in mind the URLs where the following two files will be accessible from the outside:
    • setcooki.php - Your "Set-Cookie" script
    • report.php - Your reporting script

  4. PayPal
    To receive money from us, you need a PayPal account. Before you proceed, please create one
    here.


2. Ipaya sign up

3. Database setup
  1. Certain web hosting plans already come with a MySQL database preinstalled, while others need you to create one first. Create a MySQL database now. To do so, either ask your provider or go into your site management website and do it yourself. Since there are many different site managers, we can't show you a picture of this step, but it's a trivial thing anyway in most cases. If phpMyAdmin is not installed on your server, but you're familiar with the UNIX command line, read this.

  2. Now, browse to the phpMyAdmin tool. This tool can often be found at yourwebsite.com/phpMyAdmin/.



    On the left side, you see the name of your database (here it's "example"). Click it.

  3. On the next screen, you're now able to create all tables for Ipaya.



    We've made this process easier for you by providing a script that creates all necessary tables automatically. To run it, click on the button named "Choose File" in our example (it might be called "Browse..." or something else on your system). Then choose the file db_setup.sql that we provided you as part of this documentation. Then click the button "Go".

  4. MySQL now sets up all necessary tables for you. When it's done, you see the following screen:



    Note the 3 tables "Globals" "Pagehit" and "temp_permit" on the left side, that have been created for you. This is the last step of the database setup.

4. Adapting PHP files
  1. basics.php
    Remember the 5 files in the directory "to_server"?



    Open the file called "basics.php" with a text editor. At the very beginning of this file, there is a section that starts with "adapt these lines for your site" and ends with "End of lines to adapt". Work through this section according to the notes written alongside them.



    Make sure that you don't change anything else in the code. Make especially sure that
    • you don't erase the quotes (") at the beginning and end of each text you adapt
    • you don't add a spaces: Each text needs to have the quotes, then immediately afterwards the text and then immediately afterwards the quotes again
    • you don't erase the semicolon (;) at the end of each line

  2. yourpage.php
    Now, open the file called "yourpage.php". It's an example for the page that your subscribers will see.



    There are two things you need to adapt here:
    1. Enter the complete URL of your finished page on the top.
    2. Enter the information your visitors will see beyond the "?>" marker.

  3. Last step: Upload all 5 PHP scripts into the same directory on your webserver using your normal upload tool (FTP).


5. Checking, debugging
  1. 1st-test.php
    The first thing you should do is start the provided 1st-test.php script. To do so, enter the URL of the directory you uploaded all your files into, plus 1st-test.php into your browser, like that:

    http://www.example.com/ipaya-directory/1st-test.php

    If everything works fine, you should see something like this in the browser:



    If there are errors, please refer to the following table:

    ProblemReasonSolution
    Error 404 "File not found"Your webserver could not find your pageMake sure you made no typing errors when entering the URL. Do the same checks you would do if a new html page won't show up on your site.
    Titles are displayed, but no "OKs"File is not interpreted as a PHP fileYour webserver is not configured to handle .php-files or PHP-interpreter is not installed. Check your configuration or talk to your provider to change that.
    PHP Version is below 4-Install a newer version of PHP or ask your provider to do it.
    2. Includes: "Failed opening required 'basics.php'"PHP couldn't find basics.phpCheck if you have uploaded all 5 files. Check if all 5 files are in the same folder.
    2. Includes: "Unknown MySQL Server Host"Your entered db_address in basics.php could not be foundTry entering "localhost" as db_address. If you're sure that something else has to be entered, double check it.
    2. Includes: "Access denied for user [...] (Using password: YES)"Your entered db_login or db_pass in basics.php are incorrect.Double check what you have entered as db_login and db_pass. These are likely the same values you entered when you connected to phpMyAdmin at the beginning. By the way: The message "using password: YES" doesn't mean that it has received YES as your password, but simply that it has received some password.
    3. Database Tables: "No Database Selected"Your entered db_name in basics.php could not be foundDouble check what you have entered as db_name. This is the database name you see on the left side in phpMyAdmin.
    3. Database Tables: "Call to undefined function: safe_query"basics.php exists, but is brokenMost likely, you have uploaded basics.php, but the transfer broke down before completion. Upload all files again to make sure they are complete.
    3. Database Tables: "Database tables not set up yet"PHP can find your database, but there are no tablesGo through Step 1 of this tutorial to create the necessary tables.


    If everything works fine, you may delete 1st-test.php again from your server, because you don't need it anymore.

  2. Sign up to access pages
    To test the workings of your script, you need to subscribe for an Ipaya account to access pages. This step will cost you a bit of money, but you can surf to any Ipaya page and see what others do. Plus, since you also surf to your own server, you get back some of your money at the end of the month. Read more about subscription prices
    here.

    Sign up here.

    After you have signed up, try out your subscription at a subscription page like http://www.xirrus.ch/ipaya/ to make sure that cookies are turned on in your browser and everything works fine.

  3. yourpage.php
    Now, enter the URL of your example page, like that:

    http://www.example.com/ipaya-directory/yourpage.php

    If everything works fine, your page should appear after a waiting period of 1 - 2 seconds. If there are errors, please refer to the following table:

    ProblemReasonSolution
    Error 404 "File not found", URL in the browser location bar is what you have enteredYour webserver could not find your pageMake sure you made no typing errors when entering the URL. Do the same checks you would do if a new html page won't show up on your site.
    Message "Site 'example_com' not found in database"The value you submit to Ipaya as your site name cannot be found in the Ipaya databaseMake sure that you have a publishing account at Ipaya. Double check that the value you have entered as "technical name" at Ipaya is the same that you have entered as ipaya_site in basics.php. To see what you have entered, visit your Account at Ipaya.
    Message "no '_done' URL argument received"Variable _done is either empty or nonexistentCheck yourpage.php and see what you have entered as this_page. It might be empty (looking like: "")
    Message "The requested URL needs an Ipaya subscription to be accessed."You are not signed in, or have no existing subscriptionIf you're not signed in, a sign-in box is visible in the top right corner - use it to sign in. If you have no Ipaya subscription, sign up for one or ask somebody who already has a subscription to test your pages.
    Message "Ipaya said: no site argument received"During check_temp_user, you didn't send your technical name to IpayaCheck yourpage.php and see what you have entered as ipaya_site. It might be empty (looking like: "")
    Message "Ipaya said: no pass argument received"During check_temp_user, you didn't send your password to IpayaCheck yourpage.php and see what you have entered as ipaya_pass. It might be empty (looking like: "")
    Message "Ipaya said: Invalid site or password argument"During check_temp_user, you sent a incorrect technical name or password to IpayaDouble check that your account password at Ipaya is the same value you have entered as ipaya_pass in basics.php
    Error 404 "File not found", URL in the browser location bar contains "temp_anon_user"The page Ipaya redirects users to after checking their subscription doesn't existMake sure that what you have entered as "URL of your 'Set-Cookie' script" at Ipaya in the page publishing settings is the real location of your setcooki.php script. To see what you have entered, visit your Account at Ipaya.
    Error 404 "File not found", URL in the browser location bar contains "checkcookie"The url for checking cookies that have just been set is incorrectMake sure that what you have entered as "setcookie_url" in basics.php is the real location of your setcooki.php script. Make sure that it is the complete URL of setcooki.php, including "http://" and your domain name.
    Message "Cookie was not set"In the "set cookie" command, setcooki.php sent your browser an incorrect domainMake sure that what you have entered as "set_cookie_domain" in basics.php is a real domain name and is the domain name of your setcooki.php script. The entry must not contain "http://". The entry must not contain any directories or any "/". If the top level domain of your server is one of ".com, .net, .org, .edu, .gov, .mil", the domain must consist of at least 2 elements (example: "domainname" and ".com"). If the top level domain of your server is something else, the domain must consist of at least 3 elements (example: "www", ".domainname", ".de". Another example: "domainname", ".co", ".uk")
    Error 404 "File not found", URL in the browser location bar contains no "_done" argumentThe value you entered as this_page in yourpage.php is incorrectCheck yourpage.php and see what you have entered as this_page. Make sure that it is the complete URL of yourpage.php, including "http://" and your domain name.

  4. Reporting script
    The last check is of your reporting script. To test it, go into your
    Data import summary.



    Click on "Manual import..." in the title bar.



    On the next screen, click on "Start manual import" on the bottom. The process might take a few seconds, and then present you with a "process done" page. Click to go back to the "Data import summary".



    Look at the message area. If you see a message that at least 1 entry was copied, everything works perfectly. If there are errors, use the detailed error description to figure out what the problem is and fix it. Then start another manual import to see if the problem has gone away.



6. Publishing your pages
  1. Basics
    To publish a page, use yourpage.php as a template.



    Make a copy of yourpage.php. In the new file, enter the current page URL at the red ellipse and paste your html page code after the marker - and you're done.

    There are virtually no limits to what you can paste after the marker: CSS, JavaScript... if it works in a .html-file, it will work here, as well.

  2. Publishing in other directories
    To do so, you need to adapt the "include" (line 2) so that is correctly links back to basics.php. The rules for linking are similar to how linking is done between html pages:
    • to go up a directory, write ".."
    • to go into a a directory, write its name
    • separator is "/"
    Example:
    • You are publishing a page at the url
      http://www.example.com/articles/page_one.php
    • basics.php is located at
      http://www.example.com/ipaya/basics.php
    • To link from page_one to basics, line 2 would need to be:
      include("../ipaya/basics.php");

  3. Publishing as .html
    If you would like to have your article at a URL that ends in .html instead of .php:
    • We suggest to not do it - it's complicated and can slow your server down. Stick with .php
    • To actually do it, change the configuration of your server so that all .html files are parsed by the PHP interpreter like .php files are. Beware that this makes overall site speed slower, as all your pages are handled like .php files now.

  4. Publishing pages with less than 2 KB of information
    According to the
    terms, you may not report back pages that contain less than a certain minimum amount of information. To create a page that
    • is not reported back
    • but still requires a valid Ipaya subscription
    follow these easy steps:
    • in your page, look for the line
      record_pagehit();
      (usually at line 12)
    • delete the line, or comment it out by preceding it with "//"

  5. Publishing pages containing PHP code
    To publish pages containing PHP code, simply paste your code after the marker. If you publish PHP code, please make sure that:
    • you place no code before the Ipaya code
    • you test your scripts extensively

  6. Publishing pages that use Perl, JSP, ASP or the like
    In these cases, the best way to publish pages is by reading the Ipaya
    API Specs, then taking the PHP code used in this guide and port it to the language of your choice. Check first if somebody already did this step for you. If nobody did, please consider sharing your finished work by contacting us.


Contact - User Agreement - Privacy Policy
Copyright © 2003 Ipaya