dzhax Posted August 15, 2009 Share Posted August 15, 2009 It doesn't work any idea how to fix?I'm trying the grab the data from the name field in the settings table <?php$con = mysql_connect('localhost', 'username, 'password');if (!$con) die("Could not connect...");$forumSetting = mysql_query("SELECT * FROM `settings`",$con);print("Forum Name: " . $forumSetting['name']);mysql_close($con);?> All that is printing out is: Forum Name: I replaced the mysql_connect with fake values... the actual connect is different values. so dont worry bout that. it connects just fine. Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted August 15, 2009 Share Posted August 15, 2009 <?php$con = mysql_connect('localhost', 'username, 'password');if (!$con) { die("Could not connect...");}$query = mysql_query("SELECT * FROM `settings`",$con);$forumSettings = mysql_fetch_assoc($query);print("Forum Name: " . $forumSetting['name']);mysql_close($con);?> Or you can use mysql_fetch_row, which returns an array with numerical keys, or mysql_fetch_object, which returns an object. mysql_fetch_assoc in my code returns an associative array. Link to comment Share on other sites More sharing options...
dzhax Posted August 15, 2009 Author Share Posted August 15, 2009 i tried fetch_row and a couple more and couldnt get them to work... i dunno ill see if this works than you. Link to comment Share on other sites More sharing options...
boen_robot Posted August 15, 2009 Share Posted August 15, 2009 I see why YOURS doesn't work, but FirefoxRocks' sample should work. What do you get if you do $query = mysql_query("SELECT * FROM `settings`",$con);$forumSettings = mysql_fetch_assoc($query);var_dump($forumSettings); ?If you get "array()", it means that your query is simply not returning any results. Link to comment Share on other sites More sharing options...
dzhax Posted August 16, 2009 Author Share Posted August 16, 2009 thanks anyway boen the other guys worked.Seems like you know alot in this area would u mind taking a look at my most recent post in sql section? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.