php,httpRelated issues-Collection of common programming errors


  • Aviel Fadida
    php spl filter-iterator
    I am trying to understand the behaviour of FilterIterator at This Code, I was trying to understand the action sequences, I didnt understand why if you try to print the current() value it wont work unless you will use next() or rewind() before for example:// Please take a look at the link before echo $cull->current(); // wont work $cull->next(); or $cull->rewind(); then echo $cull->current(); // workNow i dont know what i have to “Refresh” the “Pointer” to be able to print elements, i

  • shin
    php
    I have the following array structure in MySQL. There could be no items or many items; the example shows only three.Array ([0] => Array([id] => 1…[start_time] => 09:00:00[finish_time] => 10:20:00…)[1] => Array([id] => 2…[start_time] => 13:00:00[finish_time] => 14:20:00…)[2] => Array([id] => 23…[start_time] => 18:05:00[finish_time] => 19:35:00…)etc etc)I want to add the time difference between start_time and finish_time and find out the total time wi

  • themerlinproject
    php
    Looping through a dynamically-named array and comparing results to the previous positions results.if($s>1 && $s<=10){if( ${“strat{$s}”}[total] > ${“strat{$s-1}”}[total] )$sl_best = $sl_mult; //if this one did better than the previous one, then grab the value} And I’m getting error messages related the the ${“strat{$s-1}”}[total], specifically the {$s-1} portion. Here is the error message:Parse error: syntax error, unexpected ‘-‘, expecting ‘}’ …Any thoughts on how to check the

  • moogeek
    php oop class object
    How can I dynamically pass “items” to class function? For example here it is a piece of some class and its function where I declare an element of object (items) as $b://……….public function __add2SomeObj($b) { $namespc = $this -> __someObj(); // __someObj() returns object$namespc -> cats = $b;} //……………….Can I pass any other name instead cats dynamically so it won’t be declared as a string? i.e. something like://……….public function __add2SomeObj($a,$b) { $namespc

  • Brad
    php ubuntu apache2
    I have a VM with ubuntu 12.04 and running apache2 as a web server. I’ve installed PHP 5.3.10 and every time I run a php application, my php.ini throws this error: PHP: syntax error, unexpected BOOL_FALSE in /etc/php5/cli/php.ini on line 1020I’d expect that something wasn’t commented out correctly in the php.ini but when I look at it, I can’t see what’s wrong: 1007 [Pcre] 1008 ;PCRE library backtracking limit. 1009 ; http://php.net/pcre.backtrack-limit 1010 ;pcre.backtrack_limit=100000 1011 10

  • js111
    php wordpress
    I’m working with a WordPress theme (genesis framework) and i need to input a php snippet into the post meta function (right after post_edit). I cannot seem to get this to work without throwing an error. This is the function I need to work with:add_filter( ‘genesis_post_info’, ‘sp_post_info_filter’ ); function sp_post_info_filter($post_info) {$post_info = ‘[post_date] by [post_author_posts_link] [post_comments] [post_edit]’;return $post_info; }And this is the PHP snippet I need to use<?php ech

  • Julibear Police
    php
    I have this code below for updating a line on a text file.$filename = “flat-file-data.txt”; // File which holds all data $rowToUpdate = 1; // This is line need to be updated $newString = “This text is updated\n”; // This is what you want to replace it with$arrFp = file( $filename ); // Open the data file as an array // Replace the current element in array which needs to be updated with new string $arrFp[$rowToUpdate-1] = $newString; $numLines = count( $arrFp ); // Count the elements in the arra

  • Shawn31313
    php json object
    This question already has an answer here:PHP dynamic name for object property2 answersI basically know how to add a new key value pair to JSON through PHP like:$json->newObject = “value”;What I can’t however figure out is how to give the key of the pair, a random ID.I’ve tried something like:$id = rand(99, 9999); $json[“newObject” . $id] = “value”;With an error of: Fatal error: Cannot use object of type stdClass as array in /home/methodjs/public_html/projects/chat/send.php on line 8And:$id =

  • Duncan
    php arrays pdo
    Using the guidelines suggested by netnuts for the use of Data Objects for Database access, specifically in relation to unnamed placeholders# the data we want to insert $data = array(‘Cathy’, ‘9 Dark and Twisty Road’, ‘Cardiff’); $STH = $DBH->(“INSERT INTO folks (name, addr, city) values (?, ?, ?); $STH->execute($data);unfortunately seems to produce a parse error for the code# the data we want to insert $data = array($first_name, $second_name, $email_from, $telephone, $dateofbirth, $address

  • daNullSet
    php
    Look at the code below<?php //The array is storing a blog entry in it $entry = array (‘title’ => ‘sample title’,’date’ => ‘August 9, 2011′,’author’ => ‘daNullSet’,’body’ => ‘I shall become a web developer IA’,); echo “The title of the blog is “.$entry[‘title’].”<br />”; ?>The code above executes quite well, but it returns the following parse error when I enclose $entry[‘title’] in double quotes while concatenating with other strings in echo statement.Parse error: syntax e

  • ChuckE
    ruby-on-rails http responders
    I’m trying to use bare bones rails controllers and have a more fine-grained control at the same time. If I’m on :new action, I respond_with my new @instance and I get a status code 200 and render the :new template. On show, same thing, different template. So far, so good. But, on the create, I’m having something unexpected. If the new record was successfully and I call respond_with on it, I am redirected to show (status code 302), which is right. But if the new record couldn’t be created because

  • Joseph
    http node.js ubuntu ubuntu-11.10
    I’m installing node.js on Ubuntu as per these instructions ( http://nodenode.com/post/1197688151/installing-node-js-on-ubuntu-screencast-tutorial )and I’m recieving the following errors on the final stepI type node hello_node.jsmy terminal replies/home/joe/tmp/hello_node/hello_node.js:1 require(‘http’);^node.js:201throw e; // process.nextTick error, or ‘error’ event on first tick^SyntaxError: Unexpected token ILLEGALat Module._compile (module.js:427:25)at Object..js (module.js:450:10)at Module.

  • hvr
    http sockets tcp rfc
    I’ve observed a HTTP 1.1 Server implementation, which terminates a client connection as soon as it detects a client-side connection shutdown of its outgoing channel (or rather, either before or after sending a proper http response). Is this a conforming HTTP 1.1 implementation?RFC 2616 Section 8.1.4 seems to suggest this is to be the proper behaviour:When a client or server wishes to time-out it SHOULD issue a gracefulclose on the transport connection. Clients and servers SHOULD bothconstantly w

  • dvanaria
    java security http cookies
    I’m finishing a Cattle Drive assignment where a small Java web application manages a movie library for the client. The assignment is to put some security on the application using cookies, so that a “hacker” couldn’t just guess one of the URLs that would lead to another part of the application. The user will be directed to login to the site and not be allowed to view other pages until logged in.The parts of the web app are:1. index.html 2. VideoServlet 3. listvideos.jsp 4. addvideo.jsp 5. videolo

  • arnp
    json windows-phone-7 http delegates
    I am using this method to get dataprivate void getNews(int cat_id, int page){this.progress.Visibility = Visibility.Visible;var m = new SharpGIS.GZipWebClient();Microsoft.Phone.Reactive.Observable.FromEvent<DownloadStringCompletedEventArgs>(m, “DownloadStringCompleted”).Subscribe(l =>{try{//List<NewsKeys> deserialized = JsonConvert.DeserializeObject<List<NewsKeys>>(r.EventArgs.Result);ObservableCollection<NewsKeys> deserialized = JsonConvert.DeserializeObject<L

  • Marek Tuchalski
    http node.js
    I need in cycle create http.get request to google api|cache service. With nodejs i try do it for(var i = 41923,postID=i; i <= 41925; i++) {http.get(options, function(res) {res.setEncoding(‘utf8’);res.on(‘data’, function(data) {responseBody += data;}).on(‘end’, function() {if(getPostCacheUrl) {var json = JSON.parse(responseBody);json.items = json.items || [];var cacheUrl = getPostCacheUrl(json);parseCacheUrl(cacheUrl);}}).on(‘error’, function(error) {console.log(‘ERROR’ + error.message);});});

  • ioSamurai
    c# asp.net-mvc http
    What is happening is occasionally at random instead of the HTML being returned to the browser as you would expect, it looks a little something like this:Thread was being aborted.HTTP/1.1 200 OK(the rest of the header)… (like 1/10th of the HTML)That’s it, they are literally getting a bunch of text in the browser window.It doesn’t happen all the time, just randomly. Computers… in my experience always have a reason for everything, ALWAYS. So what’s the heck is going on here?I have searched the

  • Explosion Pills
    http post get http-post http-get
    Simply put, I have a website where you can sign up as a user and add data. Currently it only makes sense to add specific data once, so an addition should be idempotent, but theoretically you could add the same data multiple times. I won’t get into that here.According to RFC 2616, GET requests should be idempotent (really nullipotent). I want users to be able to do something like visithttp://example.com/<username>/add/?data=1And this would add that data. It would make sense to have a PU

  • Dan Maguire
    c# http http-post imageshack
    Does anybody know how to upload to imageshack.us with C#? Two other threads here couldn’t help:/ That’s my piece of code. “PostParamCollection” is a library for sending HTTP Post. Lots of thanks for any help!Im getting the error-message: ” Sorry, but we’ve detected that unexpected data is received. Required parameter ‘fileupload’ is missing or your post is not multipart/form-data”String imageshackurl = “http://www.imageshack.us/upload_api.php?”;PostParamCollection postParamCollection = new PostP

  • Peter Skirko
    http web-applications rest query-string
    I am still fairly new to web application development, so perhaps this is a n00b question.It seems like most websites will just silently ignore query string arguments they do not need nor understand. For example, a github URI usually looks like:https://github.com/airbnbNow if I just tack on a bogus query string, as in:https://github.com/airbnb?foo=barThe page loads just fine and doesn’t complain about the query string.This seems like a perfectly reasonable behavior, and I spot-tested some other s

Web site is in building