[Solved] PHP sql query isn’t returning anything


From the manual:

Identifiers may begin with a digit but unless quoted may not consist solely of digits.

Which is exactly what you’re doing, and should not be doing.

Solution:

  1. Choose a different name for your table, one consisting of letters preferably.

  2. Use backticks around the table name.

Plus, if you wish to view data, you need to use a loop.

I.e.:

$query="SELECT * FROM `140423` WHERE GAME='Clash of Clans'";

    while ($row = mysql_fetch_assoc($query)) 
            {
                $var = $row["column"]; // the column of your choice
            }

        echo $var;

Rewrite:

$dbc = mysql_connect ('localhost','root','abcde');

if (!$dbc) {
die('Not Connected:' . mysql_error ());
}

$db_selected = mysql_select_db ('db_test', $dbc);

if (!$db_selected) {
die ("Can't Connect :" .mysql_error());
}

$query="SELECT * FROM `140423` WHERE GAME='Clash of Clans'";
//add "result"
$result=mysql_query($query);

// as pointed out already
    if (!$result) {
    die ("Can't Connect :" .mysql_error());
    }

echo $result; // this is up to you

// if you want to see data from your table, loop through it.

    while ($row = mysql_fetch_assoc($query)) 
            {
                $var = $row["column"]; // the column of your choice
            }

        echo $var;

Footnotes:

mysql_* functions deprecation notice:

http://www.php.net/manual/en/intro.mysql.php

This extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used. See also the MySQL API Overview for further help while choosing a MySQL API.

These functions allow you to access MySQL database servers. More information about MySQL can be found at » http://www.mysql.com/.

Documentation for MySQL can be found at » http://dev.mysql.com/doc/.

solved PHP sql query isn’t returning anything