Search Results

Search found 16 results on 1 pages for 'krike'.

Page 1/1 | 1 

  • Simplepie - fetch feeds from database

    - by krike
    I want to fetch multiple feeds from the database and in so doing fetch all new content from those feeds it works but there is a problem and I have no idea what's causing it, this is the code: $feed_sql = mysqli_query($link, "SELECT feed from tutorial_feed WHERE approved=1"); $feeds = array(); $i = 0; while($feed_r = mysqli_fetch_object($feed_sql)): $feeds[$i] .= $feed_r->feed; $i++; endwhile; $feed = new SimplePie($feeds); $feed-handle_content_type(); foreach($feed-get_items(0, 100) as $item) : echo $item-get_permalink().""; endforeach; I first get Notice: Undefined offset: 0 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 1 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 2 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 3 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 4 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 5 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 6 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 7 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 8 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 9 in I:\wamp\www\cmstut\includes\cron.php on line 22 Notice: Undefined offset: 10 in I:\wamp\www\cmstut\includes\cron.php on line 22 and then it will start printing the permalinks to the new content based on the imported feeds, I know undefined offset means it does not exist but I don't get it, any help would be appreciated

    Read the article

  • uploading zip files in codeigniter won't work

    - by krike
    I have created a helper that requires some parameters and should upload a file, the function works for images however not for zip files. I searched on google and even added a MY_upload.php - http://codeigniter.com/bug_tracker/bug/6780/ however I still have the problem so I used print_r to display the array of the uploaded files, the image is fine however the zip array is empty: Array ( [file_name] => [file_type] => [file_path] => [full_path] => [raw_name] => [orig_name] => [file_ext] => [file_size] => [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => ) Array ( [file_name] => 2385b959279b5e3cd451fee54273512c.png [file_type] => image/png [file_path] => I:/wamp/www/e-commerce/sources/images/ [full_path] => I:/wamp/www/e-commerce/sources/images/2385b959279b5e3cd451fee54273512c.png [raw_name] => 2385b959279b5e3cd451fee54273512c [orig_name] => 1269770869_Art_Artdesigner.lv_.png [file_ext] => .png [file_size] => 15.43 [is_image] => 1 [image_width] => 113 [image_height] => 128 [image_type] => png [image_size_str] => width="113" height="128" ) this is the function helper function multiple_upload($name = 'userfile', $upload_dir = 'sources/images/', $allowed_types = 'gif|jpg|jpeg|jpe|png', $size) { $CI =& get_instance(); $config['upload_path'] = realpath($upload_dir); $config['allowed_types'] = $allowed_types; $config['max_size'] = $size; $config['overwrite'] = FALSE; $config['encrypt_name'] = TRUE; $ffiles = $CI->upload->data(); echo "<pre>"; print_r($ffiles); echo "</pre>"; $CI->upload->initialize($config); $errors = FALSE; if(!$CI->upload->do_upload($name))://I believe this is causing the problem but I'm new to codeigniter so no idea where to look for errors $errors = TRUE; else: // Build a file array from all uploaded files $files = $CI->upload->data(); endif; // There was errors, we have to delete the uploaded files if($errors): @unlink($files['full_path']); return false; else: return $files; endif; }//end of multiple_upload() and this is the code in my controller if(!$s_thumb = multiple_upload('small_thumb', 'sources/images/', 'gif|jpg|jpeg|jpe|png', 1024)): //http://www.matisse.net/bitcalc/ $data['feedback'] = '<div class="error">Could not upload the small thumbnail!</div>'; $error = TRUE; endif; if(!$main_file = multiple_upload('main_file', 'sources/items/', 'zip', 307200)): $data['feedback'] = '<div class="error">Could not upload the main file!</div>'; $error = TRUE; endif;

    Read the article

  • codeigniter: how to redirect after login to current controller (php_self in regular php)

    - by krike
    Well it's not really a problem but I check if the user exist and log them in and redirect to site/members_area, but I don't want to send the user to a specific page but i want to reload the current controller. So if I login in index/home I would like to be redirected at index/home, how should I proceed? in regular php I would put in the action to redirect to current page <?php echo $_SERVER['PHP_SELF']; ?> This is the code in the framework function validate_credentials() { $this->load->model('membership_model'); $query = $this->membership_model->validate(); if($query) // if the user's credentials validated... { $data = array( 'username' => $this->input->post('username'), 'is_logged_in' => true ); $this->session->set_userdata($data); redirect('site/members_area'); //<-- this line here should be dynamic } else // incorrect username or password { $this->index(); } }

    Read the article

  • wordpress num rows, how?

    - by krike
    I'm creating a plugin for wordpress and I need to check if a post with a specific title exist or not. This to prevent duplicates, how can I query this and see if it returned true or false?

    Read the article

  • paypal custom confirmation page

    - by krike
    I have a deposit page where people can deposit money on their accounts, but I would like to extend this with other payment methods and also I don't want to have certain information in the form visible to people (those who now how to manipulate form data using firebug). So I want to submit the form to a confirmation page where the data is processed and where new data is added like the paypal e-mail and the IPN link that needs to be send to, and only then redirected to paypal. is there php code I can use to submit the form immediatly once the data is processed? or should this be done in the meta tag or something like that?

    Read the article

  • fetching rss feed, mktime problem (wordpress plugin)

    - by krike
    sorry for the weird question but actually I'm not sure how to ask this. the code works fine but the problem is the following. I fetch items from feeds and compare them to a specific date which is stored into the database as an option. I see if the fetched item is more recent or not and if it is I create a new pending post. however there is one item that just keeps being added because there is something wrong with the date and I don't understand what is wrong because all other items (before and after) are blocked once they are being added as post (so when they are not recent anymore compared with the date I store as an option) I then echo'ed that line and this is the result: yes it exist! 27-03-2010-04-03 Free Exclusive Vector Icon Pack: Web User Interface 29-01-2010-03-01 if(1330732800 < 1335830400) 01 05 2012 the first line is to see if the option still exist and what data was stored in it the second is the actual items that's causing all the problem, it's initial date is less recent then the date but still passes as more recent.... this is the code I use, any help would be great: if(!get_option('feed_last_date')): echo "nope doesn't exist, but were creating one"; $time = time()-60*60*24*30*3; add_option("feed_last_date", date('d-m-Y-h-m', $time)); else: echo "yes it exist! ".get_option('feed_last_date'); endif; //Create new instance of simple pie and pass in feed link $feed = new SimplePie($feeds); //Call function handle_content_type() $feed->handle_content_type(); $last_date = explode("-", get_option('feed_last_date')); $day = $last_date[0]; $month = $last_date[1]; $year = $last_date[2]; $hour = $last_date[3]; $minute = $last_date[4]; $last_date = mktime(0,0,0, $day, $month, $year); //4 - Loop through received items foreach($feed->get_items(0, 500) as $item) : $feed_date = explode("-", $item->get_date('d-m-Y-h-m')); $day = $feed_date[0]; $month = $feed_date[1]; $year = $feed_date[2]; $hour = $feed_date[3]; $minute = $feed_date[4]; $feed_date = mktime(0,0,0,$day, $month, $year); if($last_date < $feed_date): echo $item->get_title()." ". $item->get_date('d-m-Y-h-m') ." if(".$last_date." < ".$feed_date.") <b>".date("d m Y", $feed_date)."</b><br />"; //if datum is newer then stored in database, then create new post $description = "<h3>download the resource</h3><p><a href='".$item->get_permalink()."' target='_blank'>".$item->get_permalink()."</a></p><h3>Resource description</h3><p>".$item->get_description()."</p>"; $new_post = array( 'post_title' => $item->get_title(), 'post_content' => $description, 'post_status' => 'pending', 'post_date' => date('Y-m-d H:i:s'), 'post_author' => $user_ID, 'post_type' => 'post', 'post_category' => array(0) ); $post_id = wp_insert_post($new_post); endif; endforeach; update_option("feed_last_date", date('d-m-Y-h-m', time()));

    Read the article

  • custom rss feed suddenly does not work anymore

    - by krike
    I just don't understand what's happening, I haven't change anything to the site for a few months but now suddenly the rss feed doesn't work anymore. I create a php file with the following code: header('Content-type: text/xml'); include("config/config.inc.php"); $result = mysqli_query($link, "SELECT * FROM tutorials ORDER BY tutorial_id DESC LIMIT 50"); ?> <rss version="2.0"> <channel> <title>CMS tutorial site</title> <description>Bringing you the best CMS tutorials from the web</description> <link>http://cmstutorials.org</link> <?php while($row = mysqli_fetch_object($result)) { $user = mysqli_fetch_object(mysqli_query($link, "SELECT * FROM user_extra WHERE userid=".$row->user_id."")); ?> <item> <title><?php echo $row->title; ?></title> <author><?php echo $user->username; ?></author> <description><?php echo $row->description; ?></description> <pubDate><?php echo $row->date; ?></pubDate> <link>http://cmstutorials.org/view_tutorial.php?tutorial_id=<?php echo $row->tutorial_id; ?></link> </item> <?php } ?> </channel> </rss> I checked the query by executing it in phpmyadmin and it works, doesn't give any error. When I delete the header content type and the rss tag it will print out each line from the query but the feed won't display anything this is the link of the feed http://cmstutorials.org/rss (or http://cmstutorials.org/rss.php)

    Read the article

  • preg_replace not working for charachter \

    - by krike
    I'm trying to replace \' with ' but it won't work This is the text I want to replace from Using Twitter\'s @Anywhere Service in 6 Steps and this is the code $tutorial = "Using Twitter\'s @Anywhere Service in 6 Steps "; echo $tutorial."<br /><br />"; $tut_title = preg_replace("/\\'/", "'", $tutorial); echo $tut_title;

    Read the article

  • how to simplify this database update query (php)

    - by krike
    How could I simplify this update instruction? Whenever a client buys an item it will update the sales with 1. $this->db->query('SELECT amount FROM shop_items WHERE itemid='.$itemid.''); $new_amount = $item->amount+1; if(!$this->db->query('UPDATE shop_items SET amount='.$new_amount.' WHERE itemid='.$itemid.'')): return false; endif; Can't I make it more simple so there are less lines, for example: if(!$this->db->query('UPDATE shop_items SET amount=_current_value_+1 WHERE itemid='.$itemid.'')): return false; endif; is this possible? if not thanks anyway

    Read the article

  • CodeIgniter: problem using foreach in view

    - by krike
    I have a model and controller who gets some data from my database and returns the following array Array ( [2010] => Array ( [year] => 2010 [months] => Array ( [0] => stdClass Object ( [sales] => 2 [month] => Apr ) [1] => stdClass Object ( [sales] => 1 [month] => Nov ) ) ) [2011] => Array ( [year] => 2011 [months] => Array ( [0] => stdClass Object ( [sales] => 1 [month] => Nov ) ) ) ) It shows exactly what it should show but the key's have different names so I have no idea on how to loop through the years using foreach in my view. Arrays is something I'm not that good at yet :( this is the controller if you need to know: function analytics() { $this->load->model('admin_model'); $analytics = $this->admin_model->Analytics(); foreach ($analytics as $a): $data[$a->year]['year'] = $a->year; $data[$a->year]['months'] = $this->admin_model->AnalyticsMonth($a->year); endforeach; echo"<pre style='text-align:left;'>"; print_r($data); echo"</pre>"; $data['main_content'] = 'analytics'; $this->load->view('template_admin', $data); }//end of function categories()

    Read the article

  • codeIgniter: pass parameter to a select query from previous query

    - by krike
    I'm creating a little management tool for the browser game travian. So I select all the villages from the database and I want to display some content that's unique to each of the villages. But in order to query for those unique details I need to pass the id of the village. How should I do this? this is my code (controller): function members_area() { global $site_title; $this->load->model('membership_model'); if($this->membership_model->get_villages()) { $data['rows'] = $this->membership_model->get_villages(); $id = 1;//this should be dynamic, but how? if($this->membership_model->get_tasks($id)): $data['tasks'] = $this->membership_model->get_tasks($id); endif; } $data['title'] = $site_title." | Your account"; $data['main_content'] = 'account'; $this->load->view('template', $data); } and this is the 2 functions I'm using in the model: function get_villages() { $q = $this->db->get('villages'); if($q->num_rows() > 0) { foreach ($q->result() as $row) { $data[] = $row; } return $data; } } function get_tasks($id) { $this->db->select('name'); $this->db->from('tasks'); $this->db->where('villageid', $id); $q = $this->db->get(); if($q->num_rows() > 0) { foreach ($q->result() as $task) { $data[] = $task; } return $data; } } and of course the view: <?php foreach($rows as $r) : ?> <div class="village"> <h3><?php echo $r->name; ?></h3> <ul> <?php foreach($tasks as $task): ?> <li><?php echo $task->name; ?></li> <?php endforeach; ?> </ul> <?php echo anchor('site/add_village/'.$r->id.'', '+ add new task'); ?> </div> <?php endforeach; ?> ps: please do not remove the comment in the first block of code!

    Read the article

  • Codeigniter: validation problem

    - by krike
    For some reason a user can login with any password, first I thought I forgot to check for the password but I didn't... and I just cant find the problem here is the model: /*#######################################################*/ function validate() /*#######################################################*/ { $this->db->where('username', $this->input->post('username')); $this->db->where('password', md5($this->input->post('password'))); $q = $this->db->get('user_extra'); if($q->num_rows() == 1): return true; else: return false; endif; }//end of function validate() The controller /*#######################################################*/ function validate_credentials() /*#######################################################*/ { $this->load->model('membership_model'); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Name', 'trim|required'); $this->form_validation->set_rules('password', 'password', 'trim|required'); if(!$this->membership_model->validate()): $this->form_validation->set_message('check_login', 'Login not correct, please try again.'); endif; if($this->form_validation->run() == FALSE): $this->index(); else: $this->membership_model->userinfo($this->input->post('username')); //should redirect to last view redirect($this->session->flashdata('redirect_url')); endif; }// end of validate_credentials()

    Read the article

  • How to: compare array with string and create hastags before tweeting

    - by krike
    Let's say I have the following array (which is the returned value of a database query): Array ( [0] => PHP [1] => Webdesign [2] => Wordpress [3] => Drupal [4]) And the following string: Working With Wordpress Shortcodes How can I compare the array with the string to see if the string contains any word stored in the array? (hopefully that made sense to you :d ) When he finds a match (eg: Wordpress) it should create a hashtag like so: Working With #Wordpress Shortcodes

    Read the article

1