Wordpress 4.2.2
I've got the connection to my database working just fine. Now I just want to print or echo a table from my database using this php code and display it on my webpage.
I can't get it to display anything and I think it's because of the echo statement. I never inserted anything in the echo thinking that it doesn't require anything. I think the echo string is printing out $row which fetches $result which has my query in it.
I've tried making a separate echo and print statement with no results.
Would anyone have any suggestions?
$c = mysql_connect("localhost", "user", "password");
mysql_select_db("database");
$result = mysql_query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = mysql_fetch_assoc($result);
echo htmlentities($row['_message']);
EDIT: above is the code I copied from php.net. Below is my version.
$c = mysql_connect("localhost", "my_user", "f2f3243f2");
mysql_select_db("my_DB");
$result = mysql_query("SELECT * FROM fakeDB");
$row = mysql_fetch_assoc($result);
echo htmlentities($row['_message']);
EDIT: Thank you @andrewsi. var_dump($row)
has displayed the information I wanted.
array(5) { ["CharName"]=> string(6) "Majaba" ["Level"]=> string(1) "3" ["class"]=> string(4) "Bard" ["race"]=> string(8) "High Elf" ["skills"]=> string(8) "Blocking" }