Teonynn Posted June 26, 2008 Share Posted June 26, 2008 <?PHP $link = mysql_connect("localhost","*****","*****"); mysql_select_db("*****"); $result = mysql_query("SELECT series FROM fla_banner") or die(mysql_error()); $row = mysql_fetch_array($result); echo $row; mysql_close($link); ?> I have been trying to get a PHP link to dip into a database and return a single value, but for some reason... each time I try to get this thing to work it just returns "array", rather then "2008A-70", the variable stored in the database. I have no idea what's going on here.. being pretty new to PHP in general and mySQL, and was wondering if anyone would be willing to take a look at this. All the code needs to do is to return the one piece of data in the collum and print/echo it out. Quote Link to comment Share on other sites More sharing options...
ocpaul20 Posted June 26, 2008 Share Posted June 26, 2008 var_dump($row); // this is the whole row as an array of values echo $row['FIELDNAME']; // this is an individual value Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 26, 2008 Share Posted June 26, 2008 mysql_fetch_array() returns an array containing data from the current row that has been selected. To access an element of the array, you'll need to provide the key -- which is either 0 or the field name (the default behaviour of mysql_fetch_assoc is that it gives both a numerically indexed array and an associatively indexed array. See the manual for more) So echo $row['series']; //or echo $row[0]; Quote Link to comment Share on other sites More sharing options...
Teonynn Posted June 26, 2008 Author Share Posted June 26, 2008 Thank you! [ -0- ] made the whole thing work like a charm. Now I just have to get Flash to read this properly. Edit: Er... whoops. Original post for some reason didn't like doing zero in brackets and changed the symbol on me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.