Displaying a Mysql database with PHP -
wordpress 4.2.2
i've got connection database working fine. want print or echo table database using php code , display on webpage.
i can't display , think it's because of echo statement. never inserted in echo thinking doesn't require anything. think echo string printing out $row fetches $result has query in it.
i've tried making separate echo , print statement no results.
would have suggestions?
$c = mysql_connect("localhost", "user", "password"); mysql_select_db("database"); $result = mysql_query("select 'hello, dear mysql user!' _message dual"); $row = mysql_fetch_assoc($result); echo htmlentities($row['_message']);
edit: above code copied php.net. below version.
$c = mysql_connect("localhost", "my_user", "f2f3243f2"); mysql_select_db("my_db"); $result = mysql_query("select * fakedb"); $row = mysql_fetch_assoc($result); echo htmlentities($row['_message']);
edit: thank @andrewsi. var_dump($row)
has displayed information wanted.
array(5) { ["charname"]=> string(6) "majaba" ["level"]=> string(1) "3" ["class"]=> string(4) "bard" ["race"]=> string(8) "high elf" ["skills"]=> string(8) "blocking" }
@andrewsi wrote in comment:
check return values query; can
var_dump($row)
see what's in there.
Comments
Post a Comment