|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10861 Array bug w/MySQL
Submitted: 2001-05-14 16:59 UTC Modified: 2001-05-14 17:34 UTC
From: czaries at hotmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.0.5 OS: Unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
47 - 38 = ?
Subscribe to this entry?

 [2001-05-14 16:59 UTC] czaries at hotmail dot com
When trying to put a value from a database into an array for checking, it jsut won't do it...

Like this:
$board_r = mysql_query("SELECT * FROM mb_boards WHERE BoardID='$BoardID'", $link);
$board = mysql_fetch_row ($board_r);
$userarr = array($board[9]);

When I try to call $userarr at a later date, all it prints is: "Array" - and it doesn't put the contents of that veriable into the array, even though the contents of the cell are separated with commas and all the proper stuff needed for an array!

Please help me!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-14 17:06 UTC]
user error:

change this line:
$userarr = array($board[9]);

$userarr = $board[9];

and mysql_fetch_row gives one row per call

 [2001-05-14 17:34 UTC]
You can't "print" an array in PHP.  You either need to loop through the array and print each element, or use something like print_r() or var_dump() to see the contents of the array.

I bet this will work for you:

$board_r = mysql_query("SELECT * FROM mb_boards WHERE BoardID='$BoardID'", $link);
$board = mysql_fetch_row ($board_r);
$userarr = array($board[9]);

print_r($userarr);       // this, or ...
echo $userarr[0];     // this.

- Colin
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Oct 15 21:03:43 2021 UTC