Jump to content

[SOLVED] Help! PHP mySQL link refusing to return the data it should


Teonynn

Recommended Posts

<?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.

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];

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.  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.