Jump to content

NathanLedet

Members
  • Posts

    102
  • Joined

  • Last visited

    Never

Everything posted by NathanLedet

  1. I think CodeIgniter is the most newbie friendly. Lots of tutorials popping up with good information. Have a look at the CodeIgniter from Scratch series over at Nettuts. That should really get you going http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-1/
  2. I think the "deleting" portion can be handled quite easily by calling a delete function into "decision.php" However, "modify.php" contains forms and that sort of thing that would require a bit more. Would it be bad practice to set those checkbox values into an array in a session? and as soon as that's done - destroy the session?
  3. So I have a form with a load of check boxes. User can select 1 or all of the check boxes, and then at the bottom of the form, there are two submit buttons. <input type="submit" name="remove" id="remove" value="Remove" /> <input type="submit" name="modify" id="modify" value="Modify" /> So, when I choose one of those submit buttons, my form action posts to something like "decision.php" My array of selections is then posted to that php file - and based on what was pushed (modify or delete), that array of data is then pushed on to a new file (modify.php or remove.php) that then processes it. Is this logic correct? or is there a simpler way? If this logic is correct, then I'm not sure how to again post my data on to modify or remove...
  4. I'm building a little animal management system where people can update records of animals they keep. I have given the ability to upload an image - and when a user edits an animal, and chooses NOT to upload a new image, then the image initially chosen will not change. So, in my code to process the submission, I have the following SQL query that is running into an unexpected T_IF. $sql = "UPDATE rcms SET `animal_id` = '{$animalid}', `type` = '{$animaltype}', `weight` = '{$animalweight}', `birthday` = '{$animalbday}', `description` = '{$animaldescription}'" . if ($filename != NULL){ ", `image` = '{$filename}'" }. "WHERE id='{$id}' LIMIT 1"; I have other code that process the image if it's there, or sets the $filename variable to NULL if the file field is left blank. So, essentially, All I'm trying to do is say if $filename is not NULL (has a name of a new file) - add that snippet of code so that it will update in the database.
  5. Creating a plugin for FrogCMS... I have MyController.php and ImageResize.php in the same plugin directory so when someone submits a form with an image to upload, it submits to the process_entry function: class MyController extends PluginController { function process_entry() { $image = $_FILES['contentimg']; $tmp_name = $image['tmp_name']; $name = $_FILES['contentimg']['name']; //include the ImageResize class to process the image include_once('ImageResize.php'); //$uploaddir is defined higher up in the plugin - it works image_scale($tmp_name, "$uploaddir/$name", 200, 200); } } That generates a fatal error: Call to undefined function image_scale() K, so ImageResize.php looks like this: class ImageResize { function image_scale($source, $dest, $width, $height) { $info = $this->image_get_info($source); //no scaling up if ($width > $info['width'] && $height > $info['height']) { return false; } $aspect= $info['height'] / $info['width']; if (!$height or ($width && $aspect < $height /$width)) { $width = (int)min($width, $info['width']); $height = (int)round($width * $aspect); } else { $height = (int)min($height, $info['height']); $width = (int)round($height / $aspect); } return $this->image_gd_resize($source, $destination, $width, $height); } //end function image_scale() function image_get_info($file) { if( !is_file($file)) { return false; } $details = false; $data = @getimagesize($file); if (is_array($data)) { $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png'); $extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : ''; $details = array( 'width' => $data[0], 'height' => $data[1], 'extension' => $extension, 'mime_type' => $data['mime'] ); } return $details; } function image_gd_resize($source, $dest, $width, $height, $source_x = 0, $source_y = 0, $source_width = null, $source_height = null) { if (!file_exists($source)) { return false; } $info = $this->image_get_info($source); if(!$info) { return false; } $im = $this->image_gd_open($soure, $info['extension']); if (!$im) { return false; } $source_width = is_null($source_width) ? $info['width'] : $source_width; $source_height = is_null($source_height) ? $info['height'] : $source_height; $res = imageCreateTrueColor($width, $height); imageCopyResampled($res, $im, 0, 0, $source_x, $source_y, $width, $height, $source_width, $source_height); $result = ImageResize::image_gd_close($res, $dest, $info['extension']); imageDestroy($res); imageDestroy($im); return $result; } function image_gd_open($file, $extension) { $extension = str_replace('jpg', 'jpeg', $extension); $open_func = 'imagecreatefrom'.$extension; if(!function_exists($open_func)) { return false; } return $open_func($file); } function image_gd_close($res, $dest, $extension) { $extension = str_replace('jpg', 'jpeg', $extension); $close_func = 'image'.$extension; if(!function_exists($close_func)) { return false; } return $close_func($res, $dest); } } So, apparently I'm mis-using the classes because my image_scale function is not being found.... ? Thanks for the help
  6. Thanks. I guess I should have mentioned that the class already extends a class: class MyController extends PluginController { } [code=php:0] I'm building plugin for a CMS.
  7. Still learning a bit about OOP... If I have a class that runs and process all of my form submissions, can I execute a function that generates a thumbnail when someone uploads an image? For example... class MyController { function upload_image() { //queries and stuff to go here to get all of the form data //code to process image: require_once('Thumbnail.class.php'); $tn = new Thumbnail(200,200); $tn->loadFile("filename.jpg"); $tn->buildThumb(); } } and of course, my Thumbnail.class.php would contain all of the functions to generate the thumbnail. Is this method doable? or should I consider putting all of my thumbnail functions in my already existing "MyController" class? any other suggestions? Thanks
  8. And someone also said it's like apples to oranges, which is completely true. Yes, Javascript does cool stuff. There is stuff like JQuery and other Javascript libraries that do some great things for your users experience - but you need a way to process and store that data - yes? That is what PHP is for. It's limited only to what you know. I've been dinking with PHP for years and still feel like an amateur.
  9. no. Javascript does Javascript. If you don't like PHP - there's always ASP. good luck
  10. OK I typed it all out and this is my actual script. It is putting in a "0", when it should be 11 or 12 or whenever the previous query's id turned out to be: $PDO->exec("INSERT INTO `".TABLE_PREFIX."page`( `title`, `slug`, `breadcrumb`, `parent_id`, `status_id`, `created_by_id`, `updated_by_id`) VALUES( 'Tessst', 'Tessst', 'Tessst', '1', '100', '1', '1')"); $PDO->exec("INSERT INTO `".TABLE_PREFIX."page_part` ( `name`, `content`, `content_html`, `page_id`) VALUES('body', 'content goes here', '<p>content goes here</p>', '".mysql_insert_id()."')");
  11. Awesome - I'm going to give this a try $sql = "INSERT INTO page ('title', 'keywords', 'parent_id', 'status', 'created_by_id') VALUES('page title', 'key, word, page, title', '1', '1', '1') )"; $sql2 = "INSERT INTO page_body ('content', 'page_id') VALUES('Page Title', mysql_insert_id()) ";
  12. I have a little script I'm working with that has pages and page data (two MySQL tables) When you create a page, the database auto-increments the page ID number. I need to create a script that automatically generates a page and puts that page in the database - but the page data is in a separate table. So, my next step would be to create the page data and then the "page_id" needs to be the page id that was automatically created by MySQL So in my PHP/MySql - what's the best way to retrieve the ID of the entry that was just generated? Thanks!
  13. One way you can check to see what's being put in is to echo your sql statement. $sql = "INSERT INTO candidateEmails(id,candidate_id) VALUES ('','$cid')"; echo $sql;
  14. Amazon has a few books that are helpful. Follow those video tutorials - that really is a good start. Once I got my head around the MVC architecture, I loved it. But, it took me a bit to realize its power - and I realized its power by getting my hands dirty and writing a program in CodeIgniter. CodeIgniter is by far the easiest to set up and just start programming in. Zend, CakePHP, and some others have a little more involved that confused me as a framework newbie. That doesn't mean I hate them and won't use them...I just think the learning curve is steeper and take a little more experience to really understand what you're doing. I've read that each framework has its place. I can certainly agree with that - and I'm trying right now to learn as much as I can about each framework so I can expand my knowledge and be ready to work with each one. I think CI is a great place to start - but I wouldn't limit it to JUST CI. The other frameworks are great and have their place. They don't have any place with stupid people, however.
  15. I found them on The Web Freaks web site and just wanted to check them out. Had no idea you guys were based in Kissimmee... Hello from Orlando I'm right around the Florida Mall area right now.
  16. Just clarifying - You did mean 'require', not 'request'... ? Is there any significant difference or reason why I should use require ("file.ext"); versus require "file.ext";
  17. I agree with this Making a cup of tea is a step by step procedure. In terms of using PHP, it would simply be step1.php, step2.php, step3.php, step4.php, etc. PHP runs on the server and returns HTML based on certain things. If else statements, loops, arrays, etc. etc. etc. make PHP an interactive language. Based on x, do y. Based on y, do z, etc. It's not a step by step thing.
  18. I do believe this is a setting in your php.ini http://us3.php.net/ini.core
  19. Why is LinuxForum.com pointing to phpfreaks.com?
  20. ha. That was it - and I tested that theory out right before seeing your reply. Thanks for the help
  21. I need to re-visit this issue. Any ideas anyone? Thank you.
  22. harhar...it was the very next google result.. basename($_SERVER['PHP_SELF']);
  23. So, I want to get the current page that I'm on so that I can run an if/else statement. I want it to be like "if page is on index.php, then do this" k? so. I'm working in a development folder and when I use REQUEST_URI, PHP_SELF, or SCRIPT_NAME, it returns the development folder that I'm working on, as well as the file name. In other words, it's returning /development/index.php when all I really need is index.php I would appreciate the help!
×
×
  • 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.