Common php error

Everyone runs into syntax errors. Even experienced programmers make typos. For newcomers, it's just part of the learning process. However, it's often easy to interpret error messages such as: PHP ...

What are the syntax errors?

PHP belongs to the C-style and imperative programming languages. It has rigid grammar rules, which it cannot recover from when encountering misplaced symbols or identifiers. It can’t guess your coding intentions.

Function definition syntax abstract

Most important tips

There are a few basic precautions you can always take:

  • Use proper code indentation, or adopt any lofty coding style.
    Readability prevents irregularities.

  • Use an IDE or editor for PHP with syntax highlighting.
    Which also help with parentheses/bracket balancing.

    Expected: semicolon

  • Read the language reference and examples in the manual.
    Twice, to become somewhat proficient.

How to interpret parser errors

A typical syntax error message reads:

Parse error: syntax error, unexpected T_STRING, expecting ; in file.php on line 217

Which lists the possible location of a syntax mistake. See the mentioned file name and line number.

A moniker such as T_STRING explains which symbol the parser/tokenizer couldn’t process finally. This isn’t necessarily the cause of the syntax mistake, however.

It’s important to look into previous code lines as well. Often syntax errors are just mishaps that happened earlier. The error line number is just where the parser conclusively gave up to process it all.

Solving syntax errors

There are many approaches to narrow down and fix syntax hiccups.

  • Open the mentioned source file. Look at the mentioned code line.

    • For runaway strings and misplaced operators, this is usually where you find the culprit.

    • Read the line left to right and imagine what each symbol does.

  • More regularly you need to look at preceding lines as well.

    • In particular, missing ; semicolons are missing at the previous line ends/statement. (At least from the stylistic viewpoint. )

    • If { code blocks } are incorrectly closed or nested, you may need to investigate even further up the source code. Use proper code indentation to simplify that.

  • Look at the syntax colorization!

    • Strings and variables and constants should all have different colors.

    • Operators +-*/. should be tinted distinct as well. Else they might be in the wrong context.

    • If you see string colorization extend too far or too short, then you have found an unescaped or missing closing " or ' string marker.

    • Having two same-colored punctuation characters next to each other can also mean trouble. Usually, operators are lone if it’s not ++, --, or parentheses following an operator. Two strings/identifiers directly following each other are incorrect in most contexts.

  • Whitespace is your friend.
    Follow any coding style.

  • Break up long lines temporarily.

    • You can freely add newlines between operators or constants and strings. The parser will then concretize the line number for parsing errors. Instead of looking at the very lengthy code, you can isolate the missing or misplaced syntax symbol.

    • Split up complex if statements into distinct or nested if conditions.

    • Instead of lengthy math formulas or logic chains, use temporary variables to simplify the code. (More readable = fewer errors.)

    • Add newlines between:

      1. The code you can easily identify as correct,
      2. The parts you’re unsure about,
      3. And the lines which the parser complains about.

      Partitioning up long code blocks really helps to locate the origin of syntax errors.

  • Comment out offending code.

    • If you can’t isolate the problem source, start to comment out (and thus temporarily remove) blocks of code.

    • As soon as you got rid of the parsing error, you have found the problem source. Look more closely there.

    • Sometimes you want to temporarily remove complete function/method blocks. (In case of unmatched curly braces and wrongly indented code.)

    • When you can’t resolve the syntax issue, try to rewrite the commented out sections from scratch.

  • As a newcomer, avoid some of the confusing syntax constructs.

    • The ternary ? : condition operator can compact code and is useful indeed. But it doesn’t aid readability in all cases. Prefer plain if statements while unversed.

    • PHP’s alternative syntax (if:/elseif:/endif;) is common for templates, but arguably less easy to follow than normal { code } blocks.

  • The most prevalent newcomer mistakes are:

    • Missing semicolons ; for terminating statements/lines.

    • Mismatched string quotes for " or ' and unescaped quotes within.

    • Forgotten operators, in particular for the string . concatenation.

    • Unbalanced ( parentheses ). Count them in the reported line. Are there an equal number of them?

  • Don’t forget that solving one syntax problem can uncover the next.

    • If you make one issue go away, but other crops up in some code below, you’re mostly on the right path.

    • If after editing a new syntax error crops up in the same line, then your attempted change was possibly a failure. (Not always though.)

  • Restore a backup of previously working code, if you can’t fix it.

    • Adopt a source code versioning system. You can always view a diff of the broken and last working version. Which might be enlightening as to what the syntax problem is.
  • Invisible stray Unicode characters: In some cases, you need to use a hexeditor or different editor/viewer on your source. Some problems cannot be found just from looking at your code.

    • Try grep --color -P -n "[x80-xFF]" file.php as the first measure to find non-ASCII symbols.

    • In particular BOMs, zero-width spaces, or non-breaking spaces, and smart quotes regularly can find their way into the source code.

  • Take care of which type of linebreaks are saved in files.

    • PHP just honors n newlines, not r carriage returns.

    • Which is occasionally an issue for MacOS users (even on OS  X for misconfigured editors).

    • It often only surfaces as an issue when single-line // or # comments are used. Multiline /*...*/ comments do seldom disturb the parser when linebreaks get ignored.

  • If your syntax error does not transmit over the web:
    It happens that you have a syntax error on your machine. But posting the very same file online does not exhibit it anymore. Which can only mean one of two things:

    • You are looking at the wrong file!

    • Or your code contained invisible stray Unicode (see above).
      You can easily find out: Just copy your code back from the web form into your text editor.

  • Check your PHP version. Not all syntax constructs are available on every server.

    • php -v for the command line interpreter

    • <?php phpinfo(); for the one invoked through the webserver.

    Those aren’t necessarily the same. In particular when working with frameworks, you will them to match up.

  • Don’t use PHP’s reserved keywords as identifiers for functions/methods, classes or constants.

  • Trial-and-error is your last resort.

