Jump to content

KrisNz

Members
  • Posts

    271
  • Joined

  • Last visited

Everything posted by KrisNz

  1. getimagesize only works on files, not raw data. You can use imagecreatefromstring() to recreate the image as a resource, then use functions like imagesx(),imagesy() image_type_to_extension() to get those bits of information. But if you need that information it would make more sense to store it in the database when you first save the image, since that will save you a lot of overhead.
  2. ImageCreateFromBMP is not a function. Theres imagecreatefromwbmp, which is for creating wireless bitmaps, not windows ones. Why can't you test it?
  3. You can use a registry class. http://www.patternsforphp.com/wiki/Registry
  4. Is there a point in your script (or an included script) where you create an instance of your database class and assign it to $Db1? e.g $Db1 = new Database();
  5. You can also do this, which is a bit less sophisticated, but still... <?php set_error_handler("my_error_handler"); function my_error_handler($errno,$errMsg,$errFile,$errLine,$errContext) { echo "$errMsg occured in $errFile on line $errLine<br>"; } trigger_error("this is a warning",E_USER_WARNING); trigger_error("this is a total error",E_USER_ERROR); ?>
  6. Use the built in Exception class. http://php.net/manual/en/language.exceptions.php
  7. I'm not the most mathematically inclined person, but isn't that what abs() is for?
  8. You need to create the object in your constructor, i.e <?php require_once('database.class.php'); class input { private $database; //database object function input () { $this->database = new database(); $this->database->moderator(); } } ?>
  9. You're almost there, functions.php shouldn't contain any html or calls to the functions, just the functions themselves. From the description of your assignment it sounds like the only functions you need are link() and title(). So you can reduce your functions.php file to <?php function link($link, $site) { $link = "<li><a href=\"$link\"> \"$site\" </a></li>\n"; return $link; } function title($title) { $title = "<h1>$title</h1>\n"; return $title; } ?> Also, it's not necessary to assign a value to a variable before returning it. you can return the literal value e.g return "<h1>$title</h1>\n"; Good luck.
  10. Do you mean heredoc syntax? e.g <?php echo <<<END <b>this is some html with quotes' ' '' "" '"'' and stuff.</b> END; ?>
  11. It's due to the semicolon you have here... Remove that and all shall be well.
  12. Here's a tutorial(of sorts) that has some code that should help. I thought that all you had to do was putenv("TZ=whatever") but apparently that doesn't always work. http://drakecms.sourceforge.net/index.php?option=content&id=32&Itemid=10 Either that, or demand an upgrade
  13. Just use file_get_contents() instead.
  14. There's also the glob() function http://nz2.php.net/glob
  15. <pre> <?php $contents = array_chunk(file("data.txt"),2); $final = array(); foreach ($contents as $array) { $final[rtrim($array[0])] = $array[1]; } print_r($final); //or $contents = file("data.txt"); $size = count($contents); $final = array(); for ($i=0;$i<$size;$i++) { $final[rtrim($contents[$i])] = $contents[++$i]; } print_r($final); ?>
  16. your $actiondate variable is a string, you can't just increment it that way. You need to use timestamps thusly... <select name="date"> <option value="">--Select Something--</option> <option value="TBC">T.B.C</option> <?php $now = time(); for ($i=0;$i<28;$i++) : $ts = $now + (86400 * $i); $date = date('j F Y',$ts); ?> <option value="<?php echo $ts ?>"><?php echo $date ?></option> <?php endfor; ?> </select> Also note that your option's need value attributes to be of any use In my example I've made that value the raw timestamp so you can easily convert it into whatever format you need when its sent back to the server for processing.
  17. Theres a plugin for vs.net 2k3 here but its not free. http://vs-php-for-visual-studio-net-2003.jcx-software-corp.qarchive.org/ Alternatively you could try to find a php editor that can be installed on a flash drive. SciTE apparently does and its free! http://www.scintilla.org/SciTE.html
  18. In your original code, the last else block was missing a closing brace. That's probably still the problem (though maybe not the exact same one since it was fixed by Bauer418). This is one reason for using consistent indentation.
  19. Oh yeah, you also only SET once ie. $a = 10; $b = 20; $q = "UPDATE points SET `1`=$a,`2`=$b ";
  20. I think you need `` around your column names. as in `1`=$a.
  21. It needs to be something like set_error_handler(array("Error","Test")); //Error is the Class, Test - the entry point (must be a static method)
  22. method overriding is not the same as method overloading. Since you want to do this with a constructor it would look something like <?php class Foo { public function __construct() { $all_args = func_get_args(); if (count($all_args) == 1) { $this->construct_one($all_args[0]); } else { $this->construct_two($all_args[0],$all_args[1]); } } protected function construct_one($a) { echo ($a); } protected function construct_two($a,$b) { echo ($a); echo ($b); } } <? Obviously, that's not as cool.
  23. The short answer is you can't. The long answer is you can produce a similar behavior using __call and checking the number of arguments before calling the correct method, but the methods still can't have the same name.
×
×
  • 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.