Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Well yes this is one of those issues where you have a DATE time so when you specify a date by itself, it gets turned into the equivalent of midnight on that day. You can rectify that by having the dates be '2011-05-02 23:59:59' or you can change those to be > and
  2. What are you trying to do? You don't need to pass a public or private key as a client browser in order to access an https:// page securely.
  3. I don't see anyplace in your code where you assign a value to $_SESSION['firstname'].
  4. Well there you go, a web developer is another name for "php developer."
  5. You do something like: $result = mysql_query("SELECT * FROM inventory WHERE itemNumber=$data[0]"); if ($result) { $recordCount = mysql_num_rows($result); if ($recordCount > 0) { // rest of your current code loop here. } else { // your current code. } } else { die(mysql_error()); }
  6. Well yes I guess I didn't notice that this line is invalid: $recordCount = @mysql_num_rows("Select * from inventory where itemNumber=".$data[0]); What you need to do is do a query and assign that to a variable that will be the result. Then you can use mysql_num_rows() on the result to see if there is one. Just in terms of advice, don't use the @ until you are sure you know what you're doing as it hides errors.
  7. Yes, you need to use an IP address or an entirely different domain.
  8. Did you do any analysis of why that is? I type things in off the top of my head, so there may be some small issue that can be debugged, but I cant tell you that it will do what you originally asked for, in terms of taking the piece of the hostname and looking to see if the last 3 characters are com, net etc.
  9. The way to look at it is that you have a block which includes the category header AND the unordered list that you need to output for every category. Each time you are doing this, it means that you already had a category previously that you need to close out first, by providing the end tags. The only time that is not true, is when you first enter the loop. In that case you don't need to close a ul and div first. You can check that by testing to see if category_id == '', which will only be true on entry intot he while loop. Something like this is closer to what you need: $sql = "SELECT c.name, v.* FROM video v INNER JOIN category c ON c.cat_id = v.cat_id WHERE v.client_id = $customerid ORDER BY c.cat_id, video_id DESC"; $result = mysql_query($sql) or die (mysql_error()); $category_id = ''; while($categoryrow = mysql_fetch_assoc($result)) { if($categoryrow['cat_id'] != $category_id) { if ($category_id != '') { //close up prior list and div } ?> $category_id = $categoryrow['cat_id']; } ?> if (strlen($categoryrow['description']) > $limit) $description = substr($categoryrow['description'], 0, strrpos(substr($categoryrow['description'], 0, $limit), ' ')) . '... read more'; echo $description; ?> } //end category loop ?>
  10. That code doesn't look like it would even work as is, because the leading period of the tld would not be part of the match array. Seems like that array should be array('com', 'net'..... etc); With that said, you could use the same idea and add a conditional check of substr($match[1], -3). if(preg_match( "/^($label)\\.($tld)$/", $line, $match ) && (!in_array(substr($match[1], -3), $tld_list)) && in_array($match[2], $tld_list ))
  11. Typically the reason you're loading this core stuff in is because it is going to be used. In terms of structuring code, the autoloader implementation often depends on a class name convention. You have code that could be handled by the autoloader, which is not only pointless, but a bad idea in most cases, because you don't want to load code that you're never going to use. So the main thing I see missing is that this core code should be used to create some objects that become part of your api. The naming of these objects as well as their visibility is a lot more important than the mechanics of how they got loaded.
  12. http://www.programmershelp.co.uk/ctutorials.php
  13. Hey TLG, I think what you're looking for is: autoload If you want to look at an implementation http://framework.zend.com/manual/en/zend.loader.html and the features they have as well as the thought process that was used might give you some ideas.
  14. This is basically the same problem as the one discussed here: http://www.phpfreaks.com/forums/index.php?topic=331579.msg1560489#msg1560489 Take a look at my answer, as it's the same answer I alluded to previously, when I stated that you need a variable you assign to cat_id to track whether or not you need to start a new category block.
  15. My recommendation would be to learn C. It will help introduce you to a lot of important concepts, and it's also the language still most commonly used to write portable software, and remains close to the hardware, so in learning about things like pointers, you will learn more about how computers actually work. It's also the basis for c++. Since you've learned PHP you will probably be pleasantly suprised at how much c syntax is in PHP for things like loops, if then elses, and increments.
  16. I agree with Ignace that assembler offers a wonderful amount of insight into how the computer really works, as well as insight into how memory is managed, concepts like the heap, stack, memory models, instructions, interrupts, etc., as well as how a high level language implements functions, pass by reference vs. pass by value, and the list goes on and on. You probably never quite look at object the same once you realize they're typically just a data structure with a list of pointers to functions. Personally, I would advise learning C first. I don't see the danger of learning things "wrong" with C, and the simple fact is that C is used to implement C++. Once you understand C syntax its much easier to understand C++ syntax and its idiosyncracies that come from C. Learning C also gives you a nice springboard to looking at things like writing PHP extensions.
  17. There is no reason not to continue with PHP. It can do everything you need it to do, and there's excellent support for talking to facebook from php. Purely from an academic point of view, Perl tends to appeal to sysadmins who already know shell scripting really well. Perl is like the granddaddy of modern scripting languages. Python and Ruby are both object oriented programming languages with huge communities and robust libraries behind them. If you're just itching to learn another language I would take a look at Python and Ruby and see which one most appeals to you.
  18. The other popular image handling library is GD but it does not handle pdf files, so I think that ImageMagick is probably your best bet.
  19. Glad to hear it, and thanks for being a supporter of the forum.
  20. Your update syntax is wrong. It should be UPDATE inventory SET itemNumber='$data[1]', itemDesc='$data[2]', .... WHERE...
  21. The language you know the best. Popular solutions used on Linux servers: perl, php, ruby, python.
  22. That is the basics of it, but since you need some things from category, you want to specify those columns in your list. One way to make this a bit simpler is to use table aliases. I usually use a letter or 2 from the name of the table. This would get you all the columns, but you're probably better off just listing the exact columns you want. $sql = "SELECT c.*, v.* FROM video v INNER JOIN category c ON c.cat_id = v.cat_id ORDER BY c.cat_id, video_id DESC";
  23. You suggested what I would suggest, start with video and inner join to category. For an inner join it really doesn't matter because you only get a row when the join matches values in both tables.
  24. I don't find any of your arguments to be good ones. SQLLite is a throw back to the days of PC databases like Paradox, Access and Dbase. They are just profoundly different technology. SQLLite has no server, so that means that anytime you want to do anything with it, the entire SQLLite code base, as well as all the data and indexes needs to be loaded into memory. This means that for every script, and every user, you will be loading in all that code and data. My opinion is that SQLLite is great for quick prototypes, really small quick and dirty apps, or an app that is going to be deployed on clients, and requires a small local database. -You make a table with myisam and you get set of files for that table. How is that worse than sqllite having a seperate database for each user? -If your server gets compromised it is not going to matter that you have data in seperate files/tables/databases whatever. -People waiting for resources -- just isn't going to be an issue with 100 users, and more than likely any contention issues will be caused by overall load on the system, and is probably just as likely to appear in SQLLite as it would be in mysql. If you're highly concerned with contention, then you should use the innodb engine. You can configure mysql to make tables per file, rather than using the default innodb tablespace, and innodb gives you transactions as well as row level locking. -naming a database after a session id is a horrible idea. Session id's can and should change frequently. I would not put blobs in a database, so I agree with your plan to keep them on the file system. Of course this design also undercuts the importance of concerns about security, since the material you're concerned about will be in directories on the server filesystem anyways. In summary it seems to me that you've assigned advantages to what is in essence a barebones technology, that it does not really have.
  25. Yes of course you get empty categories, because you select all the categories and loop through those spitting out a category header div before you've queried to see if there are any videos for that category. Do you not understand why that is? A call to mysql_num_rows would take care of this problem, as you could check before you otuput either the category div or start the ul. With that said, the best answer is to do a single query that inner joins your video table to category, with an ORDER BY category_id, video_id DESC. You would be doing only one qeuery, getting only one result set, and would need only one loop. You would simply need a variable for category that you check to see if there's a new category which requires you to output a new category section.
×
×
  • 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.