If all else fails, you can always google your error message. Syntax symbols aren’t as easy to search for (Stack Overflow itself is indexed by SymbolHound though). Therefore it may take looking through a few more pages before you find something relevant.

Further guides:

  • PHP Debugging Basics by David Sklar
  • Fixing PHP Errors by Jason McCreary
  • PHP Errors – 10 Common Mistakes by Mario Lurig
  • Common PHP Errors and Solutions
  • How to Troubleshoot and Fix your WordPress Website
  • A Guide To PHP Error Messages For Designers — Smashing Magazine

White screen of death

If your website is just blank, then typically a syntax error is the cause.
Enable their display with:

  • error_reporting = E_ALL
  • display_errors = 1

In your php.ini generally, or via .htaccess for mod_php,
or even .user.ini with FastCGI setups.

Enabling it within the broken script is too late because PHP can’t even interpret/run the first line. A quick workaround is crafting a wrapper script, say test.php:

<?php
   error_reporting(E_ALL);
   ini_set("display_errors", 1);
   include("./broken-script.php");

Then invoke the failing code by accessing this wrapper script.

It also helps to enable PHP’s error_log and look into your webserver’s error.log when a script crashes with HTTP 500 responses.

Common PHP 8.0 Compilation Error Messages

With PHP 8.0 closing on us, it is high time to check our code bases to see if they compile, at least. Here is a list of common PHP 8.0 compilation messages, and what do to with them.

The errors have been found on a corpus of 1756 PHP projects. Any emitted error was compared to the result of the PHP 7.4 compilation. This means that those errors are fatal in PHP 8, while they were absent, or a warning in PHP 7.4. In both cases, in PHP 7.4, it used to be possible to brush them under the carpet, but not in PHP 8.0 anymore.

Common PHP 8.0 compilation errors

  • Array and string offset access syntax with curly braces is no longer supported
  • Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)
  • __autoload() is no longer supported, use spl_autoload_register() instead
  • Cannot use ‘parent’ when current class scope has no parent
  • syntax error, unexpected ‘match’
  • The (real) cast has been removed, use (float) instead
  • The (unset) cast is no longer supported
  • Declaration of A2::B($c, $d = 0) must be compatible with A1::B(&$c, $d = 0)
  • Unterminated comment starting line

