dzhax Posted August 15, 2009 Report 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 Report 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 Report Share Posted August 15, 2009 (edited) i tried fetch_row and a couple more and couldnt get them to work... i dunno ill see if this works than you. Edited August 15, 2009 by dzhax Link to comment Share on other sites More sharing options...
boen_robot Posted August 15, 2009 Report Share Posted August 15, 2009 (edited) 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. Edited August 15, 2009 by boen_robot Link to comment Share on other sites More sharing options...
dzhax Posted August 16, 2009 Author Report Share Posted August 16, 2009 (edited) 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? Edited August 16, 2009 by dzhax Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now