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. Link to comment https://forums.phpfreaks.com/topic/111987-solved-help-php-mysql-link-refusing-to-return-the-data-it-should/ 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 Link to comment https://forums.phpfreaks.com/topic/111987-solved-help-php-mysql-link-refusing-to-return-the-data-it-should/#findComment-574834 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]; Link to comment https://forums.phpfreaks.com/topic/111987-solved-help-php-mysql-link-refusing-to-return-the-data-it-should/#findComment-574838 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. Link to comment https://forums.phpfreaks.com/topic/111987-solved-help-php-mysql-link-refusing-to-return-the-data-it-should/#findComment-574871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.