BEFORE POSTING: basic error-checking

Post here is you are having problems with any of the tutorials.
Locked
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

BEFORE POSTING: basic error-checking

Post by Helx »

Hi there,

Before creating a thread in this section, please go through the step-by-step list below to see if you are able to figure out what your error is on your own. If you cannot figure out what is wrong with your code, then go ahead and create a new thread about your troubles.

The following assumes that your problem is with a PHP tutorial by Jacek.

Step 1: Spell-check

Try going through each line of your code on all your pages. See if the functions are spelled correctly.
If you cannot concentrate, try copying what you have to a different editor, so that you can see what you have in a different format.

If you already use a program such as Notepad, try using an editor that highlights PHP syntax; like Komodo Edit. See if your code is identical to the video.

Step 2: PHP errors

If you know what you're doing, chances are all you need is an error message to point out where syntax errors are (like unclosed tags and whatnot). All that is needed is the following code at the top of the page you are working in (underneath the opening tags, <?php):

[syntax=php]error_reporting(E_ALL);
ini_set('display_errors', '1');[/syntax]
This will display ANY error or warning that could affect the desired outcome of the script.
Once you have finished troubleshooting, it's always a good idea to remove it.

Step 3: SQL errors

Sometimes you might get an SQL error, these can be caused by using a backtick where an apostrophe was required. These are simple enough to fix; just insert the following code below your queries

[syntax=php]echo mysql_error();[/syntax]
This will produce an error message such as "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''posts' WHERE `post_title` = 'title'' at line 1".

It points you very close to where the problem is and is usually enough.

Step 4: Versions and Operating Systems

I could argue about this needing to be step 1, but typically PHP versions all plays nicely together (okay, no).
However, one thing you need to look out for is depreciation.

PHP functions come and go, it's really quite annoying to keep up with. If you get a depreciation error (using step 2), then go to the php.net website and lookup the function, the website will usually direct you off to the replacement (they normally work the same).

I said Operating Systems could matter, because the PHP versions are developed differently. For example, the Windows version of PHP has the screenshot() function and Linux doesn't.

--

So have a go, and try not resort to copying and pasting; you'll learn nothing.
If you are really stuck, just go straight ahead and create a new thread.

Jacek/Temor, feel free to add more steps or edit the current ones :P
Locked