Here is my problem in a nutshell; I'm trying to connect to a mysql database and run a query that only gives one result, and get that data and bring it inside a variable in php.
$dbp = mysql_connect("localhost", "username", "password");
mysql_select_db("exampledb", $dbp);
$sql = "SELECT data FROM 'exampletable' WHERE id=1";
$data = mysql_query($sql, $dbp);
print $data;
This code does not give the value of the query result, but rather gives something strange. When I searched around, I found out that people used mysql_fetch_field() to get data. But as in my case, I'm only getting one value.. or maybe I'm totally wrong. Please could someone help me with this problem?
mysql_query() returns a result set that is a PHP resource. In order to extract the data out of it, you need to use one of those 2 functions. For example, if you use mysql_fetch_assoc():