Verification: a143cc29221c9be0

Php check if sql error

User guide

To check syntax code:

  • First, Drag and drop your PHP file or copy / paste your PHP text directly into the editor above.
  • Finally, you must click on "Check PHP syntax" button to display if there is an syntax error in your code.

PHP code checker tool

PHP is a server-side scripting language, but can also be used as a general-purpose programming language.

PHP error checker tool allows to find syntax errors (lint). You can test your PHP code online directly in your browser.

If a syntax error is detected, then the line in error is highlighted, and it jumps to it to save time (no need to search the line).

It can be useful to make online test to save time (deployment ...).

Note: If you want to run php code you can use our PHP Online tool.


An API is available to test the syntax of your php scripts.


Check the PHP syntax. PHP versions: 5.6.40, 7.4.8, 8.0.0.


JavaScript example:

const request = new XMLHttpRequest();"POST", "", true);
request.onreadystatechange = () => {


Success: 200

   "stdout":"No syntax errors detected"

Error: 400

    "code": 4294967295,
    "stdout": "\nParse error: syntax error, unexpected 'dir' (T_STRING) in file on line 3\nErrors parsing file\n"

Error: 500

PHP version is not available


I suggest that you use the mysqli method below as mysql will at some point in the near future be removed from the language as it is deprecated! If you continue to use it and create sites/apps with it then when this eventually happens you'll either have to use an old version of php which has it's own risks/limitations attached or face having a lot of broken code to fix...



$query = mysql_query("SELECT * FROM cursus01");

    //Rows are returned
    while($row = mysql_fetch_assoc($query)){
        //Do stuff with row data


$mysqli = new mysqli('localhost', 'root', 'root', 'cursuson');

$result = $mysqli->query("SELECT * FROM cursus01"); 

    //Rows are returned
    while($row = $result->fetch_assoc()){
        //Do stuff with row data

I assume that you are actually trying to echo a count of the number of rows returned? Your current code echos a count of the number of coulmns. If you don't know already it would suggest that there are bigger problems here....