There is a table, there is a request for output

$sqlpre = mysql_query("SELECT `like` FROM `base` WHERE `id` = 31"); $sqlpreone = $sqlpre + 1; 

But instead of assigning the value of the column like from an entry with id = 31 to the variable $sqlpre , it assigns an incomprehensible thing (it seems 5).

How to fix it? I need to make so that the variable $sqlpre assigned a value that is in the like column of an entry with id = 31, and after all this, the variable $sqlpreone assigned the value of the variable $sqlpre + 1

  • To "fix", you should at least read the documentation and see examples there - BOPOH
  • @BOPOH after reading really came to msql_result (), thanks) - Nikolay

2 answers 2

Surprisingly, for this you need to read the documentation on how to use the mysql_query function and see examples of its use.

In the process, you should also pay attention to the big red inscription that this function is outdated, and instead you should use PDO

 $like = $pdo->query("SELECT `like` FROM `base` WHERE `id` = 31")->fetchColumn(); $like = $like + 1; 
     $sqlpre = mysql_result(mysql_query("SELECT `like` FROM `base` WHERE `id` = 31"),0); $sqlpreone = $sqlpre + 1; 

    I must say that mysql_query() and mysql_result() are outdated long ago.

    • Thank you very much, but if they are outdated, what can be replaced with? - Nikolay
    • PDO. See post Ipatiev - mix