Jump to content

snivek

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

snivek's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. What about libraries written in php? I commonly have seen threads or blogs where people refer to a library they use to abstract their database api. Any insight into libraries being used in that way?
  2. I often see people refer to a library? What is it? How is it different than a class and how would you use/implement it? Sorry if this is an answer easily found somewhere. I have looked for days but could not find anyting.
  3. This query is blowing up and I do not know why [code] <?php $sql = "SELECT DateDiff(\"d\", (SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC), GetDate())"; $result = mssql_query($sql); ?> [/code] Here is the query PRINTED, and the error. SELECT DateDiff("d", (SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC), GetDate()) Warning: mssql_query() [function.mssql-query]: message: Invalid parameter 1 specified for datediff. (severity 15) in E:\DHCPLogs\index.php on line 48 The same query works fine from SQL Mgmt Studio. Also - the following query executes without any prob from php. [code] <?php $sql = "SELECT TOP 1 dhcp_log_date FROM dhcp_log ORDER BY dhcp_log_date ASC" ?> [/code]
  4. I have a function that does this...It's not the most elegant piece of code I have written but it works.  I did this for viewing images one at a time from an album. [code] <?php while($row = mysql_fetch_assoc($result)) { If ($row['image_id'] == $image_id) { $previous_image = $tmpPrev; $image_name = $row['image_file_name']; $bool_next = TRUE; }elseif ($bool_next === TRUE) { $next_image = $row['image_id']; $bool_next = FALSE; }else { $tmpPrev = $row['image_id']; } $i=$i+1; ?> }[/code]
  5. I think I see what you are saying.  Since I included the header from within in the class method and not directly from index.php it cannot see $site?  Like my header file is "running" inside of my SiteCore::print_header() method? I made the change and it worked!  Thank you! Is what I'm doing a bad practice?
  6. It is included with SiteCore::print_header() method.  It is called in index.php with $site->print_header();
  7. Here is my code...the relevant parts anyway. SiteCore.php [code] <?php Class SiteCore { private $_DOC_ROOT; private $_HEADER; private $_FOOTER; private $_IMAGES_DIR; private $_INCLUDE_DIR; private $_NAME; private $STYLESHEET; function __construct() { $this->_DOC_ROOT = $_SERVER['DOCUMENT_ROOT']; $this->_IMAGES_DIR = $this->_DOC_ROOT . "/images"; $this->_INCLUDE_DIR = $this->_DOC_ROOT . "/include"; $this->_NAME = "Family and Friends"; $this->_HEADER = $this->_INCLUDE_DIR  . "/header.php"; $this->_FOOTER = $this->_INCLUDE_DIR . "/footer.php"; $this->_STYLESHEET = $this->_INCLUDE_DIR . "/stylesheet.css"; }         public function print_header() { $header = $this->_HEADER; if (file_exists($header)) { require($header); } else { print "Header File Missing!"; } }                public function name() { return $this->_NAME; } } ?> [/code] index.php [code] <?php Require($_SERVER['DOCUMENT_ROOT'] . "/classes/SiteCore.php"); $site = new SiteCore; $site->print_header(); print $site->name(); $site->print_footer(); ?>[/code] header.php [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="<? print $site->print_css();?>" /> <title><?php print $site->name() ?></title>    <!-- **  FAILING!  ** --> </head> <body> <div>  <!-- GLOBAL CONTAINER --> <? print $site->name(); ?>[/code]
  8. I am getting "Call to a member function name() on a non-object in ..." when I call the method in the included file.  Same exact method call from the base index.php file works fine.
  9. I did, and it didnt work.  Which is why I posted :-\  Going to mess with it some more.
  10. If I create an instance of an object in index.php and within index.php include header.php.  Can I have code in my header.php that uses the object as if it were in the file? index.php [code] <?php $site = new SiteCore; print $site->name; include(header.php) ?> [/code] header.php [code] <title><?php print $site->name ?><title> [/code]
  11. I am getting an out of memory error when I call imagecreatefromjpeg().  I am providing it with a 1MB image.  Per my php.ini i have 20MB allocated to me.  Does this function use a lot more memory than I think?  Are there any PHP function I can use to get the amount of memory a variable or array is using?  Like $memused = Mem($string);  Thanks!
  12. I have a hard time trying to define what should be in a Class.  If I create a ImageFile class that contains some properties like name, hegiht, width, etc and some methods like resize and get_thumbnail.  Should I put something like get_exif in it?  Should I make EXIF it's own class?  And if I do, should I put a method in my ImageFile class that makes a call to the EXIF class?  Decisions, Decisions!
  13. I have been trying to learn Classes recently to take a more OO approach at my PHP.  I have noticed that a lot of other coders make static calls to other classes from classes.  i.e., They have a Image Exif class and in one of it's methods it calls a static method from a Utilities class.  This is done fairly often and with many varying methods. This confuses me because IMO it kills the re-usability factor that is supposed to be associated with OOP.  If I have a class that makes calls to a bunch of external methods then I cannot use this class with other application without using those other classes, and those classes might not really be necessary in my new app.  Or I'd have to go through my potential large class and find all my calls and remove or change them. Maybe I'm looking at this on to small a scale or just from the wrong angle.  Am I missing something? I have had many little questions like this come up while trying to learn OOP.  If anyone could provide any links to a good write up on the approach and design of classes, I would really appreciate it!  I don't need to learn the CODE but more the thought/theory/approach.
  14. There isn't that much interaction.  I basically intend for them to upload a zip file and have the script do it thing.  Worst case I could write a UI for the import process but was hoping i would not have to.
  15. I have a script that runs against uploaded image files.  It extras EXIF data, creates thumbs, and moves the image.  When there are a lot of files it takes longer for the script to finish doing everything that it does.  Is there any downside to setting set_time_limit to a very high limit or is there another more elegant way of preventing this timeout?
×
×
  • 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.