Jump to content

Nethox

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Nethox's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok I figured out what doesn't work and it seems to be an AR issue.. I redid the mysql syntax manually and adding brackets where required.. AR does not seem to do that automatically for some reason. Here is the appropriate SQL for those looking for an answer to this problem. SELECT * FROM (`videos`) WHERE `category` IN ('6', '7', '8', '9', '11', '12', '13') AND (`video_name` LIKE '%test%' OR `username` LIKE '%test%' OR `description` LIKE '%test%' OR `tags` LIKE '%test%')
  2. Need help with Active Record: using where_in and like and or_like at the same time does not work out... Here is my code : <?php // Making sure categories are visible $visible_cats = $this->get_all_visible_cats(); $cat_array = array(); foreach($visible_cats as $cat) { $cat_array[] = $cat['id']; } $match = $this->input->post('search'); $clean_match = $this->security->xss_clean($match); $this->db->like('video_name',$clean_match); $this->db->or_like('username',$clean_match); $this->db->or_like('description',$clean_match); $this->db->or_like('tags',$clean_match); $this->db->where_in('category', $cat_array); $query = $this->db->get('videos'); $videos = $query->result_array(); ?> and this is the get_all_visible_cats() method (which works very well in other instances where I'm using where_in but not like and or_like at the same time) <?php function get_all_visible_cats() { $this->db->select('id, category'); $this->db->where('visible', 1); $query = $this->db->get('categories'); $categories = $query->result_array(); return $categories; } ?> Here is the SQL query that it generates: <?php SELECT * FROM (`videos`) WHERE `category` IN ('6', '7', '8', '9', '11', '12', '13') AND `video_name` LIKE '%test%' OR `username` LIKE '%test%' OR `description` LIKE '%test%' OR `tags` LIKE '%test%' ?> In another method that I have, I use it like this and it works perfectly: <?php // Making sure categories are visible $visible_cats = $this->get_all_visible_cats(); $cat_array = array(); foreach($visible_cats as $cat) { $cat_array[] = $cat['id']; } // db query (id needs to be last for array_pop to work at the end) $this->db->select('thumbnail, video_name, description, category, views, date, username, tags, id'); $this->db->order_by("date", $sort); $this->db->where_in('category', $cat_array); $query = $this->db->get('videos', $num, $offset); $videos = $query->result_array(); ?> Any help is appreciated! Thank you. I forgot to mention what doesn't work. The like() and or_like() functions work well, I get the search results correctly. What doesn't work is the where_in.. It gives me all categories including the ones that are not even in the array (see SQL query up here, even though '10' is not in the array, it returns rows with category 10...) The last bit of code that I posted does not return these non-visible categories.. That is the goal but I have to use like and or_like for my search in this case...
  3. Hi, I'm looking to create a PHP script that converts video files to MP4, WebM and OGG but I don't know where to start. I've been searching on google and on these forums for that type of information but I didn't find anything. Is there any website or PHP library/framework that I should look at in order to find that kind of information? Any help is appreciated!
  4. Thanks for all the help, I've fixed everything following your tips!
  5. Hi, I have a small CMS I coded and developped on my local WAMP server and everything worked fine but when I decided to export everything to my hostgator server I realized that the constants I define in some of my includes are not being defined.. Here is one of the errors I get : Fatal error: require_once() [function.require]: Failed opening required 'LIB_PATHDSdatabase.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/nethox/public_html/photo_gallery/includes/photograph.php on line 2 You can see that LIB_PATH is not defined and even the .DS. is not working.. Here is a sample of the code I made : <?php // Defining core paths // Defining them as absolute paths to make sure that require_once works as expected // DIRECTORY_SEPARATOR is a PHP pre-defined constant // (will do \ for Windows, / for Unix) defined('DS') ? null : define('DS', '/'); defined('SITE_ROOT') ? null : define('SITE_ROOT', 'http://www.lemontree-designs.com'.DS.'photo_gallery'); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.'/includes'); defined('LOG_PATH') ? null : define('LOG_PATH', SITE_ROOT.DS.'logs'); defined('PUBLIC_AREA') ? null : define('PUBLIC_AREA', 'http://www.lemontree-designs.com'.DS.'photo_gallery'.DS.'public'); // Load config file first require_once(LIB_PATH."/config.php"); // Load basic functions next so that everything after can use them require_once(LIB_PATH.DS."functions.php"); // Load core objects require_once(LIB_PATH.DS."session.php"); require_once(LIB_PATH.DS."database.php"); require_once(LIB_PATH.DS."pagination.php"); // Load database-related classes require_once(LIB_PATH.DS."user.php"); require_once(LIB_PATH.DS."photograph.php"); require_once(LIB_PATH.DS."comment.php"); ?> Any help is appreciated! EDIT : For the sake of debugging, I've changed the defined value of DS to '/' instead of DIRECTORY_SEPARATOR to see if it's what caused an issue..
  6. Hey guys, this is just a general question. I read about late static binding and started developing with it on my local server but I noticed that hostgator still runs on 5.2.. Should I use late static binding? (im planning to code an open source CMS)
  7. I'm not sure exactly of what you're trying to do but why don't you put both buttons in the elseif? Wouldn't it show both buttons then?
  8. ROFL, would never have guessed that... Thanks alot you saved me alot of time!
  9. Hey guys. I keep getting this error and I can't find what's wrong with the SQL syntax. I do know that you're not supposed to put single quotes around integers but I don't think it's what's causing the issue. I made a script that echoes the SQL syntax when there's an error for debugging : Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mod) VALUES ('', 'nethox2', '89671260714cbd0eff69a9b6e0ae4c45b2efd67a', 'max', '' at line 1 Last SQL query: INSERT INTO users (id, username, hashed_password, first_name, last_name, admin, mod) VALUES ('', 'nethox2', '89671260714cbd0eff69a9b6e0ae4c45b2efd67a', 'max', 'lab', '1', '0')
  10. Can you post the new code? I'm not sure where exactly you've inserted your user verification script.
  11. Alright, well I already understand the basics of OO PHP and MVC so I think I already have a grasp on how frameworks work. I'll just have to learn the methods/controllers I guess. Thanks!
  12. Thank you, Thorpe. I've read the post. I understand the role a framework can play into programming but how much time does one have to put into learning a framework and using it efficiently? Do you want me to ask this on that other topic?
  13. Hi, I recently finished some online PHP courses from lynda.com (basic php + OOP) and I'm planning to code a whole advanced opensource CMS. I know I have the capabilities to do it but I read that using a framework can be very benificial. I've been looking at codeigniter and it looks great but I'm wondering if it's worth investing my time into learning. How long (hours) does it take to learn how to use a framework such as codeigniter and is it worth investing my time? Should I just stick to using snippets and coding the rest myself? Thanks for any input.
  14. $name1 .= "<br>Name is empty."; $email1 .= "<br>Email is empty."; $message1 .= "<br>User Message is empty."; if(isset($_POST['submit']) && trim($_POST['email']) != $email1 && trim($_POST['name']) != $name1 && trim($_POST['message']) != $message1) { $emailconfirm = $_POST['emailconfirm']; $name = trim($_POST['name']); $visitor_email = trim($_POST['email']); $user_message = trim($_POST['message']); if(empty($name)){ $name1 .= "<br>Name is empty."; } if(empty($visitor_email)){ $email1 .= "<br>Email is empty."; } if(empty($user_message)){ $message1 .= "<br>User Message is empty."; } I think something like this would do it. EDIT: Well actually you'd need to change the name of the variables at the top so they don't appear in the form lol...
×
×
  • 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.