Jump to content

maexus

Members
  • Posts

    191
  • Joined

  • Last visited

    Never

Everything posted by maexus

  1. What is your thoughts on having users pass data to your functions using an array due to the lack of named arguments in PHP? Example: $db = new DB(); $db->connect(array( 'host'=>'localhost', 'username'=>'jimjoe', 'password'=>'hamburgers', 'database'=>'random_db' )); vs $db = new DB(); $db->connect('localhost', 'jimjoe', 'hamburgers', 'random_db')); I'm at work and just thinking about this. Thoughts? Good, bad? Horrible readability? I was also thinking you could pass the array from another object or variable, like a settings class $db = new DB(); $db->connect($settings->get("db_connection_data"))); Something like that.
  2. In your includes, do you generally have longer more complex variable names or use unset for variables that aren't needed outside the include to prevent conflict of variables in the script calling the include? In case that didn't make sense... consider the following somefile.inc.php: <?php $paths = array('dir', 'dir2', 'dir3'); $base = dirname(__FILE__); foreach($paths as $path){ $files = glob("{$base}/{$path}/*.ext"); foreach($files as $file){ require_once($file); } } ?> index.php: <?php require_once("somefile.inc.php"); $paths = "another variable used for a completely different reason than the one used in the included file"; ?> Now, this will work, $paths will just be reassign but personally, this looks just sloppy. I see two options. Instead of using $paths, I could have $jfw_plugin_paths or use unset($paths) at the end of the include file. Which method do you use or do you just let the variable be reassigned when it's needed.
  3. Broken links. 404 is exactly as the error says, file not found.
  4. Thanks for the responses, I just like to adhere to a standard if there is one out there.
  5. The code he posted was specific to pngs. Do you have any png's in the folder? Are you sure you have the path right in glob for your image directory? http://us.php.net/glob For more info
  6. To set the default value of a drop down is HTML, not PHP My suggestion is to visit http://htmldog.com/
  7. If you aren't running the script locally, then yes your host. In fact, I would ask your host if they have a specific setup to send mail from PHP. I know Godaddy does.
  8. I did a quick google search for php error logging and came up with a lot of results. Here is one at random http://www.ilovejackdaniels.com/php-ini-guide/error-handling-and-logging/
  9. Your ISP could be blocking your smtp port?
  10. PHP is executed on the server side only and stops once the page loads. What you are talking about would be client side only, so not php. Javascript could work in this case.
  11. <?php if(isset($_POST['submit'])){ //the code you have before the form } ?> //the form This will make it so that the code does not run unless the form has been submitted.
  12. From what I see, as soon as the page loads, it tries to load post variables that I assume would come from the form at the bottom? Well, that won't work because the query runs before the form is displayed, unless I'm wrong about the form at the bottom supplying the data used in the query. Then, since there is no post variables, I'm assuming $userRecord['status'] is NULL so the switch cause doesn't assign $location to anything and the header call redirects to index because of this. I could be WAY off base as I only skimmed it because I'm at work... Actually, I should be working right now
  13. try $login = new login(); minus the space between login and ()
  14. You have to assign the login object to $login $login = new login();
  15. XAMPP was a great all in one install back when I was running on Windows. I use MAMP now that I'm on OSX
  16. Save it into a php file and link to the file? As soon as the php is called, it's ran.
  17. maexus

    URLS?

    regular expresssions would be good for this.
  18. $$variable should work but I'm double checking
  19. My ultimate point was to use PHP (shocking I would suggest this on a PHP forum) the include/require functions work perfect for this. Also, I don't feel Javascript should be used for something like this. It's relying on the browser's javascript to make this work so that is horrible for usability. What happens when Javascript is turned off or blocked by the browser? If someone can point out why JS is better in this situation, by all means, speak up. To me, it seems like using a wrench to drive in a nail.
  20. http://www.phpfreaks.com/forums/index.php/topic,37442.0.html "HEADER ERRORS - READ HERE BEFORE POSTING THEM" It's stickied right at the top of the forum, in all caps.
  21. Javascript doesn't handle PHP directly or... at all. Javascript passes data/requests to the server, which then passes it to the server side script to do the heavy lifting. The server side script then returns a results, usually XML (The X in AJAX) which is read by Javascript. All of this happens asynchronously.
×
×
  • 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.