Jump to content

TOA

Members
  • Posts

    623
  • Joined

  • Last visited

Everything posted by TOA

  1. $injection_strings = array ( "content-type:","charset=","mime-version… You don't close out your array properly. Fix that first, then check out this sticky for your header errors
  2. In your form, point to your php file in the 'action' paramater. header() is what redirects inside a php file. Jessica's right though, you need to go read some basic tutorials before you dive in head first. I had a useless professor in college too, so I can empathize. PHP is an easy language to teach yourself though.
  3. Looks like half your server is on strike Sorry to have humor at your expense. I'm not that much of a server guy so I'm not sure what to tell you. Hopefully someone with more experience in that area can help out. Sorry I'm not more help.
  4. Definitely a cron job (Apache) or scheduled task(IIS) IMO Just write your script without the sleep call and set the script to run every minute
  5. I didn't test this, but try this <?php // handle processing and declarations first so you don't get header errors error_reporting(-1); class Product{ public $var; public function convertToUpperCase($var){ if(isset($_POST['submit'])){ $this->var = strtoupper($var); return $this->var; } } } if ($_SERVER['REQUEST_METHOD'] == "POST") { // process the form $someval = $_POST['someval']; $product = new Product; echo $product->convertToUpperCase($someval); } else { //display the form <form method="POST"> <input type="text" name="someval" /> <input type="submit" name="submit" /> </form> } ?>
  6. 1. You need a class varaible to hold $this->var. Add public $var; as the first thing in your class definition. 2. You can't use $submit in the class without passing it in. You could potentially check $_POST there since it's a global though. 3. Your script structure is all f'd up. But one thing at a time.
  7. The size of your database shouldn't matter. Scripts don't just stop working for no reason; something changed. And since you didn't mention altering any code, I'd say your guess about the server changing or updating is correct. Do you get any errors? If not, turn on error reporting and post the error message.
  8. Then don't put sleep at the beginning of the script. Increment first, then sleep(). Most likely it will go in a loop of some kind.
  9. += assignment operator Use sleep() to make the script wait
  10. mysql_query returns a resource ID you use with any of the fetch_ functions. So use fetch_result or fetch_row or something similar. For example $post = $mysql_query($sql); while ($row = mysql_fetch_row($post)) { echo $row['somvalue']; }
  11. Then you need to pass it into the method. Something like this class SomeClass { public function useVar($var) { //do something with $var } } $someval = $_POST['someval']; $obj = new SomeClass; $obj->useVar($somevar);
  12. *Edit* Beat again! I really miss the alert that used to come up (maybe I'm just not seeing it !
  13. *Edit* Beat me to it. Also, you'll need to return from convertToUppercase or alternatively echo type again after converting.
  14. That worked brilliantly. Thank you very much!
  15. Sure thing...here it is. -- -- Table structure for table `bg_participants` -- CREATE TABLE IF NOT EXISTS `bg_participants` ( `pid` int(11) NOT NULL auto_increment, `cid` int(11) NOT NULL, `start` date NOT NULL, `end` date NOT NULL, PRIMARY KEY (`pid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ; -- -- Dumping data for table `bg_participants` -- INSERT INTO `bg_participants` (`pid`, `cid`, `start`, `end`) VALUES (2, 5, '2012-08-26', '2012-09-30'); ---------------------------------------------------------------------- -- -- Table structure for table `bg_points` -- CREATE TABLE IF NOT EXISTS `bg_points` ( `pid` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL, `points` varchar(255) collate utf8_unicode_ci NOT NULL, `stamp` datetime NOT NULL, PRIMARY KEY (`pid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=27 ; -- -- Dumping data for table `bg_points` -- INSERT INTO `bg_points` (`pid`, `uid`, `points`, `stamp`) VALUES (1, 1, '1', '2012-09-05 15:29:02'), (2, 1, '1', '2012-09-05 15:24:34'), (3, 1, '1', '2012-09-05 15:27:27'), (4, 1, '1', '2012-09-05 15:27:38'), (5, 1, '1', '2012-09-05 15:28:45'), (6, 1, '1', '2012-09-05 15:41:00'), (7, 1, '1', '2012-09-05 16:31:03'), (8, 1, '1', '2012-09-05 16:34:35'), (22, 1, '1', '2012-09-06 10:49:09'), (21, 1, '1', '2012-09-06 10:48:12'), (20, 1, '1', '2012-09-06 10:47:12'), (19, 1, '1', '2012-09-06 10:45:29'), (18, 1, '1', '2012-09-06 10:44:27'), (17, 1, '1', '2012-09-06 10:23:41'), (23, 1, '1', '2012-09-06 10:49:30'), (24, 1, '1', '2012-09-06 13:16:00'), (25, 1, '1', '2012-09-10 09:53:54'), (26, 1, '1', '2012-09-10 10:14:09'); ---------------------------------------------------------------------- -- -- Table structure for table `bg_roster` -- CREATE TABLE IF NOT EXISTS `bg_roster` ( `rid` int(11) NOT NULL auto_increment, `tid` int(11) NOT NULL, `uid` int(11) NOT NULL, PRIMARY KEY (`rid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ; -- -- Dumping data for table `bg_roster` -- INSERT INTO `bg_roster` (`rid`, `tid`, `uid`) VALUES (4, 3, 2), (3, 2, 1); ---------------------------------------------------------------------- -- -- Table structure for table `bg_teams` -- CREATE TABLE IF NOT EXISTS `bg_teams` ( `tid` int(11) NOT NULL auto_increment, `name` varchar(255) collate utf8_unicode_ci NOT NULL, `pid` int(11) NOT NULL, PRIMARY KEY (`tid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ; -- -- Dumping data for table `bg_teams` -- INSERT INTO `bg_teams` (`tid`, `name`, `pid`) VALUES (2, 'Fake Team', 2), (3, 'Team B', 2); Thanks
  16. That is correct. Using this query gets me an incorrect result. It returns the team that has empty points but it returns the other teams points with it. SELECT `bg_teams`.tid, `bg_teams`.name, SUM(`bg_points`.points) AS total FROM `bg_teams` INNER JOIN `bg_roster` ON `bg_teams`.tid=`bg_roster`.tid LEFT JOIN `bg_points` ON `bg_roster`.uid=`bg_points`.uid INNER JOIN `bg_participants` ON `bg_teams`.pid=`bg_participants`.pid WHERE CURRENT_DATE() BETWEEN start AND end Ie: Team Two - 16 This is what I'm trying to get as a result Team One - 16 Team Two - null Thanks for the help, I appreciate it.
  17. It still ignores NULL; I only get one result when I'm expecting at least two (that's how many there are in my test db - one with points and one with no points). Am I doing something wrong here?? Here's my current query SELECT `bg_teams`.tid, `bg_teams`.name, SUM(`bg_points`.points) AS total FROM `bg_teams` INNER JOIN `bg_roster` ON `bg_teams`.tid=`bg_roster`.tid INNER JOIN `bg_points` ON `bg_roster`.uid=`bg_points`.uid LEFT JOIN `bg_participants` ON `bg_teams`.pid=`bg_participants`.pid AND CURRENT_DATE() BETWEEN start AND end Using all LEFT joins makes no difference, I still only get the one result. Thanks for the help.
  18. I'll give that a shot, thanks!
  19. Thanks for the suggestion. I thought of that and tried that too, just a minute ago. It either returns the same results or incorrect results, the incorrect results being the teams with null points are returned with the point values of the teams that do have points, which are left out. Depends on where I use LEFT instead. If I use LEFT on all of them, it returns the same results as the original query. Hope that makes sense.
  20. Hey guys. I'm hoping someone can help me out. I don't know if I've been looking at this problem too long, having a brain fart or what but I can't seem to figure it out. I'm creating a simple game for work. Users do things for points, and whoever gets the most points at the end of a time period wins. They're organized into teams and there are 'prizes' for both individual and team high scores. All that works fine. What I'm trying to do now is show a leaderboard (sounds simple right? ). I have it working using two queries, but then I have to do a bunch of stuff to it like custom sorting and rearranging to get proper order. I know I can get it using one query which would order it for me too, but I can't get the query correct. What's happening is that it will ignore any teams that have no points (or rather a null total) a. why is that? b. how do I get it to show all the teams, even with a null total? This is what I've got: SELECT `bg_teams`.tid, `bg_teams`.name, SUM(`bg_points`.points) AS total FROM `bg_teams` INNER JOIN `bg_roster` ON `bg_teams`.tid=`bg_roster`.tid INNER JOIN `bg_points` ON `bg_roster`.uid=`bg_points`.uid INNER JOIN `bg_participants` ON `bg_teams`.pid=`bg_participants`.pid WHERE CURRENT_DATE() BETWEEN start AND end Here's the table structure for that: CREATE TABLE IF NOT EXISTS `bg_teams` ( `tid` int(11) NOT NULL auto_increment, `name` varchar(255) collate utf8_unicode_ci NOT NULL, `pid` int(11) NOT NULL, PRIMARY KEY (`tid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ; CREATE TABLE IF NOT EXISTS `bg_roster` ( `rid` int(11) NOT NULL auto_increment, `tid` int(11) NOT NULL, `uid` int(11) NOT NULL, PRIMARY KEY (`rid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ; CREATE TABLE IF NOT EXISTS `bg_points` ( `pid` int(11) NOT NULL auto_increment, `uid` int(11) NOT NULL, `points` varchar(255) collate utf8_unicode_ci NOT NULL, `stamp` datetime NOT NULL, PRIMARY KEY (`pid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=25 ; CREATE TABLE IF NOT EXISTS `bg_participants` ( `pid` int(11) NOT NULL auto_increment, `cid` int(11) NOT NULL, `start` date NOT NULL, `end` date NOT NULL, PRIMARY KEY (`pid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ; Thanks for checking this out.
  21. I would like to change my username please.. DevilsAdvocate --> TOA
  22. Then just add the path to the right directory in the href, before $file <a href='path/to/dir/$file'>$file</a>
  23. Unless I'm missing something.. echo "filename: <a href='$file'>" . $file . "</a><br />";
×
×
  • 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.