This is a discussion on Why does the word "Array" show on a select query within the PHP Language forums, part of the PHP Programming Forums category; Hello, I am new to php and MySQL and I'm attempting to run a select query on a MySQL ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I am new to php and MySQL and I'm attempting to run a select query on a MySQL database which is working fine except prior to displaying the table with the results from the select query it displays 1 line for each row in the database containing only the word Array. This is then followed by the correct results in the constructed table. I am not storing the string "Array" in my table. Following is the PHP code for constructing the table from the results variable. for ($i = 0; $i < mysql_num_rows($result); $i++) { echo "<tr>"; echo $row = mysql_fetch_row($result); for ($j = 0; $j < mysql_num_fields($result); $j++) { echo("<td>" . $row[$j] . "</td>"); } echo "</tr>"; } I hope this is enough of the PHP script to solve the problem TIA Vic |
|
|||
|
Never Mind I see the problem. The statement "echo $row = mysql_fetch_row($result);" should not be an echo. It's amazing but the solution to the problem is always clear within a few minutes after I post the question. "Vic Spainhower" <vic@showsec.com> wrote in message news:h6adnVp5VswyMb3fRVn-gg@comcast.com... > Hello, > > I am new to php and MySQL and I'm attempting to run a select query on a > MySQL database which is working fine except prior to displaying the table > with the results from the select query it displays 1 line for each row in > the database containing only the word Array. This is then followed by the > correct results in the constructed table. I am not storing the string > "Array" in my table. > > Following is the PHP code for constructing the table from the results > variable. > > for ($i = 0; $i < mysql_num_rows($result); $i++) > { > echo "<tr>"; > echo $row = mysql_fetch_row($result); > for ($j = 0; $j < mysql_num_fields($result); $j++) > { > echo("<td>" . $row[$j] . "</td>"); > } > echo "</tr>"; > } > > I hope this is enough of the PHP script to solve the problem > > TIA > > Vic > > > |
|
|||
|
Line 4:
echo $row = mysql_fetch_row($result); That's your problem. If you try to echo an array in php it will print "Array". Try print_r($row) or var_dump($row) if you actually want to print the array's contents Cheers Vasilis |