Jump to content

cpd

Members
  • Posts

    883
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by cpd

  1. https://docs.google.com/viewer You realise google have their own format for documents? It's not a simple .doc format. I was at a google event in London recently where they explained all their future plans etc and how they want to hold everyone's documents in a central location.
  2. Words of f***ing wisdom! Thank you for reinforcing my original comments! Love MVC
  3. That's the clearest explanation of JOINS I've ever read. Deserves a sticky!
  4. @MathiasJor - For future reference you can add constraints directly in your CREATE TABLE section after defining each field. Have a read up.
  5. What a numpty, I've completely misinterpreted what your trying to do. Like thorpe said, use the mysql_fetch_assoc or mysql_fetch_array and in your query you can add an "AS" statement like so: SELECT SUM((daysperiod * interest) / daysyear) AS `interest` FROM obresti WHERE startperiod >= '2007-02-02' AND endperiod <= '2012-02-10'; Although I would consider using a stored routine or procedure, depending on your DBMS, because this is a lengthy process which would make sense to have in the SQL Server itself.
  6. @ melting_dog In other words you need something like "C:/path/to/the/desired/folder/". Or on a server its usually something like "/home/username/public_html/desired/folder/" dependent on permissions and where you want to store the file etc.
  7. What your trying to do just wont work with your current database structure. You need to re-think how your doing it with changing interest rates if I'm interpreting your requirements correctly.
  8. Creata, I feel your using my previous post, the apology, as an excuse to start an argument. I don't see any personal insults but can see why you may feel there are some. As I explained, the singleton pattern isn't ideal for php. Thorpe said the same thing in his/her own way. Don't make an assumption on thorpe's tone, that's the worst thing you can do on a forum. On a side note, simplicity is good but as mentioned, it can sometimes be misconstrued as has been done here with the singleton pattern.
  9. Sorry, made a mistake and can't edit anymore $thisWillAvoidLoadsOfEchoStatements = <<<HTMLBLOCK <html> <body> <p>This is a paragraph.</p> <p>This is a paragraph.</p> <p>This is a paragraph.</p> </body> </html> HTMLBLOCK;
  10. Without knowing which line is erroring I'm going to hazard a guess from your previous posts as to where the error is occuring. $data = "SELECT *, MATCH(status, date, species, breed, sex, primary_colour, colour, distinctive_traits, fur_length, age, desexed, microchipped, suburb, pound_area, contact, link) AGAINST ('%$find%') AS score FROM animal_info WHERE MATCH(status, date, species, breed, sex, primary_colour, colour, distinctive_traits, fur_length, age, desexed, microchipped, suburb, pound_area, contact, link) AGAINST('%$find%') $max" or die(mysql_error()); Judging by your query and the error you've received I believe its coming from $max variable which suggests, and I'll once again assume, your trying to make a LIMIT, except your missing the word LIMIT . Furthermore, you must have some form of error when working the limit out because your trying to get rows -1 to 1 which doesn't make sense. Review your code which assigns the $max variable as well as adding the LIMIT syntax. I arrived at this conclusion because you receive an error from mysql_fetch_array which is usually generated when no resource ID is returned from a query. I then scanned through your code to find a single mysql_fetch_array statement using the $results variable as it's parameter. The $results variable was set using the above query hence why I believe this is the query causing the error. I have however, made two assumptions and only scanned through the code; I could be wrong... only way to find out is do what I've recommended and test it And a little tip $thisWillAvoidLoadsOfEchoStatements = <<<HTMLBLOCK <html> <body> <p>This is a paragraph.</p> <p>This is a paragraph.</p> <p>This is a paragraph.</p> </body> </html> HTMLBLOCK;
  11. Out of interest, why would you want to download a google doc using cURL when there is a method in the Google Documents List API?
  12. You've created an internal method variable (can't remember the exact name, help anyone?) which can only be accessed inside that method therefore you do not need to use $this. Instead you just echo the variable name. See below for the correct way to use $this. class Foo { public $external = "My external method var."; public function Bar(){ $internal = "My internal method var."; echo "{$this->external} {$internal}"; } } $class = new Foo; $class->Bar(); // Displays "My extenal method var. My internal method var" echo $class->external // Displays "My extenal method var."
  13. @creata.physics - Apologies if you think that was a second dig at you. Thorpe and myself posted at the same time; never realised he was posting.
  14. Having previously read this page over the years I'd like to draw your attention to the tip slightly further down the page after loading. It explains why the Singleton Pattern concept is not ideal for PHP OOP. Instead, you should create individuality with your objects as detailed by the Law of Demeter, also mentioned in the tip. I personally love the MVC method of programming. It fits perfectly with my page execution concept (Y). Whilst its not specifically object oriented, it's still very nice and can be used in object-oriented languages very easily; therefore allowing you to use it in an object-oriented fashion.
  15. In that case you will want the slightly outdated MSSQL drivers which should be lurking around on the web somewhere. They should connect you to SQL Server 2005.
  16. That is all well and good except there is no object in your example. I do apollogise I wasn't thinking straight, accessing the methods statically as in his example. Adjusted the example accordingly.
  17. This particular piece of code, as already pointed out by scootstah, isn't very good. Your better of learning from another piece. See below for a slightly better way (althought not how I would do it) of doing it. class Sql { public static function connect($connectionInfo){ $connection = mysql_connect($connectionInfo['host'], $connectionInfo['user'], $connectionInfo['pass']; mysql_select_db($connectionInfo['database']; return $connection; } public static function query($sql, $connection){ return mysql_query($sql, $connection); } } $dbInfo = array(DB INFO HERE); $sql = new Sql; $con = $sql->connect($dbInfo); $query = $sql->query(SQL STRING HERE, $con) ; Essentially you access an objects method, it executes the code wrapped in the methods squiggly brackets and may or may not return a value depending on how you program it. Your particular piece of code adopts the object oriented style but is not a piece of object oriented code as it defeats the methodology of object oriented code due to having a single method in the object. The examples using foobar on the php.net website explain classes far more clearly in my opinion so I would refer to them.
  18. Read and learn http://php.net/manual/en/book.ftp.php Far more efficient in my opinion.
  19. The error would suggest the drivers and database type are incompatible. Try using Microsoft's SQLSRV driver. That's what I use and it works a charm. I'm fairly sure it'll work in SQL Server 2005.
  20. Sooo you want help with what exactly? Or do you want it just done for you, that's the impression I get...
  21. Working through your question logically. When you send a CSV file to someone over the web containing an image, the image appears their end. This indicates the image is inside the CSV file. As to whether or not you can upload the image I'm unsure; though I would imagine its possible.
  22. echo str_pad($day, 2, 0, STR_PAD_LEFT);
  23. Echo out your query and ensure everything is being input correctly. If so echo out your result to see if a resource ID is returned and if that's true see how many rows were affected using the mysql_affected_rows or num_rows function; at this stage I would assume our result will be 0.
  24. I did it the following way. It does comes out fine the other end. I'm almost certain there will be an easier way to do it though as this seems a little long winded. Don't have time to do any research though. $nArr = array('A', 'B', 'C', 'D', 'E', 'F'); // Set some vars $length = 1; $offset = 0; $total = 0; // Reverse the array $nArr = array_reverse($nArr); // Create the array $chunkedValues = array(); while($total < count($nArr)){ $chunkedValues[] = array_slice($nArr, $total, $length); $total+= $length; $length++; } // Revers stuff. foreach($chunkedValues as $cK => $cV){ $chunkedValues[$cK] = array_reverse($chunkedValues[$cK]); } $chunkedValues = array_reverse($chunkedValues); var_dump($chunkedValues);
  25. You just hit the nail on the head and hammered it in one blow Muddy. @eroc - Your best route is to use a RDBMS or ORDBS (although there's no great need for it). Don't try and manage everything through cookies which may get destroyed.
×
×
  • 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.