What is Resource # – PHP MySql

Are your trying to print_r or echo the results of a mysql query to your database and just get resource #10 or resource #5 or something similar. I found this somewhere that may explain the problem.

When you use mysql_query(), it really returns a reference to a result resource, which is parsed by mysql_fetch_* functions. If you directly echo out the resource, PHP just gives you the resource number. You need to actually use one of those mysql_fetch_* functions.

Solution:

1
2
3
4
$query = "SELECT * FROM table1 WHERE column=value";
	$result = mysql_query ($query);
	       $row = mysql_fetch_array($result);
                      print_r("$row");
0 Be the first to like this.