Jump to content

sKunKbad

Members
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by sKunKbad

  1. Unfortunately you will probably end up going back to JavaScript again because it handles stuff that PHP doesn't handle. I started with PHP and didn't get very involved with JavaScript, but then found that I needed it. I now use it all the time. It's not like the old days where JavaScript was considered a option. These days JavaScript is enabled on like 99.99999% of devices. PHP and JavaScript are good friends though. I can't remember when I started in on web design and development, but it's probably been about 10 years. Been using PHP for 8 years. You never stop learning, so that feeling of falling will probably be with you for a couple years until you start feeling more comfortable.

  2. ginerjm is correct, but for the sake of learning what you wanted to do, most of the time you will not be using an IP address, but rather a domain. If you really do need the IP address, you can use the server variable $_SERVER['SERVER_ADDR'].

     

    Likewise, if you really did want to use the domain, you would use $_SERVER['HTTP_HOST'].

     

    Example:

    <?php
    
    $domain = $_SERVER['HTTP_HOST'];
    
    echo '<a href="http://' . $domain . '">Link</a>';
    
    echo '<br />';
    
    echo '<a href="http://' . $domain . '/contact">Link to contact page</a>';
    
  3. This isn't really a PHP or WP issue, because the output is what you want it to be. What it is is a CSS issue, and if your on-hover color isn't right for the span, then you'll need to add/edit some CSS to make it right.

     

    So where you have CSS rules for "a" and "a:hover", you're also going to need one for "a span:hover". This wouldn't normally be the case, but it seems that you might have a rule that this span is inheriting from.

  4. Hi,

     

    I doesn't make sense to hard-code a “YES” or “NO” into your array, because like you said, this is only for displaying. Leave the array as it is and do the “YES/NO” thing when you actually display the content.

     

    By the way, you neither need fetchAll() nor the old while (... fetch()) pattern. You can use a PDOStatement directly in a foreach loop:

    <?php
    
    $rma_details_stmt = $database->query('
    	...
    ');
    
    foreach ($rma_details_stmt as $rma_details)
    {
    	// ...
    }
    

    You may have to adjust the fetch mode. This can be done per statement or globally for the whole database connection.

     

    I think he may need nested foreaches, because he wants the keys (field names).

    foreach ($rma_details_stmt as $rma_details)
    {
         foreach( $rma_details as $k => $v )
         {
              // $k is the key and $v is the value of the field
         }
    }
    
  5. The main issue is that singletons are Bad. They're just another global which leads to tight coupling, which leads to rigid code, which leads to spaghetti-flavored hacks to work around it.

     

    Singletons are wholly unnecessary in PHP where a script's lifespan generally lasts just for one request and objects are passed by reference by default. Generally, if you think you need a singleton, what you really want is dependency injection.

     

    Doesn't OP's code more or less show an example of dependency injection? Yes, having the class and implementation of the class in the same script is not appropriate, but he's learning, and it's not half bad. Also, I think a DB connection is a great place for a singleton, no? Would one really want to make multiple connections to the database in the same request?

     

    In any case, OP needs to read up on dependency injection and service locators, and also take a look at the modern PHP frameworks and how they are handling dependencies.

  6. Every time I look at WordPress code, I have a mini-stroke. So much crap under the hood, with more crap bolted on top in the form of plugins.

     

    I always tell people that WordPress is a great example of how not to code. It's the definition of spaghetti code. Makes CodeIgniter look like a golden nugget, LOL.

  7. If you can provide any actual errors shown, that would be helpful. WP has no "environment" like most modern PHP frameworks offer. So to see the errors, you must set WP_DEBUG to TRUE in wp-config.php.

     

    Just looking at your code, there are a couple things wrong. First, you're not ending your while loop. Secondly, you will probably need to use output buffering to capture the output generated, then insert it into your function. Look at the PHP manual for ob_start, and then go from there.

  8. It's not going to give your site visitors the feeling that they are dealing with a professional company. You might go over to themeforest.net and search for responsive WordPress designs. You can do really well for about $50 and a couple of hours to input your content.

  9. I would love to modify the modSecurity settings, but with MediaTemple's grid service for 20 bucks a month, they will not allow me to do that. They won't even do it for me because they say they can't on their shared server.

     

    I've spoke with inMotion hosting and they told me they have no file size limit on uploads and they also said that if I have issues with modSecurity they would make the changes for me.

     

    I think I may be leaving MediaTemple. For 20 bucks a month, I am way too limited for that price imo

    I've used inMotion before, and also complained to everyone about how I felt they were deceptive and trying to get me to upgrade my account for no reason. As soon as I told them I was leaving, then all the sudden there was no problem. I've been using MDD Hosting, www.mddhosting.com for about 4 years now. I have a semi-dedicated account, which costs about $22 a month. They've been very helpful when I needed server changes, and they have a better "smaller business" type of customer support that works well for me. I have a lot of reasons that I like them, but some highlights are the litespeed server, php 5.5.12, and if something goes bonkers with the server they are very up-front with what is going on. For instance, when they had a hardware issue they emailed everyone letting them know that they were working on it and maybe to expect certain things. If you go with inMotion, remember this story if they tell you your account is using a lot of resources and they are going to need you to pay more for a better account.

  10. I don't see why I would have to set the folder's permissions to 777 when 755 works just fine on the smaller sized files.

     

    ModSecurity: Input filter: Failed writing 1460 bytes to temporary file (rc 1173).

     

    Same error anyways with a 74MB file.

     

    I need to disable this garbage. lol.

     

    Does anyone really know what this error means. Searching google for days and no one really seems to have a straight answer.

     

    I wasn't suggesting that you use the script for production purposes, only to test basic file uploading. So 777 or 755, makes no difference.

     

    Quick search on Google for "modsecurity input filter" gave me this:

     

    https://discussion.dreamhost.com/thread-138012.html

     

    See last response, which indicates something useful about mod security:

     

     

    It's likely the /tmp/ directory that modsec2 is using is set down around the 100MB mark. You'd need to alter the modsec2.conf file to point SecTmpDir and SecUploadDir somewhere else - such as the upload_tmp_dir location you used in your PHP settings above.

  11. I don't think what your trying to do is possible. I understand usage of window.onbeforeunload, but don't believe that it's meant to be used for what you're attempting to do. As far as I know, window.onbeforeunload is only going to give the site visitor a chance to stay of leave, based on a suggested message. For instance, "Are you sure you want to leave, because if you do the world will self destruct.". Maybe I'm wrong.

  12. Open up the index file and tell it where the system file is. That's what it's telling you to do.

     

    You'll see a variable in that file called $system_path. Set it to reflect where the CI system directory is.

     

    You may also need to set the variable directly under it, called $application_folder.


  13. <?php

    if( isset( $_FILES['track'] ) )
    {
    if( ! is_dir( __DIR__ . '/uploads' ) )
    {
    mkdir( __DIR__ . '/uploads', 0777, TRUE );
    }

    if ( ! @copy( $_FILES['track']['tmp_name'], __DIR__ . '/uploads/' . $_FILES['track']['name'] ) )
    {
    if ( ! @move_uploaded_file( $_FILES['track']['tmp_name'], __DIR__ . '/uploads/' . $_FILES['track']['name'] ) )
    {
    echo $_FILES['track']['error'] . '<br />';
    }
    }

    echo 'Upload attempted <br />';
    }
    else
    {
    echo 'No Track';
    }

     

  14. Google oversætte, bare så du ved det. Jeg tror, ​​din hjemmeside er OK. Jeg kan godt lide, at det er lydhør. Der er noget for minimalistiske om det selv. Responsive hjemmeside design behøver ikke at ligne børnehavebørn designet det med farvekridt. Jeg vil sige at arbejde på at forfine designet. Det er de subtile ting at tilføje op til noget stort. Baggrundsbilleder, skygge, skygger, grænser, osv. osv. Gør det et mesterværk!

     

    Google translating, just so you know. I think your website is OK. I like that it is responsive. There's something too minimalistic about it though. Responsive website design doesn't have to look like kindergarten students designed it with crayons. I'd say to work on refining the design. It's the subtle things that add up to something great. Background images, shading, shadows, borders, etc, etc. Make it a masterpiece!

  15. There is really nothing simple about an effective, safe, and trustworthy authentication script / class. Having spent hundreds of hours on my own, I can tell you that you aren't going to get a final product worth using unless you have great dedication. Your best option is to pick up a framework that already has an Auth class.

  16. In your model, school should be school_id, and subject should be subject_id

    <?php
    
      class User extends CI_Model {
     
       public function add_user($data) {
     
       $data = array(
         'username' => $data['username'],
         'name' => $data['name'],
         'email' => $data['email'],
         'password' => $data['password'],
         'user_type' => $data['user_type'],
         'phone_number' => $data['phone_number'],
         'subject_id' => empty($data['subject_id']) ? null : $data['subject_id'],
         'school_id' => empty($data['school_id']) ?  null : $data['school_id']
        );
     
       $this->db->insert('users', $data);
      }
     }
    ?>
    
×
×
  • 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.