'What is the output value/type of this query?
I've been trying to get the score of a post, which is stored in a MySQL database. I've been able to do this using the following code:
$query_getpostscore = mysqli_query($con,"SELECT score FROM theshitp_posts.mainfeed WHERE id ='$postid'");
$row = mysqli_fetch_array($query_getpostscore, MYSQLI_ASSOC);
$score = mysqli_real_escape_string($con,$row['score']);
However, I was wondering why simply writing the following does not work:
$query_getpostscore = mysqli_query($con,"SELECT score FROM theshitp_posts.mainfeed WHERE id ='$postid'");
Surely this should give the numeric value of the score stored in the database, where id=$id?
Why does the first example work, but not the second?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
