Search Results

Search found 981 results on 40 pages for 'codeigniter 2'.

Page 26/40 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • Unsupported operand types when value is integer

    - by Adam Tester
    I'm getting this error when trying to add 2 to an integer. I am using the Codeigniter framework. Fatal error: Unsupported operand types in D:\wamp\www\application\libraries\Gen_images.php on line 180 Here is where its called: // Now process the image var_dump($this->upload->data('image_width')); $this->gen_login->resize($file_name, $this->upload->data('image_width'), $this->upload->data('image_height')); I get the error on line 180 which is: $config['width'] = $width + 2; So I thought $width must be an array or string so I wouldn't be able to add to it, but the var dump shows this: array 'file_name' => string 'genyx_1341414096.jpg' (length=20) 'file_type' => string 'image/jpeg' (length=10) 'file_path' => string 'D:/wamp/www/beer/uploads/' (length=25) 'full_path' => string 'D:/wamp/www/beer/uploads/genyx_1341414096.jpg' (length=45) 'raw_name' => string 'genyx_1341414096' (length=16) 'orig_name' => string 'genyx_1341414096.jpg' (length=20) 'client_name' => string '294207_177080222375077_100002193022560_361510_991268937_s.jpg' (length=61) 'file_ext' => string '.jpg' (length=4) 'file_size' => float 55.85 'is_image' => boolean true 'image_width' => int 720 'image_height' => int 479 'image_type' => string 'jpeg' (length=4) 'image_size_str' => string 'width="720" height="479"' (length=24) Can anyone help me?

    Read the article

  • Calling Model Functions from a Library

    - by Abs
    Hello all, I have turned a normal PHP class into a library so I can use it in Codeigniter as a library. I can load it and call the functions I need in that class. Here is that class to help with the question. However, there are quite a few points where I have to call functions in my class. These functions reside in the model that instantiated my class. How can I do this as currently normal calls don't work. Here is my code: class Controlpanel_model extends Model { var $category = ''; var $dataa = 'a'; function Controlpanel_model(){ parent::Model(); } function import_browser_bookmarks(){ $this->load->library('BookmarkParser'); /* *In this function call to the class I pass * what model functions exist that it should call * You can view how this done by clicking the link above and looking at line 383 */ $this->bookmarkparser->parseNetscape("./bookmarks.html", 0, 'myURL', 'myFolder'); return $this->dataa; } function myURL($data, $depth, $no) { $category = $this->category; $this->dataa .= 'Tag = '.$category.'<br />'.'URL = '.$data["url"].'<br />'.'Title = '.$data["descr"].'<br />'.'<br /><br />'; } function myFolder($data, $depth, $no) { $this->category = $data["name"]; } } Thanks all for any help.

    Read the article

  • Content-disposition:inline header won't show images inline?

    - by hamstar
    I'm trying to show an image inline on a page. It is being served by a codeigniter controller. class Asset extends MY_Controller { function index( $folder, $file ) { $asset = "assets/$folder/$file"; if ( !file_exists( $asset ) ) { show_404(); return; } switch ( $folder ) { case 'css': header('Content-type: text/css'); break; case 'js': header('Content-type: text/javascript'); break; case 'images': $ext = substr( $file, strrpos($file, '.') ); switch ( $ext ) { case 'jpg': $ext = 'jpeg'; break; case 'svg': $ext = 'svg+xml'; break; } header('Content-Disposition: inline'); header('Content-type: image/'.$ext); } readfile( $asset ); } } When I load a image in Chrome of FF its pops up the download window. I know when the browser can't display the content inline it will force a download anyway, but these are PNG and GIF images which display in the browser fine otherwise. In IE it doesn't force a download but it displays the image in ASCII. If I comment out the entire image case it FF and Chrome both display the ASCII but not the image. I thought setting the content type would allow FF and Chrome to show the actual image, and also allow the location to be used as an src. The javascript and css shows fine of course. Anyone got any ideas how I can make the images show properly? Thanks :)

    Read the article

  • PHP APC and Pecl upload progress returning false/null.

    - by Keyo
    This is a long shot. I believe this might be suhosin patch issue. Here is my php from codeigniter: public function uploadprogress($id) { if ($id) { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); echo json_encode(apc_fetch('upload_'.$id)); exit(); } } public function uploader() { $this->load->view('myid/' . $this->router->class . '_uploader'); //phpinfo(); } script: <script type="text/javascript"> $(document).ready(function(){ var progress_key = $('#progress_key').val(); // this sets up the progress bar $('#uploadform').submit(function() { setTimeout(beginUpload,1500); return; }); function beginUpload() { $("#progressbar").progressbar({ value:0}).fadeIn(); var i = setInterval(function() { $.getJSON("/myid/videos/uploadprogress/" + progress_key, function(data) { alert('data'); if (data == null) { clearInterval(i); location.reload(true); return; } var response; eval ("response = " + data); if (!response) return; var percentage = Math.floor(100 * parseInt(response['bytes_uploaded']) / parseInt(response['bytes_total'])); $("#progressbar").progressbar({value:percentage}); }, 1500); }); } }); </script> Has anyone had strange troubles with this before? The upload key is the same on the view and the uploadprogress method. I've Tried apc and pecl upload-progress both return false or null. I wondering if it's just suhosin patch messing up everything?

    Read the article

  • How should I manage my many-to-many relationships?

    - by wes
    Hello all, I have a database containing a couple tables: files and users. This relationship is many-to-many, so I also have a table called users_files_ref which holds foreign keys to both of the above tables. Here's the schema of each table: files - file_id, file_name users - user_id, user_name users_files_ref - user_file_ref_id, user_id, file_id I'm using Codeigniter to build a file host application, and I'm right in the middle of adding the functionality that enables users to upload files. This is where I'm running into my problem. Once I add a file to the files table, I will need that new file's id to update the users_files_ref table. Right now I'm adding the record to the files table, and then I imagined I'd run a query to grab the last file added, so that I can get the ID, and then use that ID to insert the new users_files_ref record. I know this will work on a small scale, but I imagine there is a better way of managing these records, especially in a heavy-traffic scenario. I am new to relational database stuff but have been around PHP for a while, so please bear with me here :-) I have primary and foreign keys set up correctly for the files, users, and users_files_ref tables, I'm just wondering how to manage the adding of file records for this scenario? Thanks for any help provided, it's much appreciated. -Wes

    Read the article

  • PHP fails silently when php-code is within html tag

    - by Michal M
    PROBLEM UPDATED, READ BELOW For some reason my CI fails silently when loading view. Loading view is simply called from controller $this->load->view('templates/default.php'); Now. There are some functions in the loaded view that are not defined unless a proper helper is loaded as well. Normally, php would throw an error, but instead it fails silently here. I have no idea why. The template gets outputted till the line containing the undefined function. It took me long time to realise where my script is failing. Here's my setup: Windows 7 Ultimate Apache 2.2.15 PHP 5.3.2 with following error reporting settings: display_errors = On display_startup_errors = On error_reporting = E_ALL | E_STRICT CodeIgniter 1.7.2 Any ideas why would that be? UPDATE After further debugging, it turned out that PHP fails to report any errors when php code is inline with HTML and within the HTML tag. Now this is bizarre. This returns Fatal Error: <p><?php echo $bogus(); ?></p> This doesn't and fails silently: <p class="<?php echo $bogus(); ?>">paragraph</p> Why? :O UPDATE 2 Further investigation showed that if an error_log in PHP is specified, the errors are in fact reported in that file, but still not in the browser... Again, why? UPDATE 3 Actually my code should be slightly different. Checked another PHP installation on completely different machine and it confirmed the PHP bug. Reported here: http://bugs.php.net/bug.php?id=52040

    Read the article

  • Load Balancing of PHP/MYSQL script without big code changes

    - by DR.GEWA
    Sorry for my Dummy Question, but... I am making a script on php/mysql (codeigniter) and I am extremally interested in knowing if there is a way without big architectural changes of the script make a load balancing. I mean, that for example now I will rent a medium dedicated server with 2GB ram, 200GB memory and good processor, and this will be enough lets say half year for the users which will come. But when they will become more and more, and as its a social net and at nights the server is waiting to have 500-1500 or 5000-8000 users online, I wander if there is a way for lets say just add second server with some config which will bear next pressure. After again one and so on... ???? <? if($answer=YES) { how(??); } esle{ whatToDo(??); } ?> If there is no way, than maybe you could point to a easiest way of load balancing solution.... I will be extremally thanksfull if you can tell me for such purposes , should I move lets say to PostgreSQl or FireBird? Which of them will be more easy in the future to handle ? I am getting on the mysite.com/users/show/$userId page something like 60queries for all data... maybe too much, but anyway....after some optimization it can be 20-30....

    Read the article

  • Error handling in PHP

    - by Industrial
    Hi guys, We're building a PHP app based on Good old MVC (codeigniter framework) and have run into trouble with a massive chained action that consists of multiple model calls, that together is a part of a big transaction to the database. We want to be able to do a list of actions and get a status report of each one back from the function, whatever the outcome is. Our first initial idea was to utilize the exceptions of PHP5, but since we want to also need status messages that doesnt break the execution of the script, this was our solution that we came up with. It goes a little something like this: $sku = $this->addSku( $name ); if ($sku === false) { $status[] = 'Something gone terrible wrong'; $this->db->trans_rollback(); return $status; } $image= $this->addImage( $filename); if ($image=== false) { $error[] = 'Image could not be uploaded, check filesize'; $this->db->trans_rollback(); return $status; } Our controller looks like this: $var = $this->products->addProductGroup($array); if (is_array($var)) { foreach ($var as $error) { echo $error . '<br />'; } } It appears to be a very fragile solution to do what we need, but it's neither scalable, neither effective when compared to pure PHP exceptions for instance. Is this really the way that this kind of stuff generally is handled in MVC based apps? Thanks!

    Read the article

  • Configuring Displays for Different Mobile Devices

    - by Mike
    Does anyone know a way to have specific CSS style sheets based on the type of Mobile Device? I have been researching it a few days now and haven't found anything except this snippet of code for iPhones. <link media="only screen and (max-device-width: 480px)" href="iPhone.css" type="text/css" rel="stylesheet" /> This works great for iPhones, but on all other mobile devices (android, blackberry, Nokia), it's still displaying the same as my site. I tried: <link media="handheld" href="iPhone.css" type="text/css" rel="stylesheet" /> but that didn't seem to have any effect on the other mobile devices. So I'm not sure how to reach the blackberry's/androids/nokia's without effect the code of my actual site. I'm building my site using the PHP framework CodeIgniter and I looked into this code which is suppose to be able to tell if it is being looked at through a mobile device or browser. if ($this->agent->is_browser()) { $agent = $this->agent->browser().' '.$this->agent->version(); } elseif ($this->agent->is_mobile()) { $agent = $this->agent->mobile(); } else { $agent = 'Unidentified User Agent'; } The only problem is that the newer phones we are building on render the site as a browser and not as a mobile (I think, I've only tested the iphone because it's all I have at the moment). So does anyone have any work arounds for the other phone platforms?

    Read the article

  • Call to a member function num_rows() on a non-object

    - by Patrick
    I need to get the number of rows of a query (so I can paginate results). As I'm learning codeigniter (and OO php) I wanted to try and chain a -num_rows() to the query, but it doesn't work: //this works: $data['count'] = count($this->events->findEvents($data['date'], $data['keyword'])); //the following doesn't work and generates // Fatal Error: Call to a member function num_rows() on a non-object $data['count2'] = $this->events->findEvents($data['date'], $data['keyword'])->num_rows(); the model returns an array of objects, and I think this is the reason why I can't use a method on it. function findEvents($date, $keyword, $limit = NULL, $offset = NULL) { $data = array(); $this->db->select('events.*, venues.*, events.venue AS venue_id'); $this->db->join('venues', 'events.venue = venues.id'); if ($date) { $this->db->where('date', $date); } if ($keyword) { $this->db->like('events.description', $keyword); $this->db->or_like('venues.description', $keyword); $this->db->or_like('band', $keyword); $this->db->or_like('venues.venue', $keyword); $this->db->or_like('genre', $keyword); } $this->db->order_by('date', 'DESC'); $this->db->order_by('events.priority', 'DESC'); $this->db->limit($limit, $offset); //for pagination purposes $Q = $this->db->get('events'); if ($Q->num_rows() > 0) { foreach ($Q->result() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } Is there anything that i can do to be able to use it? EG, instead of $data[] = $row; I should use another (OO) syntax?

    Read the article

  • How should backbone.js handle a GET request that returns no results?

    - by Nyxynyx
    I have a number of text input elements that when its values are changed, will trigger a fetch on listingListView's collection listingCollection, which then updates listingListView with the new data via the function listingListView.refreshList as shown below. I am using PHP/Codeigniter to expose a RESTful API. Problem: Everything works fine if there are results retrieved from the fetch(). However, when the filters results in no result being returned, how should the server side and the client side handle it? Currently Chrome's javascript console displays a 404 error and in the Network tab, the XHR request is highlighted in red. All I want to do in the event of zero results returned, is to blank the listingListView and show a message like (No results returned) and not throw any errors in the javascript console. Thanks! PHP Code function listings_get() { // Get filters $price_min = $this->get('price_min'); $this->load->model('app_model'); $results = $this->app_model->get_listings($price_min); if($results) $this->response($results); else $this->response(NULL); } JS Code window.ListingListView = Backbone.View.extend({ tagName: 'table', initialize: function() { this.model.bind('reset', this.refreshList, this); this.model.bind('add', function(listing) { $(this.el).append(new ListingListItemView({ model: listing }).render().el); }, this); }, render: function() { _.each(this.model.models, function(listing) { $(this.el).append(new ListingListItemView({ model: listing }).render().el); }, this); return this; }, close: function() { $(this.el).unbind(); $(this.el).empty(); }, refreshList: function() { $(this.el).empty(); this.render(); } });

    Read the article

  • PHP Commercial Project Function define

    - by Shiro
    Currently I am working with a commercial project with PHP. I think this question not really apply to PHP for all programming language, just want to discuss how your guys solve it. I work in MVC framework (CodeIgniter). all the database transaction code in model class. Previously, I seperate different search criteria with different function name. Just an example function get_student_detail_by_ID($id){} function get_student_detail_by_name($name){} as you can see the function actually can merge to one, just add a parameter for it. But something you are rushing with project, you won't look back previously got what similar function just make some changes can meet the goal. In this case, we found that there is a lot function there and hard to maintenance. Recently, we try to group the entity to one ultimate search something like this function get_ResList($is_row_count=FALSE, $record_start=0, $arr_search_criteria='', $paging_limit=20, $orderby='name', $sortdir='ASC') we try to make this function to fit all the searching criteria. However, our system getting bigger and bigger, the search criteria not more 1-2 tables. It require join with other table with different purpose. What we had done is using IF ELSE, if(bla bla bla) { $sql_join = JOIN_SOME_TABLE; $sql_where = CONDITION; } at the end, we found that very hard to maintance the function. it is very hard to debug as well. I would like to ask your opinion, what is the commercial solution they solve this kind of issue, how to define a function and how to revise it. I think this is link project management skill. Hope you willing to share with us. Thanks.

    Read the article

  • How to scale a PHP application (servers, mysql, memcache)

    - by Stéphane Goetz
    Hi, I'm currently creating a website for a social project in switzerland. And before there is an overflow of user, I want to prepare the application to scale. I answered by myself many questions but some are left. I explain what I want to do. First at the beginnning, the Application will have only one server (short time) with DNS, PHP, Mysql, Data, and memcache. Second Then I will split them in two DNS, Mysql, memcache Data, PHP Third Here is the problem, I don't know how to do it exactly here to keep the application running well. I could do : Front : Load Balancer, memcache, DNS Web 1 : PHP, DATA Web 2 : PHP, DATA Mysql This would be the scheme, all PHP sessions are kept in the DB. BUT, how do I sync the data? do I run a Rsync to keep them up to date. do I put them on a separate disk (network disk) to be sure ? but in this case, how can I do in case of user uploads ? and if the website gets more success and we have to go on greater structures, would'nt it create some latency on updates ? or would it be a good thing to go directly to amazon's web services ? some infos I use codeigniter as Framework. I use linux as webserver (distribution not chosen now, but should be Debian) Thanks in advance for your answers.

    Read the article

  • Can I use foreign key restrictions to return meaningful UI errors with PHP

    - by Shane
    I want to start by saying that I am a big fan of using foreign keys and have a tendency to use them even on small projects to keep my database from being filled with orphaned data. On larger projects I end up with gobs of keys which end up covering upwards of 8 - 10 layers of data. I want to know if anyone could suggest a graceful way of handling 'expected errors' from the MySQL database in a way that I can construct meaningful messages for the end user. I will explain 'expected errors' with an example. Lets say I have a set of tables used for basic discussions: discussion questions responses users Hierarchically they would probably look something like this: -users --discussion ---questions ----responses When I attempt to delete a user the FKs will check discussions and if any discussion exist the deletion is restricted, deleting discussion checks questions, deleting questions checks responses. An 'expected error' in this case would be attempting to delete a user--unless they are newly created I can anticipate that one or more foreign keys will fail causing an error. What I WANT to do is to catch that error on deletion and be able to tell the end user something like 'We're sorry, but all discussions must be removed before you can delete this user...'. Now I know I can keep and maintain matching arrays in PHP and map specific errors to messages but that is messy and prone to becoming stagnant, or I could manually run a set of selects prior to attempting the deletion, but then I am doing just as much work as without using FKs. Any help here would be greatly appreciated, or if I am just looking at this completely wrong then please let me know. On a side note I generally use CodeIgniter for my application development, so if that would open up an avenue through that framework please consider that in your answers. Thanks in Advance

    Read the article

  • Accents in uploaded file being replaced with '?'

    - by Katfish
    I am building a data import tool for the admin section of a website I am working on. The data is in both French and English, and contains many accented characters. Whenever I attempt to upload a file, parse the data, and store it in my MySQL database, the accents are replaced with '?'. I have text files containing data (charset is iso-8859-1) which I upload to my server using CodeIgniter's file upload library. I then read the file in PHP. My code is similar to this: $this->upload->do_upload() $data = array('upload_data' => $this->upload->data()); $fileHandle = fopen($data['upload_data']['full_path'], "r"); while (($line = fgets($fileHandle)) !== false) { echo $line; } This produces lines with accents replaced with '?'. Everything else is correct. If I download my uploaded file from my server over FTP, the charset is still iso-8850-1, but a diff reveals that the file has changed. However, if I open the file in TextEdit, it displays properly. I attempted to use PHP's stream_encoding method to explicitly set my file stream to iso-8859-1, but my build of PHP does not have the method. After running out of ideas, I tried wrapping my strings in both utf8_encode and utf8_decode. Neither worked. If anyone has any suggestions about things I could try, I would be extremely grateful.

    Read the article

  • Database contents setting themselves to 0

    - by Luis Armando
    I have a Database that contains 4 tables, however I'm using 1 of them which is separated from the others. In this table I have 4 fields which are varchar and the rest are ints (11 other fields), when the users fill up the DB everything gets saved correctly, however it has happened 3 times so far that the database values for the int's reset to 0 without any apparent reason. At first, I thought, it was because those fields (where the numbers should go) were varchars not ints. However since I changed it, it happened again. I've already double checked my code and I have nothing that even updates or inserts a 0 value. Also I'm using codeigniter and active records which protect against SQL injections AND have XSS filtering enabled, could anyone point out something I might be missing or a reason for this to be happening? Also, I'm pretty sure about the answer of this but, is there ANY way to recover some data?? Other than having to ask everyone to fill in everything again.. =/ ** EDIT ** The Storage Engine is MyISAM and Collation is latin1_swedish_ci, Pack Keys are default, for all intents and purposes it's a normal DB

    Read the article

  • Apache crashes, probably because of this piece of php code. Can you have a look?

    - by Munim
    I am working on the development of a web based application on codeigniter. I wrote this function to get the timezone data for any city or address. function gettimezone($address) { $_url = 'http://api.local.yahoo.com/MapsService/V1/geocode'; $_url .= sprintf('?appid=%s&location=%s',"phpclasses",rawurlencode($address)); $_result = false; if($_result = file_get_contents($_url)) { preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U', $_result, $_match); $lng = $_match[2]; $lat = $_match[1]; $url = "http://ws.geonames.org/timezone?lat={$lat}&lng={$lng}"; $timedata = file_get_contents($url); $sxml = simplexml_load_string($timedata); return $sxml->timezone; } else return false; } I am working on Windows 7 and xampp 1.7 (php 5.2.8). Is there any possible scenario where this piece of code would crash Apache? The application runs fine almost everytime, but I think running this piece of code when there is no internet connectivity or very poor internet connectivity (thereby no access to either of the webservices I have used) brings down the server. Something like this happened a few times and I think it was due to loss of internet connectivity but I am not sure what exactly is going on. [ By the way, feel free to use this piece of code. Makes 2 web service calls so don't use to too often in your application. Consider storing the results in a database.]

    Read the article

  • optimistic and pessimistic locks

    - by billmce
    Working on my first php/Codeigniter project and I’ve scoured the ‘net for information on locking access to editing data and haven’t found very much information. I expect it to be a fairly regular occurrence for 2 users to attempt to edit the same form simultaneously. My experience (in the stateful world of BBx, filePro, and other RAD apps) is that the data being edited is locked using a pessimistic lock—one user has access to the edit form at the time. The second user basically has to wait for the first to finish. I understand this can be done using Ajax sending XMLHttpRequests to maintain a ‘lock’ database. The php world, lacking state, seems to prefer optimistic locking. If I understand it correctly it works like this: both users get to access the data and they each record a ‘before changes’ version of the data. Before saving their changes, the data is once again retrieved and compared the ‘before changes’ version. If the two versions are identical then the users changes are written. If they are different; the user is shown what has changed since he/she started editing and some mechanism is added to resolve the differences—or the user is shown a ‘Sorry, try again’ message. I’m interested in any experience people here have had with implementing both pessimistic and optimistic locking. If there are any libraries, tools, or ‘how-to’s available I’m appreciate a link. Thanks

    Read the article

  • CodeIgnither OAuth 2.0 database setup for users and access_tokens

    - by xref
    Per this question I am using CodeIgniter and OAuth 2 in an attempt to provide SSO for internal users of my webapp, ideally verifying them against their Google Apps account. No registrations or anything, just existing users. Using the CI oauth2 spark I'm getting back from Google an OAuth token similar to below: OAuth2_Token_Access Object ( [access_token:protected] => dp83.AHSDj899sDHHD908DHFBDjidkd8989dDHhjjd [expires:protected] => 1349816820 [refresh_token:protected] => [uid:protected] => ) And using that token I can retrieve some user info from Google: [uid] => 3849450385394595 [nickname] => this_guy [name] => This Guy [first_name] => This [last_name] => Guy [email] => [email protected] [location] => [image] => [description] => [urls] => Array ( ) Now to allow the 15 people or so who will be using the webapp currently to log in, do I need to create a users table in the mysql database with their email address as a key? Then compare the email which just came back from the Google OAuth request and see if it exists in my users table? What about the Google access_token, do I store that now along with the email which already existed in the users table? Related: How would I go about verifying the user automatically in the future against that access_token so they don't have to go through the whole OAuth approval process with Google again?

    Read the article

  • only default controller is loading for all request - Critical

    - by Jayapal Chandran
    Hi, My codeigniter project is in live. I have two copies of it. One in the root and another in a subfolder. Both are configered to work normal. The root copy if the one which was made after testing in a subfolder. While running from the a subfolder all worked well. But when copied to the root folder the default controller is loading for all requests. But were as in subfolders and in other servers it is working well. It is like the following A true copy in root folder like sitename.com and another true copy in a subfolder like sitename.com/abc when requesting like this sitename.com/gallery the default controller is loaded instead of gallery controller. When i tried like this sitename.com/index.php/gallery/ then it worked well... but sitename.com/gallery/ is showing only the default controller. that is the index page. here is my htaccess... php_flag magic_quotes_gpc off php_flag short_open_tag on RewriteEngine on RewriteCond $1 !^(index\.php|images|css|static|font|xml|flash|galleryimages|htc|store|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L] The server is Linux barracuda.elinuxservers.com 2.6.27.18-21 #1 SMP Tue Aug 25 18:13:37 UTC 2009 i686 PHP Version 5.2.9

    Read the article

  • Download Remote File

    - by Abs
    Hello all, I have a function that will be passed in a link. The link is to a remote image. I thought I could just use the extension of the file in the URL to determine the type of image but some URLs won't have extensions in the URL. They probably just push headers to the browser and therefore I do not have an extension to parse from the URL. How can I test if the URL has an extension and if not then read the headers to determine the file type? Am I over complicating things here? Is there an easier way to do this? I am making use of Codeigniter maybe there is something already built in to do this? All I really want to do is download an image from a URL with the correct extension. This is what I have so far. function get_image($image_link){ $remoteFile = $image_link; $ext = ''; //some URLs might not have an extension $file = fopen($remoteFile, "r"); if (!$file) { return false; }else{ $line = ''; while (!feof ($file)) { $line .= fgets ($file, 4096); } $file_name = time().$ext; file_put_contents($file_name, $line); } fclose($file); } Thanks all for any help

    Read the article

  • JQuery datepicker icon trigger broken after inserting data to database

    - by crisgine callano
    at first i got to load my icon for the JQuery datepicker but after i insert the value to my database the icon image is broken. im using Codeigniter framework. here's my html code: <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>CRUD</title> <?php echo link_tag(base_url() . 'css/ui-lightness/jquery-ui-1.8.23.custom.css'); ?> </head> <body> <div> <?php echo form_label('BDay:', 'bday'); $data = array( 'name' => 'bday', 'id' => 'datepicker' ); echo form_input($data); ?> </div> </body> </html> and here's my jscript: <script> $(function() { $( "#datepicker" ).datepicker({ changeMonth: true, changeYear: true, showOn: "button", buttonImage: "<?php echo base_url() . '/images/icons/calendar_24.png' ?>", buttonImageOnly: true, onSelect: function(dateText, inst){ $("input[name='bday']").val(dateText); } }); }); am i missing something? thanks!

    Read the article

  • If Key Value pair exists in multidimensional array.. How to?

    - by Daniel White
    I have a codeigniter shopping cart going and its "cart" array is the following: Array ( [a87ff679a2f3e71d9181a67b7542122c] => Array ( [rowid] => a87ff679a2f3e71d9181a67b7542122c [id] => 4 [qty] => 1 [price] => 12.95 [name] => Maroon Choir Stole [image] => 2353463627maroon_3.jpg [custprod] => 0 [subtotal] => 12.95 ) [8f14e45fceea167a5a36dedd4bea2543] => Array ( [rowid] => 8f14e45fceea167a5a36dedd4bea2543 [id] => 7 [qty] => 1 [price] => 12.95 [name] => Shiny Red Choir Stole [image] => 2899638984red_vstole_1.jpg [custprod] => 0 [subtotal] => 12.95 ) [eccbc87e4b5ce2fe28308fd9f2a7baf3] => Array ( [rowid] => eccbc87e4b5ce2fe28308fd9f2a7baf3 [id] => 3 [qty] => 1 [price] => 14.95 [name] => Royal Blue Choir Stole [image] => 1270984005royal_vstole.jpg [custprod] => 1 [subtotal] => 14.95 ) ) My goal is to loop through this multidimensional array some how and if ANY product with the key value pair "custprod == 1" exists, then my checkout page will display one thing, and if no custom products are in the cart it displays another thing. Any help is appreciated. Thanks.

    Read the article

  • Best way to not update empty posts

    - by user1533106
    Hello, Im using codeigniter, and the page in case just update infos about an user. If the user go to the page and edit values and that posts come as "" or empty (samething) then no update it let the query pass it, i got a logic but its a bit ugly and ill take alot of time. $nome = "'nome' =>" . $this->input->post('nome') . "'"; $sobrenome = "'sobrenome' =>" . $this->input->post('sobrenome') . "'"; if($nome != ""){ $nome = "'nome' =>" . $this->input->post('nome') . "'"; }else{ $nome = ""; } if($sobrenome != ""){ $sobrenome = "'sobrenome' =>" . $this->input->post('sobrenome') . "'"; }else{ $sobrenome = ""; } $data = array($nome, $sobrenome); The problem is, i got alot of fields :( If anyone know a smart way or a better way, please i want know

    Read the article

  • how to unzip uploaded zip file?

    - by Jaydeepsinh Jadeja
    I am trying to upload a zipped file using codeigniter framework with following code function do_upload() { $name=time(); $config['upload_path'] = './uploadedModules/'; $config['allowed_types'] = 'zip|rar'; $this->load->library('upload', $config); if ( ! $this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('upload_view', $error); } else { $data = array('upload_data' => $this->upload->data()); $this->load->library('unzip'); // Optional: Only take out these files, anything else is ignored $this->unzip->allow(array('css', 'js', 'png', 'gif', 'jpeg', 'jpg', 'tpl', 'html', 'swf')); $this->unzip->extract('./uploadedModules/'.$data['upload_data']['file_name'], './application/modules/'); $pieces = explode(".", $data['upload_data']['file_name']); $title=$pieces[0]; $status=1; $core=0; $this->addons_model->insertNewModule($title,$status,$core); } } But the main problem is that when extract function is called, it extract the zip but the result is empty folder. Is there any way to overcome this problem?

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >