Jump to content

maexus

Members
  • Posts

    191
  • Joined

  • Last visited

    Never

Everything posted by maexus

  1. Stupid mistake, it can't be less than 0. Duh. Can't believe I missed that.
  2. Ok, this is a little complicated to explain so I will put down my code first. Here is what I have: <?php header('Content-Type: text/plain'); $hours = array(); for ($a=0; $a < 35; $a++) { $hours[$a] = array(); for ($b=0; $b < 6; $b++) { $seconds = mt_rand(1, 5); $hours[$a][$b] = '0:0:'.$seconds; } echo (implode("\t", $hours[$a]))."\n"; } ?> and this is what it generates: 0:0:3 0:0:2 0:0:1 0:0:3 0:0:3 0:0:3 0:0:5 0:0:4 0:0:5 0:0:3 0:0:2 0:0:5 0:0:1 0:0:2 0:0:3 0:0:3 0:0:4 0:0:1 0:0:4 0:0:1 0:0:5 0:0:5 0:0:3 0:0:4 0:0:1 0:0:1 0:0:2 0:0:1 0:0:4 0:0:5 0:0:4 0:0:4 0:0:2 0:0:4 0:0:3 0:0:3 0:0:2 0:0:4 0:0:3 0:0:1 0:0:2 0:0:4 0:0:1 0:0:1 0:0:2 0:0:5 0:0:2 0:0:1 0:0:1 0:0:3 0:0:5 0:0:4 0:0:1 0:0:2 0:0:3 0:0:4 0:0:3 0:0:1 0:0:4 0:0:1 0:0:4 0:0:3 0:0:4 0:0:2 0:0:1 0:0:5 0:0:2 0:0:2 0:0:1 0:0:1 0:0:3 0:0:4 0:0:1 0:0:2 0:0:5 0:0:2 0:0:5 0:0:1 0:0:4 0:0:3 0:0:5 0:0:5 0:0:4 0:0:2 0:0:5 0:0:3 0:0:2 0:0:1 0:0:4 0:0:1 0:0:4 0:0:4 0:0:3 0:0:1 0:0:5 0:0:1 0:0:2 0:0:1 0:0:1 0:0:1 0:0:2 0:0:2 0:0:4 0:0:3 0:0:4 0:0:3 0:0:1 0:0:3 0:0:2 0:0:5 0:0:2 0:0:2 0:0:5 0:0:5 0:0:5 0:0:3 0:0:2 0:0:1 0:0:4 0:0:5 0:0:5 0:0:4 0:0:5 0:0:2 0:0:1 0:0:4 0:0:2 0:0:5 0:0:1 0:0:1 0:0:2 0:0:5 0:0:5 0:0:3 0:0:5 0:0:3 0:0:4 0:0:3 0:0:2 0:0:2 0:0:1 0:0:3 0:0:4 0:0:1 0:0:2 0:0:3 0:0:2 0:0:4 0:0:5 0:0:5 0:0:2 0:0:4 0:0:5 0:0:3 0:0:1 0:0:2 0:0:2 0:0:3 0:0:5 0:0:2 0:0:5 0:0:4 0:0:1 0:0:5 0:0:2 0:0:2 0:0:2 0:0:1 0:0:2 0:0:1 0:0:1 0:0:4 0:0:4 0:0:2 0:0:4 0:0:1 0:0:2 0:0:3 0:0:2 0:0:5 0:0:1 0:0:3 0:0:5 0:0:1 0:0:1 0:0:5 0:0:4 0:0:4 0:0:1 0:0:4 0:0:2 0:0:1 0:0:2 0:0:4 0:0:5 0:0:5 0:0:4 0:0:2 0:0:4 0:0:4 0:0:5 0:0:1 0:0:2 0:0:4 0:0:5 0:0:1 0:0:4 0:0:5 0:0:1 0:0:5 Here is what I've tried but it only pulls from the random(1,10) not choosing between the 1,10 and 1,5: <?php header('Content-Type: text/plain'); $hours = array(); for ($a=0; $a < 35; $a++) { $hours[$a] = array(); for ($b=0; $b < 6; $b++) { if($a < 0){ $previous = $a - 1; if($hours[$previous] > 5){ $seconds = mt_rand(1, 5); }else{ $seconds = mt_rand(1, 10); } }else{ $seconds = mt_rand(1, 10); } $hours[$a][$b] = '0:0:'.$seconds; } echo (implode("\t", $hours[$a]))."\n"; } ?> Can anyone help? If you need more information, please check http://codeigniter.com/forums/viewthread/103084/
  3. I'm using the CI framework and home is my default controller. Redirecting to home is more aesthetic than functional. Just wondering how to do it.
  4. That didn't work unfortunately. Maybe I should reword it. I need http://domain/app to redirect to http://domain/app/home but I don't know what the "app" is going to be named so is there a way to set the mod_rewrite to be relative to the current directory?
  5. I’m trying to figure out what to add to my htaccess to redirect “/” to “/home” but to complicate things, the app may not be in the root directory. It could be a sub directory, like this: http://localhost/app/ to http://localhost/app/home I have tried looking at mod_rewrite tutorials but still can’t get it to work. This is what I’ve tried. RewriteRule ^/$ /home Which, does nothing. Please help!
  6. JSON is javascript object notation. http://en.wikipedia.org/wiki/Json and I don't think that will work. I still have to assign the object to something so I can access the data inside. It's a moot point at this point anyways.
  7. Here is the issue. I'm building an app entirely from JS script at work as we can not use server side scripting, at all which means I can't use a database. Since my dataset is small, I decided to put the information in to a *.json file. I know writing to it will be an issue but right now my issue is getting the json in to my javascript and in to a usable form. What is the best way to import the contents of that json file in to an array or object I can use? BTW, this is my first major use of javascript so be kind
  8. What ever works best for you and the project you are working on. Your welcome.
  9. For results I store in the object as well as return them so it gives me options. You can certainly use the many DB objects/abstractions that are out there if you wish.
  10. I'm not sure if I'm understanding what you are trying to do but here is what I gathered. You want users to create forum like posts where they are able to have both text and images. You can do this a couple of different ways. You can allow HTML and they can use the <img/> tag OR You can implement a simple BBcode system that uses or [image] or however you choose to implement that.
  11. You are declaring the document as a jpeg yet you are trying to output text. That doesn't make any sense.
  12. Directly in PHP? No.. Or I should say not realistically. You can use PHP to call external programs to do it or if you have an video converter extension for PHP you could.
  13. Ajax is simply a way to send and recieve data to and from the server asynchronously. That's it. I think a lot of people completely misunderstand what Ajax is. The bottom line is, ajax can be very useful for some applications but your site should still be 100% functional if javascript is disable. This is true anytime you use ajax.
  14. You will most likely need to import the contents of the css file in PHP, regex the javascript out and then display the css as inline vs linking to it.
  15. You posted: $username = md5($username); it should be: $password = md5($_POST['password']); No offense but why don't you try it to see if it works.
  16. MD5 is not encryption, it's a hash. One way. Once you hash it, you can't get the information back without extensive rainbow tables (which is a subject for different day). It's common to hash the password when the user registers/changes password and store the hash in the db then when they go to logon, hash the password they enter and compare.
  17. This may help, I had a similar issue. http://www.phpfreaks.com/forums/index.php/topic,201355.0.html
  18. Just an FYI, user agent strings can be spoofed. You can never trust information coming from the users side.
  19. A user's object should only have to worry about user's information. Not the uploading, editting or viewing of photos. If the photos are stored in a gallery format, the galleries may have an id that can be stored in a user's object, just for reference. Then you could have a gallery object for managing and organizing photos and a photos object for editting, outputing the images. You should always try to break down resposibilities are far as possible within reason (some may argue that)
  20. My core objects come into life when needed. Not every page needs a db for my projects. My objects are created on the page that needs them, no blanket creations.
  21. I don't think it's the lack of please they are poking fun at. It was how broad and general of a question. Also, most people ask for help on code they are working on. You make it sound like you just want a solution. Many only help those who help themselves.
  22. Well, I was more thinking about how that foo class should be functional without relying on the db class. It's requesting and getting data from *insert data source* so if my friend wanted to drop foo into his app, he could use his db object as the data source without having to modify foo. So basically, foo is depenant on a data source but not a specific one. Is there a design pattern or a way of doing this? I want to keep objects seperate but have them work together. Like puzzle pieces.
  23. One thing I noticed right away, $pr[boost]; should be $pr['boost']; and it wouldn't hurt to have back ticks for your field and tables names in your query
  24. I was going to post a new topic about this but figured I would use this one to reduce the noise. If you reference your db object or create a db object inside of a class you are working on, doesn't that tie that class to your db class? That's the trouble I'm running into with the framework/library I'm writing. I want objects to be able to interact with the database but not directly or in a means that that the my db class is required for the object to work. I remember someone mentioning using a data mapping class but I can't find that thread. Can someone point me in the right direction?
  25. Looks good, seems to work fine when I replaced the old get() method. There is an oddity. If there is one too many indexes, it only outputs the first character of the previous index. Like if I select get("db__host__test") and db__host is "LOCALHOST" but the index test doesn't exist, it will return "L". However, if I add another non existent index get("db__host__test__another") it outputs the following error: Fatal error: Cannot use string offset as an array Like I said, an oddity, just a warning for anyone who may use the code.
×
×
  • 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.