-3

Whenever I try to echo that it just outputs 'Resource Id #8'. Does anyone know why?

$blurb = mysql_query("SELECT `blurb` FROM `users` WHERE id='" . $_SESSION[user_id] . "'");
Adam S.
  • 307
  • 3
  • 14
SamHuckaby
  • 1
  • 1
  • 2

2 Answers2

1

From the manual:

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.

John Conde
  • 212,985
  • 98
  • 444
  • 485
0

mysql_query return a resource. If you want to get result. you should use mysql_fetch_array() or mysql_fetch_row() etc, after mysql_query()

So your code will become

$blurb = mysql_query('your query');
$result = mysql_fetch_array($blurb);

var_dump($result);
pveyes
  • 413
  • 2
  • 12