Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. As one who's lost many cats, I'm sorry to hear that. I'm a cat person. I can't remember a time growing up that we didn't have at least one cat but we often had as many as five. I grew up by a hilly area so most of our cats just disappeared, probably to predators like coyotes and mountain lions. I don't think we ever had a cat that lived longer than 5 years. Now I own my own place with my fiance and we have two cats; the story of how we got them is rather funny and I can elaborate on it if anyone wishes. Anyways, I still live nearby where I grew up and I know how dangerous it is for them to be going in and out of the house, so they're indoor cats. They often sit at the window or sliding door and look out, sometimes I put a leash one one of them and let them wander around in the grass outside. [attachment deleted by admin]
  2. You will go much further when programming if you exhaustively test your own code and logic before assuming there is a bug in the software you are using. Think about this logically. Selecting data from a database and displaying it via a loop is probably one of the most common functions of any PHP script. The chances of you blindly stumbling across a bug in PHP, Apache, or MySQL while performing this operation are slim-to-none when you consider the millions of PHP scripts in existence that already perform this function. Mind you I'm not trying to deride you or make you feel bad; I'm merely explaining why: is a wild conclusion. When debugging your scripts, stick with what you know. I'll walk you through it one step at a time. 1) You know that your script is executing and looping, thus we can assume there are no syntax errors and that everything is likely correct up until the looping portion. So we examine the loop: <?php for ($i=0; $i<$mainQuery;$i++) { ?> <tr> <td><?php echo $mainQuery[$i]['EventKey']; ?></td> <td><?php echo $mainQuery[$i]['FirstName']; ?></td> <td><?php echo $mainQuery[$i]['LastName']; ?></td> <td><?php echo $mainQuery[$i]['EventName']; ?></td> <td><?php echo $mainQuery[$i]['EventDescription']; ?></td> <td><?php echo $mainQuery[$i]['EventDate']; ?></td> <td><?php echo $mainQuery[$i]['EventHours']; ?></td> <td><?php echo $mainQuery[$i]['EventKey']; ?></td> <td><?php echo $mainQuery[$i]['RegNo']; ?></td> <td><?php echo $mainQuery[$i]['SubHead']; ?></td> </tr> <?php } ?> 2) The body of the loop only echoes data, so we can assume it is irrelevant to the fact that the loop is looping forever. So let's just imagine the body isn't there. <?php for ($i=0; $i<$mainQuery;$i++) { ?> <?php } ?> 3) Well, it certainly looks like the loop is set up correctly. We start at zero and iterate until $i is less than $mainQuery. But we are looping forever, let's print $mainQuery to see if it is what we expected it was: <?php echo '<pre style="text-align: left;">' . print_r($mainQuery, true) . '</pre>'; <?php for ($i=0; $i<$mainQuery;$i++) { ?> <?php } ?> 4) At that point you would have seen the contents of your array dumped to the screen and a lightbulb should go off in your head. You can't compare an int to an array and expect a meaningful result. This means that you must either change the upper constraint on your loop (so that it is an integer) or change your loop from a for to a foreach.
  3. Well you just answered your own question then. If $mainQuery is an array and you are using this loop: for ($i=0; $i<$mainQuery;$i++) { then you are comparing a number to an array. When debugging, it helps to be methodical and observant; jumping to wild conclusions rarely helps.
  4. If you have millions of active users, then you are probably making a fair amount of money through advertising. If that's the case, you can probably afford some sort of load balancing solution that will be much more effective, as well as not creating all sorts of complicated programming problems.
  5. What are you saving in the session when the user logs in?
  6. If you look at the link I gave you, there are MySQL examples of joining data on multiple tables.
  7. I don't understand why when a guest goes to your page and selects a club to view you can't just keep track of the club in a session or something. Why create a hidden account?
  8. We're not here to write your code for you, go to the freelance board if that's what you're after. Otherwise, make an honest attempt at writing the code and come back when you get stuck.
  9. Why don't you just use an INNER JOIN? http://dev.mysql.com/doc/refman/5.0/en/join.html
  10. You could also look into output buffers: ob_start(); include('file.php'); $tbcontent .= ob_get_contents(); ob_end_clean();
  11. I'm going to approach this from a different direction. Unless there are constraints on you that you have to use IIS, is there any reason why you're not just using a one-in-all package like XAMPP? I can appreciate if you have to stick with IIS for technical reasons, or if you just like going through the process, but if your current goal is to just learn phpMyAdmin it seems silly to give yourself extra road blocks. Just thought I'd throw that out there.
  12. Those kinds of mistakes don't happen any less with time, but you do get better at finding them. The simple thing to do here would have been echo your $friends_select right before the mysql_fetch_assoc() call; note that when echo'ing variables for debugging it helps to copy and paste the variable rather than retyping it as you may retype it correctly. I once lost a half an hour because of incorrect capitalization on a 'c' in a variable name, 'c' and 'C' can look so similar. Another [uncommon] but very, very tricky error, is when someone accidentally places a semicolon after the closing parenthesis of a conditional or loop.
  13. You changed your variable name in the mysql_fetch_assoc() line: $friend_select ==> $friends_select
  14. teng, removing the parentheses is just going to screw up the query logic. The query that was run from the code I gave him looks correct. @Chevy, paste your code from the moment you create the query until you try to call mysql_fetch_assoc(). If you left the or die() in there and it didn't trigger, then the query was syntactically correct and the problem must be elsewhere.
  15. I think I understand pretty well. You have a web page referring to an item that is in a protected directory, thus the user is prompted with an authentication dialog. You do not want the user to have to authenticate to view this item. So again, my question to you is, if you don't want the user to have to authenticate to view the .swf file, why did you place it inside of a protected directory? Why not just place it in a public folder? To answer your question, I'm not entirely sure. But I would imagine if you created another .htaccess file in your "converted" directory and turned off the authentication that might help. I would check the apache docs and the associated directives you're using. Again, I have to wonder why you're placing something you seem to want available publicly inside of a protected directory.
  16. What would be the point of placing unprotected content inside of a protected folder?
  17. Certifications: a:4:{ Is that all printing the row gives you? That's not a valid serialized piece of data. If that's the case then your problem lies in the code that inserts it into the database.
  18. Try this and paste the output: $friend_select = "SELECT * FROM `friends` WHERE (`from`='$global[username]' AND `accepted`='Yes') OR (`to`='$global[username]' AND `accepted`='Yes') "; echo '<pre style="text-align: left;">' . print_r($friend_select, true) . '</pre>'; $q = mysql_query($friend_select) or die('Error: ' . $friend_select . ' ## ' . mysql_error());
  19. Your error is due to variable scope. A variable declared in one method is not visible in a different method anymore than the same variable declared in one function is visible in another function.
  20. Change your code to give you more meaningful information for the purposes of debugging: $friend_select = mysql_query("SELECT * FROM `friends` WHERE (`from`='$global[username]' AND `accepted`='Yes') OR (`to`='$global[username]' AND `accepted`='Yes') ") or die('Error: ' . mysql_error()); Your problems are no more urgent than anyone else seeking free help.
  21. No. Via normalization. 1) Normalization: http://en.wikipedia.org/wiki/Database_normalization http://databases.about.com/od/specificproducts/a/normalization.htm 2) Will these categories be nested? http://dev.mysql.com/tech-resources/articles/hierarchical-data.html That may get you started.
  22. You're going to run into a problem with your current implementation of the Singlestantiator; I had this thought when I originally saw it but didn't bother to test my instinct until now. <?php define( 'NL', "\n" ); class Singlestantiator { private static $instantiated = false; public function __construct(){ echo 'Singlestantiator::__construct() entering...' . NL; if(self::$instantiated){ echo 'Too late buddy, somebody beat you to it.' . NL; } self::$instantiated = true; echo 'Singlestantiator::__construct() leaving...' . NL; } } class A extends Singlestantiator { public $member = 'A'; public function __construct(){ echo 'A::__construct() entering...' . NL; parent::__construct(); echo 'A::__construct() leaving...' . NL; } } class B extends Singlestantiator { public $member = 'B'; public function __construct(){ echo 'B::__construct() entering...' . NL; parent::__construct(); echo 'B::__construct() leaving...' . NL; } } header('Content-type: text/plain'); echo 'Testing...' . NL; $a = new A(); $b = new B(); ?> Outputs: Testing... A::__construct() entering... Singlestantiator::__construct() entering... Singlestantiator::__construct() leaving... A::__construct() leaving... B::__construct() entering... Singlestantiator::__construct() entering... Too late buddy, somebody beat you to it. Singlestantiator::__construct() leaving... B::__construct() leaving... I don't know. Maybe you didn't intend to use it as a base class for every singleton within your application, but then I wouldn't see much use for it. It's easily fixed if you change $instantiated to an associative array of parentClassName => bool.
  23. @448191, I'm curious what your thinking is on my approach. My method doesn't require the class be able to globally fetch instances of itself, although you could argue that they're not true singletons (but then others may argue that's a good thing). Again, my implementation doesn't require the factory / registry to know anything about how the object should be created. It merely passes on anything it received to the object's constructor.
  24. I inherited the application I maintain at my full-time job and I don't currently do any freelance work, so I do it the way the original programmer implemented it. Lot's of: function blahblah(){ global $_db, $_sessObj; } I die a little inside every time I type it. I've been thinking about taking on some freelance work and almost thought about developing my own framework to do so, but then I realized I'd be so caught up in developing the framework I'd never do any freelance work. So I'm forcing myself to develop a site in cakePHP (despite it's faults) for the sake of overcoming my need to control every piece of software I use. I get some bright ideas here and there, but unfortunately I don't have the resources to implement them. I've got what I think is a pretty good one right now, but I think only the software giants have the resources to pull it off. I think it'd sweep the current business software model right off it's feet though.
×
×
  • 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.