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.

Link to comment
Share on other sites

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
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.