Hi, when I try to use a SELECT statement in php, I get an error:

Resource id #18

$get = mysql_query("SELECT value FROM settings WHERE id=2");
echo $get;

The file session.php contains the database credentials .etc and it's correct.
But then when I try to echo $get, I get the error.

Why, I'm not sure and I'm still learning MySQL/PHP.

Please could someone help and thank you in advance for any replies.

Edited by Dani: Formatting fixed

3 Years
Discussion Span
Last Post by Derice

You just need to read a little more.

Here's one article from a google search. I've picked mysqli rather than mysql as mysql is so last year :-)



When you store the results of an SQL query for example, you need to pass it onto either mysql_fetch_array or mysql_fetch_assoc, and, go through a loop such as foreach, for example to output / use the information retrieved.

Also, since it seems you're relatively new with working with arrays, here's a tip. When working with, or outputting arrays in PHP, you can't simply 'echo' it. You must use a function like print_r, or better yet, use a loop like foreach to navigate through the array.

  • n21115
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.