Array and string offset access syntax with curly braces is no longer supported

Array and string offset access syntax with curly braces is no longer supportedmeans that only the square bracket syntax is now valid.

 
<?php 
   $array = range(0, 10); 
  echo $array{3}; // 4 
?> 

Replace the { with [, and the code will be good again. Exakat spots those with the rule No more curly arrays.

Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e)

Introduced in PHP 7.4, it is not possible to nest ternary operators. This is related to ternary being right associative, while most of the operators are left associative. PHP RFC: Deprecate left-associative ternary operators.

 
<?php 
1 ? 2 : 3 ? 4 : 5; // deprecated 
(1 ? 2 : 3) ? 4 : 5; // ok 
1 ? 2 : (3 ? 4 : 5); // ok 
?> 

The error message is quite verbose : take advantage of it! Add some parenthesis, or even , split the nested operation into independent expressions. Exakat spots those with the rule Nested Ternary Without Parenthesis.

__autoload() is no longer supported, use splautoloadregister() instead

This error message might appear here thanks to very old applications. Or if they try to support very old PHP versions. In any case, the message is self-explanatory.

Cannot use ‘parent’ when current class scope has no parent

Using the parent keyword in a class without parent, a.k.a. without extends keyword, used to be a Deprecation Notice. In fact, the class would blow up during execution with a ‘Cannot access parent:: when current class scope has no parent’ Fatal error.

It is now a Fatal error at linting time. This will shorten significantly the time between the bug creation and its discovery.

 <?php 
class x { 
   function foo() { 
      echo parent::a; 
   } 
}

(new x)->foo(); 
?> 

As for the fix, there are lots of options, depending on how this parent keyword ended up there in the first place. Exakat spots those with the rule Class Without Parent.

syntax error, unexpected ‘match’

This is a consequence of the introduction of the match instruction in PHP. It is not possible to use that name in instantiation (new), use expressions, instanceof, typehints, functions, classes, interfaces, traits or constants. It is still OK inside a namespace, or for a variable name.

 <?php

// This Match is still valid, thanks to the new Qualified Name processing 
use PeridotLeoMatcherMatch;

// This Match is invalid 
function foo(Match $match) { 
   // do something 
}

// Match side effect : syntax error, unexpected ',' 
$result = match($content,"'KOD_VERSION','(.*)'");

?>

When match is used as a function name, it may lead to an error about commas : the main argument of the new match keyword only accept one argument, so no comma.

The only solution is to rename the classes, interfaces, traits, functions or constants with another name and update the use expressions accordingly.

The (real) cast has been removed, use (float) instead

All is said here. (real) is gone, long live (float).

 
<?php 
  $price = (real) getActualPrice(); 
?> 

Just replace (real) by (float). While you’re at it, you can replace is_real() by is_float() : is_real() didn’t make it into PHP 8.0. Exakat spots those with the rule Avoid Real.

The (unset) cast is no longer supported

The big brother of the unset function is a type cast (unset). It used to be actually the typecast (null) (not in name, but in usage). Very little new about this, and it is a good thing : it is gone for good.

 
<?php 
   (unset) $foo; 
?> 

Exakat spots those with the rule Cast unset usage.

Declaration of A2::B($c, $d = 0) must be compatible with A1::B(&$c, $d = 0)

Checking for method compatibility used to be a warning in PHP 7, and it is now a Fatal error at linting time. The method signature in a parent and its child class must be compatible. It means a lot of different things, depending on visibility, reference, typehint, default values. It is worth a whole article by itself.

The important part is three folds : first, PHP 8.0 emits a Fatal error at compile time for that. So, your PHP 7.0 may hurt on 8.0. If you can fix it now.

 
<?php 
class A1 { 
   function B(&$c, $d = 0) {} 
}

class A2 extends A1 { 
  function B($c, $d = 0) {} 
}

?> 

The second important part is that it only works when PHP lints both classes (parent and child), in the same file, and in the right order : parent first, child second. Otherwise, PHP will only check the compatibility at execution time, and deliver a Fatal error at the worst moment.

The third important part is that compatibility between method signature doesn’t cover argument names. The following code is valid, and a major sleeping bug. Just notice that the variables have been swapped.

 
<?php 
class A1 { 
   function B($c, $d = 0) {} 
}

class A2 extends A1 { 
   function B($d, $c = 0) {} 
}

?> 

Exakat spots those with the following rules Incompatible Signature Methods, and Swapped arguments.

Unterminated comment starting line

Unterminated comment starting line used to be a warning. It is now a parse error.

 
<?php 
/** I always start, but never finish...

Just close the comment, and the code will be good again.

Compile with PHP 8.0 now!

PHP 8.0 moved a significant number of messages from Notice to Fatal errors, and, more importantly, from the execution phase to linting phase. This means that checking your current code with PHP 8.0 is sufficient to bring light on quirky pieces of code that will raise error when you want to upgrade to PHP 8.0. Simply fixing them will also improve your PHP 7.x code!

In the meantime, linting is as fast as it is superficial : it processes files individually, and postpone until execution some of the checks. Static analysis tools cover those situations, and report very early potential bugs and inconsistencies.

Install exakat and run the Migration audit on your code to get even better prepared for the Great Apparition of PHP 8.0. See you next month!

If you are encountering a WordPress error message or white screen, don’t panic. Someone has likely encountered the same message before and it can easily be solved.

This page lists the most common WordPress errors experienced by WordPress users, and provides a starting point for fixing them. At WordPress Support, you will also find links to more detailed pages or forums where a volunteer will be there to help.

The White Screen of Death

Both PHP errors and database errors can manifest as a white screen, a blank screen with no information, commonly known in the WordPress community as the WordPress White Screen of Death (WSOD).

Before resorting to desperate measures, there are a number of reasons for the WordPress white screen of death:

  • A Plugin is causing compatibility issues. If you can access the Administration Screens try deactivating all of your Plugins and then reactivating them one by one. If you are unable to access your Screens, log in to your website via FTP. Locate the folder wp-content/plugins and rename the Plugin folder plugins_old. This will deactivate all of your Plugins. You can read more about manually deactivating your plugins in the Troubleshooting FAQ.
  • Your Theme may be causing the problem. This is especially likely if you are experiencing the white screen of death after you have just activated a new Theme, or created a New Site in a WordPress Network. Log in to the WordPress Administration Screens and activate a default WordPress Theme (e.g. Twenty Twenty-One). If you are using WordPress 5.8 and below, please switch to Twenty Twenty-One theme since the Twenty Twenty-Two theme requires 5.9 and above. If you can’t access your Administration Screens, access your website via FTP and navigate to the /wp-content/themes/ folder. Rename the folder for the active Theme.

The WP_DEBUG feature often provides additional information.

Internal Server Error

Internal Server Error message

There can be a number of reasons for an Internal Server Error. Here are some thing you can do to solve it:

  • The most likely issue is a corrupted .htaccess file. Log in to your site root using FTP and rename your .htaccess file to .htaccess_old. Try loading your site to see if this has solved your problem. If it works, make sure to visit Settings > Permalinks and reset your permalinks. This will generate a new .htaccess file for you.
  • Try deactivating all of your Plugins to see if it is a Plugin issue. If you are unable to access your WordPress Administration Screens, deactivate your Plugins via FTP by following these instructions.
  • Switch the Theme to a WordPress default Theme (e.g. Twenty Twenty-One) to eliminate any Theme-related problems. If you are using WordPress 5.8 and below, please switch to Twenty Twenty-One theme since the Twenty Twenty-Two theme requires 5.9 and above.
  • Increase the PHP Memory limit
  • Try re-uploading the wp-admin and wp-includes folders from a fresh install of WordPress.

Error Establishing Database Connection

If you get a page featuring the message “Error Establishing Database Connection,” this means that there is a problem with the connection to your database and there could be a number of reasons for this. The following are possible reasons and solutions.

Incorrect wp-config.php Information

“Error establishing a database connection” is usually caused by an error in your wp-config.php file. Access your site in your FTP client. Open up wp-config.php and ensure that the following are correct:

  • Database name
  • Database username
  • Database password
  • Database host

Learn more about editing wp-config.php.

If you are sure your configuration is correct you could try resetting your MySQL password manually.

Problems with Your Web Host

The next step is to contact your web host. The following hosting issues may be causing the problem:

  • Your database has met its quota and has been shut down.
  • The server is down.

Contact your hosting provider to see if either of these issues is causing your problem.

Compromised Website

If you have checked wp-config.php for errors, and confirmed with your host for hosting issues, it is possible that your site has been hacked.

Scan your site with Sucuri SiteCheck to ensure that it hasn’t been compromised. If it has you should check out My Site was Hacked.

Failed Auto-Upgrade

There will be situations when the WordPress auto-update feature fails. Symptoms include:

  • A blank white screen and no information.
  • A warning that the update failed.
  • A PHP error message.

The WordPress automatic upgrade feature may fail due to a glitch in the connection with the main WordPress files, a problem with your Internet connection during upgrade, or incorrect File Permissions

To update your WordPress site manually, see the Manual Update article.

Connection Timed Out

The connection timed out error appears when your website is trying to do more than your server can manage. It is particularly common on shared hosting where your memory limit is restricted. Here are some things you can try:

  • Deactivate all Plugins. If deactivating all the WordPress Plugins on your site resolves the issue, reactivate them one-by-one to see which plugin is causing the problem. If you are unable to access your Administration Screens, read about how to manually deactivate your plugins.
  • Switch to a default WordPress Theme. If you are using WordPress 5.8 and below, please switch to Twenty Twenty-One theme since the Twenty Twenty-Two theme requires 5.9 and above. This should rule out any Theme-related problems.
  • Increase your memory limit in wp-config.php. If you are on shared hosting you may have to ask your hosting provider to increase your memory limit for you.
  • Increase the maximum execution time in your php.ini file. This is not a WordPress core file so if you are not sure how to edit it, contact your hosting provider to ask them to increase your maximum execution time. See below instructions for increasing maximum execution time.

Maintenance Mode Following Upgrade

When WordPress updates, it automatically installs a .maintenance file. Following upgrade, you may receive a message that says “Briefly unavailable for scheduled maintenance. Please check back in a minute.” The maintenance file may not have been removed properly.

To remove this message do the following:

  1. Log in to your website using your FTP program
  2. Delete the .maintenance file, which will be found in your site root.

Read more about the maintenance mode issue.

You Make Changes and Nothing Happens

If you are making changes to your website and you do not see the changes in your browser, you may need to clear your browser cache. Your browser stores information about the websites that you visit. This makes it faster to load websites when you visit them because the browser just has to reload information already stored on your computer, rather than downloading it again.

If you make a change to a website and the browser does not think it is significant, it will simply load the data from your cache, and you won’t see your changes. To fix the problem, simply empty your browser cache or close the tab and reopen the link.

Pretty Permalinks 404 and Images not Working

If you are experiencing 404 errors with pretty permalinks and a white screen when you upload images, mod_rewrite may not be enabled in Apache by default. Mod_rewrite is an extension module of the Apache web server software which allows for “rewriting” of URLs on-the-fly. It’s what you need to make pretty permalinks work.

WordPress Multisite networks usually experience this but it can also occur on shared hosting providers or after a site migration or server move.

Reset your permalinks through Settings > Permalinks. If this does not work, you may have to edit the .htaccess file manually.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

If you are not familiar with editing your .htaccess file, contact your hosting provider to ask them to turn on mod_rewrite rules. There is more information on pretty permalinks in the WordPress Codex.

Custom Post Type 404 Errors

You may experience problems with 404 errors and custom post types. Try the following steps:

  1. Make sure that none of your Custom Post Types and single pages have the same name. If they do, rename the single page, including the slug.
  2. Log in to your WordPress Administration Screens, navigate to Settings > Permalinks. Select the default permalinks. Save. Then reselect your preferred permalinks. This will flush the rewrite rules and should solve your problem.

Specific Error Messages

There are a number of different errors that will appear in your error logs. To access your error logs you will need to turn on debugging and then locate your error log via FTP. The following information will help you to decipher some of the common error messages.

PHP Errors

Below are some common PHP error messages.

Fatal Errors and Warnings

If you receive a warning that WordPress cannot modify header information and headers are already sent, it usually means that you have spaces or characters before the opening tags or after the closing tags. Read how to fix the headers already sent error.

If you are experiencing this problem when you have just installed WordPress you may have introduced a syntax error into wp-config.php. These instructions will help you to fix the error.

Call to undefined function

An error reading call to undefined function could mean that a WordPress Plugin is trying to find a file or data which isn’t present or accessible in the code. Reasons for this include:

  • An error when trying to auto-install or auto-upgrade a Plugin. Try installing or upgrading the Plugin manually.
  • An error when trying to auto-install or auto-upgrade a Theme. Try installing or upgrading the Theme manually.
  • You may be using an incompatible WordPress Plugin or incompatible Theme. This could happen with older versions of WordPress and a new WordPress Plugin, or if you are trying to use a WordPress Multisite Plugin on a single site installation. Upgrade WordPress to resolve this issue.
  • You may be trying to call a function that doesn’t exist. Check functions.php for misspellings.

Try deactivating the WordPress Plugin or changing the WordPress Theme that caused the error to appear. If you are unable to do this from within the Administration Screens, you may have to do this manually via FTP.

Allowed memory size exhausted

An Allowed Memory Size Exhausted error means that your WordPress installation doesn’t have enough memory to achieve what you want. You can try out the following steps:

  • Increase your memory limit in wp-config.php
  • Increase your memory limit by editing php.ini. This is not a file that comes with WordPress so if you are unfamiliar with it you should contact your web host about increasing your memory limit.
Maximum execution time exceeded

You may receive a message such as “Maximum execution time of 30 seconds exceeded” or “Maximum execution time of 60 seconds exceeded”. This means that it is taking to longer for a process to complete and it is timing out. There are a number of ways to fix this error.

Editing .htaccess

Make sure you back up .htaccess before you edit it.

Add the following line to .htaccess:

php_value max_execution_time 60

Editing php.ini

Add the following to php.ini

max_execution_time = 60

If you are unsure of how to make these changes, or if you are on shared hosting that prevents you from making them yourself, you should contact your hosting provider and ask them to increase your maximum execution time.

Parse errors

Syntax Error

A syntax error means that you have made a mistake while creating your PHP structure. You could, for example, be;

  • Missing a ; at the end of an individual line.
  • Using curly quotation marks.
  • Missing a curly bracket.

When this error appears it will tell you which file the error appears in (functions.php for example) and approximately which line (it may not always be the exact line so be sure to check just before and just after) in the code.

Unexpected

If you are receiving an error which says ‘parse error: unexpected’ this usually means that you have forgotten to include a character. The most common are:

  • Unexpected ‘=’ : you have forgotten to include the $ when referencing a variable
  • Unexpected ‘)’ : you have forgotten to include the opening bracket (
  • Unexpected ‘(‘ : you have forgotten to include the closing bracket )
  • Unexpected T_STRING: you have forgotten a quotation mark or a semi-colon at the end of the previous line
  • Unexpected T_ELSE: you have an else statement with no opening if statement

Use of an undefined constant

As with parse errors, “use of an undefined constant” means that you are missing a character. It could be one of the following:

  • Missing a $ when referencing a viariable
  • Missing quotation marks around array keys

Database Errors

The following errors may appear in relation to your WordPress database.

Error 13 – Cannot Create/Write to File

There are a number of reasons why you may be experiencing this error.

MySQL cannot create a temporary file. 

The MySQL variable tmpdir is set to a directory that cannot be written to when using PHP to access MySQL. To verify this, enter MySQL at the command line and type show variables. You’ll get a long list and one of them will read: tmpdir = /somedir/ (whatever your setting is.)

To solve this, alter the tmpdir variable to point to a writable directory.

  1. Find the my.cnf file. On *nix systems this is usually in /etc/. On Windows system, Find the my.ini.
  2. Once found, open this in a simple text editor and find the [mysqld] section.
  3. Under this section, find the tmpdir line. If this line is commented (has a # at the start), delete the # and edit the line so that it reads: tmpdir = /writable/dir where /writable/dir is a directory to which you can write. Some use /tmp, or you might also try /var/tmp or /usr/tmp. On Windows, use C:/Windows/tmp.
  4. Save the file.
  5. Shutdown MySQL by typing mysqlshutdown -u -p shutdown.
  6. Start MySQL by going to the MySQL directory and typing ./bin/safe_mysqld &. Usually the MySQL directory is in /usr/local or sometimes in /usr/ on Linux systems.

The file permissions are incorrect

Correct the File Permissions.

If none of this make sense and you have someone to administrate your system for you, show the above to them and they should be able to figure it out.

CREATE Command Denied to User

This error occurs when the user assigned to the database does not have adequate permissions to perform the action to create columns and tables in the database. You will need to log in to CPanel or Plesk to give your database user adequate permissions.

Alternatively you can create a new user to assign to your database. If you do create a new user you will need to ensure that it is updated in wp-config.php.

Error 28

It could be because:

  • you are out of space on /tmp (wherever tmpdir is), or,
  • you have too many files in /tmp (even if there is lots of free space), or,
  • Your cache on your server is full

This is a MySQL error and has nothing to do with WordPress directly; you should contact your host about it. Some users have reported that running a “repair table” command in phpMyAdmin fixed the problem.

Error 145

This indicates that a table in your database is damaged or corrupted. If you are comfortable using phpMyAdmin you can use these instructions on repairing your MySQL database tables.

Always backup your database before performing any actions on it.

If you have not used phpMyAdmin before, or are uncomfortable doing so, contact your web host and ask them to run CHECK/REPAIR on your database.

Unknown Column

An unknown column error can be caused by a missing column in the database. If you have just upgraded WordPress then try manually upgrading again. To update your WordPress site manually, see the Update article.

If you are running a database query when you encounter the error then you may by using incorrect quotation marks for the identifier quote character. This question on Stack Overflow provides more details. Also see the MySQL documentation.

Resources

  • MySQL Error Codes and Messages

A very large percentage of errors are actually quite simple to spot and solve once you are sufficiently experienced.Some of the mistakes are very basic, but trip up even the best PHP programmer. This article highlights common php errors that developers need to beware of.so that you can write error free and clean code . The main think needs to remember while you are doing code is always turn on your error display with

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

However, this doesn’t make PHP to show parse errors – the only way to show those errors is to modify your php.ini with this line.

display_errors = on

1)Memory Exhausted Error: This error will display if any of your function or script is eating your memory . you’ve encountered this error when you see this error message.

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/check.php on line xxx

Solution The error can be resolved with a simple trick

define ('wp_memory_limit', '64M');

2)Warning: Cannot modify header information:The page/output always follows the headers.Functions that send/modify HTTP headers must be invoked before any output is made. Otherwise the call fails and you will see the following warning screen.

Warning: Cannot modify header information – headers already sent by (output started at /path/check.php:125) in /path/check2.php on line 15

why headers must be sent before output:
To understand why headers must be sent before output it’s necessary to look at a typical HTTP response. PHP scripts mainly generate HTML content, but also pass a set of HTTP/CGI headers to the webserver:

HTTP/1.1 200 OK
Powered-By: PHP/5.3.7
Vary: Accept-Encoding
Content-Type: text/html; charset=utf-8
<html><head><title>page titlw</title></head>
<body><h1>page content </h1> <p>page output by php code blaaaaah blaaaaaaaaaah...</p>
and <a href="/"> <img src=internal-icon-delayed> </a>

The page/output always follows the headers. PHP has to pass the headers to the webserver first. It can only do that once. After the double linebreak it can nevermore amend them.

When PHP receives the first output (print, echo,) it will flush all collected headers. Afterwards it can send all the output it wants. But sending further HTTP headers is impossible then.
Cause
1) Whitespace before blocks.
3) Whitespace after ?>
4) Preceding error messages
If another PHP statement or expression causes a warning message or notice being printeded out, that also counts as premature output.

3) Cannot redeclare function: This error screen will visible if you are defining a function second time . may be this function is defined in php library or you define this two time . or you are including file contains this function two time . The error message will look like .

Fatal error: Cannot redeclare functiondemo() (previously declared in /home/u805727311/public_html/wp-includes/functions.php:1684) in /home/u805727311/public_html/path/includes/xyz.php on line XXX

4) Internal Server ErrorThis is the most common error message . The most likely issue is a corrupted .htaccess file. So first of all check your .htaccess file . secondly try to increaso your php memory limit with .

define ('wp_memory_limit', '64M');

5)Call to undefined function:This error will display if you are calling an undefined function or calling a defined function with wrong name . I.e if you are calling is_array() as isarray() then php will throw a fatal error that function is not defined . The error message is

[01-Jun-2011 14:25:15] PHP Fatal error: Call to undefined function myfunction() in /home/accountname/public_html/your user/file/index.php on line 7

6)Unexpected string:If you are receiving an error which says ‘parse error: unexpected’ this usually means that you have forgotten to include a character. The most common are:

Unexpected ‘=’ : you have forgotten to include the $ when referencing a variable
Unexpected ‘)’ : you have forgotten to include the opening bracket (
Unexpected ‘(‘ : you have forgotten to include the closing bracket )
Unepxpected T_STRING: you have forgotten a quotation mark or a semi-colon at the end of the previous line
Unexpected T_ELSE: you have an else statement with no opening if statement


7)Maximum execution time exceeded
: You may receive a message such as “Maximum execution time of 30 seconds exceeded” or “Maximum execution time of 60 seconds exceeded”. This means that it is taking to longer for a process to complete and it is timing out. There are a number of ways to fix this error.solution to this error is either set the execution time at run time with ini_set() or edit your php.ini file to set this

ini_set('max_execution_time', 1000);

8)Use of an undefined constant:As with parse errors, “use of an undefined constant” means that you are missing a character. It could be one of the following:

Missing a $ when referencing a viariable
Missing quotation marks around array keys

9)only variable should pass by reference:Assign the result of explode to a variable and pass that variable to end:

$file_extension = end(explode('.', $file_name));

if you are using the above code it will throw this error .The problem is, that end requires a reference, because it modifies the internal representation of the array (i.e. it makes the current element pointer point to the last element).
The result of explode(‘.’, $file_name) cannot be turned into a reference. This is a restriction in the PHP language, that probably exists for simplicity reasons.

$tmp = explode('.', $file_name);
$file_extension = end($tmp);

10)Undefined index:If you are getting an element from array in which the called index does’t exist then that is an error .The error looks like this

Undefined variable: user_location in C:wampwwwmypathindex.php on line 12

Solution for this problem is
Recommended: Declare your variables. Or use isset() to check if they are declared before referencing them, as in:

$value = isset($_POST['value']) ? $_POST['value'] : '';.

Use empty(), so no warning is generated if the variable does not exist. It’s equivalent to !isset($var) || $var == false. E.g.

echo "Hello " . (!empty($user) ? $user : "");

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request

Понравилась статья? Поделить с друзьями:
  • Common language runtime debugging services как исправить
  • Common error message перевод
  • Common error message альфа банк
  • Common dll mafia 2 ошибка
  • Commit session error