mlk77 Posted January 20, 2014 Share Posted January 20, 2014 I got a script that I'm going to run on my home server and the coder no longer has anything to do with this project and I can't seem to reach him. I installed everything but it's only grabbing the information from the first table. I've been messing around with it and can't seem to figure it out. Ay help would be great! unset ($tanks); require_once("./inc/general_functions.php"); require_once("./inc/Calendar.php"); getHeader(getcwd());?> <h2 align="center" class="center">Fish Tank Database </h2> <?php print getBreadCrumb(); $units = getUnits(); $tanks = getTankObjects(); foreach ($tanks AS $tank) { print "<table cellpadding=\"3\" cellspacing=\"0\" width=\"80%\" class=\"contentTable\" align=\"center\">\n"; print "<tr><td><h3>" . $tank->tank_name . " (<a href=\"./livestock.php?tank_id=" . $tank->tank_id . "\">view livestock for this tank</a> | <a href=\"./expenses.php?tank_id=" . $tank->tank_id . "\">view expenses for this tank</a>)</h3></td></tr>\n"; print "<tr><td>Tank Size: " . $tank->tank_size . " " . $units['size_unit'] . " (" . convertSize($tank->tank_size, $units['size_unit']) . ") </td></tr>\n"; print "<tr><td>" . $tank->tank_desc . "</td></tr>\n"; print "</table><br />\n"; Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/ Share on other sites More sharing options...
dalecosp Posted January 20, 2014 Share Posted January 20, 2014 Is that all of it?That shouldn't even parse (it's missing the closing bracket for the foreach loop ...) ... that could be, of course, the problem. Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465926 Share on other sites More sharing options...
mlk77 Posted January 21, 2014 Author Share Posted January 21, 2014 The complete code for this file is below. It will only show the first entry in the database. I'm trying it on ubuntu server 12.04 <?php /* This file is part of TankLogger. TankLogger is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. TankLogger is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with TankLogger; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Copyright 2002, 2003, 2004 Jason Nugent jnugent@ns.sympatico.ca */ unset ($tanks); require_once("./inc/general_functions.php"); require_once("./inc/Calendar.php"); getHeader(getcwd()); ?> <h2 class="center">Tanks that TankLogger is currently storing data for:</h2> <?php print getBreadCrumb(); $units = getUnits(); $tanks = getTankObjects(); foreach ($tanks AS $tank) { print "<table cellpadding=\"3\" cellspacing=\"0\" width=\"80%\" class=\"contentTable\" align=\"center\">\n"; print "<tr><td><h3>" . $tank->tank_name . " (<a href=\"./livestock.php?tank_id=" . $tank->tank_id . "\">view livestock for this tank</a> | <a href=\"./expenses.php?tank_id=" . $tank->tank_id . "\">view expenses for this tank</a>)</h3></td></tr>\n"; print "<tr><td>Tank Size: " . $tank->tank_size . " " . $units['size_unit'] . " (" . convertSize($tank->tank_size, $units['size_unit']) . ") </td></tr>\n"; print "<tr><td>" . $tank->tank_desc . "</td></tr>\n"; print "</table><br />\n"; } displayVersion(); getFooter(getcwd()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465947 Share on other sites More sharing options...
ginerjm Posted January 21, 2014 Share Posted January 21, 2014 Since you haven't given us a peek at some actual CODE, perhaps you can tell us which of the fields you place in your table are missing? Then we might be able to guess at it. Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465952 Share on other sites More sharing options...
mlk77 Posted January 21, 2014 Author Share Posted January 21, 2014 The last code is the full php file that I'm having the problem with. I have it running on a local server that don't have access to the outside. The Script is called Tanklogger and is on Source Forge but the demo isn't working. It's for keeping informtion on my fish tanks. When it adds information to the data base it should be the tank name, decription of the tank,tank size and the date I set it up. The table for the SQL is CREATE TABLE tanks (tank_id int unsigned auto_increment primary key, tank_name tinytext not null, setup_date datetime not null, tank_size mediumint unsigned not null, tank_desc text not null); I can go in phpmyadmin and change the first tank id to 3 and the second tank information will show. Right now I have 3 tanks listed but the script is only grabbing the first one. Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465955 Share on other sites More sharing options...
ginerjm Posted January 21, 2014 Share Posted January 21, 2014 The query would be most helpful - if we can help at all. Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465956 Share on other sites More sharing options...
mlk77 Posted January 21, 2014 Author Share Posted January 21, 2014 Is this what you need? INSERT INTO `tanklogger`.`tanks` ( `tank_id` , `tank_name` , `setup_date` , `tank_size` , `tank_desc` ) VALUES ( '1', 'Main Tank', '2013-05-19 22:59:12', '60', 'Main fish tank in the kitchen' ); Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465962 Share on other sites More sharing options...
ginerjm Posted January 21, 2014 Share Posted January 21, 2014 That's an insert query - but not a retrieval. Unless your question concerned data not getting on to the table. I thought you were having difficulties retrieving 'all' your data, so this would not be it. Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1465963 Share on other sites More sharing options...
mac_gyver Posted January 21, 2014 Share Posted January 21, 2014 (edited) that script is pretty bad. functions wrapping classes using globals, running queries only to run more queries inside of loops getting the same data the first query could have... start by debugging what data is in $tanks in the code you posted. what does the following show when added right before the foreach(){} loop - echo '<pre>'; var_dump($tanks); edit: see the following reply. Edited January 21, 2014 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1466042 Share on other sites More sharing options...
mac_gyver Posted January 21, 2014 Share Posted January 21, 2014 (edited) actually, i just determined why the code doesn't work. the kid who wrote it didn't have a clue, nor did he test the code, and his database class is storing the result set within the database object, rather than returning an instance of a result object, combined with trying to loop over the result from one query to get more query results. the offending code starts in the getTankObjects() function and the tank class and in the use of the database object. but given how bad just the code for this 'tanks' display is, do you really want to try and go through and fix everything else it is likely doing wrong? Edited January 21, 2014 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1466044 Share on other sites More sharing options...
Solution mlk77 Posted January 22, 2014 Author Solution Share Posted January 22, 2014 Thanks for the reply.. I gave up on that version and downloaded a older version.for some reason his older versions actually look like coding that I can understand. I don't know what was going on on the current version at all. I have the older version working much better. I did start to redo it and figures with all the files it wasn't worth it as you said. I just need to change a few things in that version for photos and should be set. Thanks again!! Quote Link to comment https://forums.phpfreaks.com/topic/285531-script-wont-get-all-database-info/#findComment-1466107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.