Daily Archives

Articles indexed Friday May 21 2010

Page 21/114 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Search Result displaying-like google php

    - by Ramesh
    i have an paragraph and user will search inside that and if the search term has 3 matches inside but all are in 3 different places ex World War II, or the Second World War[1] (often abbreviated WWII or WW2), was a global military conflict lasting from 1939 to 1945 which involved most of the world's nations, including all of the great powers, organised into two opposing military alliances: the Allies and the Axis. It was the most widespread war in history, with more than 100 million military personnel mobilised. In a state of "total war," the major participants placed their entire economic, industrial, and scientific capabilities at the service of the war effort, erasing the distinction between civilian and military resources. Marked by significant action against civilians, including the Holocaust and the only use of nuclear weapons in warfare, it was the deadliest conflict in human history,[2] with over seventy million casualties. i have to search "war" so that it should display like World War II, or the Second World War[1].....In a state of "totalwar,".... some thing like this ///

    Read the article

  • Retrieve data from .dat file.

    - by Zach
    We have an application which requires us to read data from a file (.dat) dynamically using deserialization. We are actually getting first object and it throws null pointer exception when we are accessing other objects using a "for" loop. File file=null; FileOutputStream fos=null; BufferedOutputStream bos=null; ObjectOutputStream oos=null; try{ file=new File("account4.dat"); fos=new FileOutputStream(file,true); bos=new BufferedOutputStream(fos); oos=new ObjectOutputStream(bos); oos.writeObject(m); System.out.println("object serialized"); amlist=new MemberAccountList(); oos.close(); } catch(Exception ex){ ex.printStackTrace(); } Reading objects: try{ MemberAccount m1; file=new File("account4.dat");//add your code here fis=new FileInputStream(file); bis=new BufferedInputStream(fis); ois=new ObjectInputStream(bis); System.out.println(ois.readObject()); while(ois.readObject()!=null){ m1=(MemberAccount)ois.readObject(); System.out.println(m1.toString()); }/mList.addElement(m1); // Here we have the issue throwing null pointer exception Enumeration elist=mList.elements(); while(elist.hasMoreElements()){ obj=elist.nextElement(); System.out.println(obj.toString()); }/ } catch(ClassNotFoundException e){ } catch(EOFException e){ System.out.println("end"); } catch(Exception ex){ ex.printStackTrace(); }

    Read the article

  • is there any chance of sql injection through selectbox( dynamically created or static)

    - by I Like PHP
    Hello All, i want to know that is there any chance of SQL injection via selectbox options? if yes then will u please show some demonstration(or refer any link). and also tell me how do we prevent sql injection in selectbox.(using PHP MYSQL) one more: if i create a selectbox dynamically( based on options of another select box) then is there any chance of SQLinjection? Thanking you.

    Read the article

  • How do i view the local database version in safari on the iphone?

    - by ~potsed
    I am trying to see the localDatabase version from my iPhone in safari but it is not displaying, according to the docs i am supposed to be able to do this: var db = openDatabase('dbShortName', '', 'dbLongName', 1000); alert(db.version); and it should alert the current version number. It does not. It works in Chrome and safari for the desktop but not the iPhone. Does anybody have some idea why? My next option is to store the version in a separate table, but I would prefer to use the built in system. Thanks in advance.

    Read the article

  • MySQL counting question

    - by gew
    How do I find out which user entered the most articles and then count how many articles that user entered using PHP & MySQL. Here is my MySQL tables. CREATE TABLE users_articles ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id INT UNSIGNED NOT NULL, title TEXT NOT NULL, acontent LONGTEXT NOT NULL, PRIMARY KEY (id) ); CREATE TABLE users ( user_id INT UNSIGNED NOT NULL AUTO_INCREMENT, username VARCHAR(255) DEFAULT NULL, pass CHAR(40) NOT NULL, PRIMARY KEY (user_id) );

    Read the article

  • jquery how to access the an xml node by index?

    - by DS
    Hi, say I've an xml returned from server like this: <persons> <person> <firstname>Jon</firstname> </person> <person> <firstname>Jack</firstname> </person> <person> <firstname>James</firstname> </person> </persons> If I want to access the 3rd firstname node (passed dynamically and stored in i, assumed to be 3 here), how do I do that? My weird attempt follows: var i=3; $(xml).find('firstname').each(function(idx){ if (idx==i) alert($(this).text()); }); It does fetch me the right content... but it just feels wrong to me especially the looping part. Basically I'm looping through the whole tree using .each()! Is there any better approach than this? Something that'd take me to the nth node directly like: alert( $(xml).find('firstname')[idx].text() ); // where idx=n I'm new to jquery so please excuse my jquery coding approach.

    Read the article

  • Python How to make a cross-module function?

    - by Evan
    I want to be able to call a global function from an imported class, for example In file PetStore.py class AnimalSound(object): def __init__(self): if 'makenoise' in globals(): self.makenoise = globals()['makenoise'] else: self.makenoise = lambda: 'meow' def __str__(self): return self.makenoise() Then when I test in the Python Interpreter >>> def makenoise(): ... return 'bark' ... >>> from PetStore import AnimalSound >>> sound = AnimalSound() >>> sound.makenoise() 'meow' I get a 'meow' instead of 'bark'. I have tried using the solutions provided in python-how-to-make-a-cross-module-variable with no luck.

    Read the article

  • Android 2.2 and "Bad address family" on Socket Connect

    - by Josh
    I have a fairly simple game that works perfectly on every version now up through 2.1, but with the new 2.2 (Froyo) release I am unable to create a socket. I am using the mina package for nio, and get this exception: W/System.err( 263): java.net.SocketException: Bad address family W/System.err( 263): at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method) W/System.err( 263): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:115) W/System.err( 263): at org.apache.harmony.nio.internal.SocketChannelImpl.connect(SocketChannelImpl.java:272) W/System.err( 263): at org.apache.harmony.nio.internal.PipeImpl$SinkChannelImpl.finishConnect(PipeImpl.java:164) W/System.err( 263): at org.apache.harmony.nio.internal.PipeImpl.(PipeImpl.java:48) W/System.err( 263): at org.apache.harmony.nio.internal.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:51) W/System.err( 263): at org.apache.harmony.nio.internal.SelectorImpl.(SelectorImpl.java:141) W/System.err( 263): at org.apache.harmony.nio.internal.SelectorProviderImpl.openSelector(SelectorProviderImpl.java:58) W/System.err( 263): at java.nio.channels.Selector.open(Selector.java:48) W/System.err( 263): at org.apache.mina.transport.socket.nio.SocketConnector.startupWorker(SocketConnector.java:248) W/System.err( 263): at org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:210) W/System.err( 263): at org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:137) W/System.err( 263): at org.apache.mina.common.support.BaseIoConnector.connect(BaseIoConnector.java:40) Later in the log, usually immediately following I get this: W/System.err( 263): java.lang.NullPointerException W/System.err( 263): at org.apache.harmony.nio.internal.SelectorImpl.wakeup(SelectorImpl.java:418) W/System.err( 263): at org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:222) W/System.err( 263): at org.apache.mina.transport.socket.nio.SocketConnector.connect(SocketConnector.java:137) W/System.err( 263): at org.apache.mina.common.support.BaseIoConnector.connect(BaseIoConnector.java:40) I have done all the googling and looking around I can think of and found nothing. The closest I have come seems to be an old JDK bug with ipv6 support on XP and Vista machines (I'm running Vista). Recommendations included disabling ipv6 (that did not work) and disabling ipv4 and leaving ipv6 (will not work for me as my router and ISP don't support it and so could not test anyway). Any thoughts, suggestions, things I have not tried? Thanks, Josh

    Read the article

  • Looking for recommnedation on JavaScript libraries in the leage of ExtJS and Qooxdoo for serious web

    - by Kabeer
    Hello. I'm looking for a JavaScript library for my web application. The application is very data intensive and has rich form controls (almost windows like). AJAX will be used liberally. The development platform is ASP.Net (mostly ASP.Net MVC will be used). I cannot pursue with ExtJs due to the price/license factor. I checked Qooxdoo but it is very windows-unfriendly. YIU fell short of my needs w.r.t. form controls it offers. Other libraries like jQuery do not offer rich form controls. So I am looking recommendations for a library that satisfies most of following needs: Rich UI controls Solid API for AJAX handling Employs good programming practices for scripting in frontend (preferably OO but not mandatory) Free. Else has only development cost and not production Windows friendly (or at least not unfriendly) Not monolithic. Should be independent (Not have development & production dependencies) Theme'ing should be easy (preferably wrapped by the library) I am not mentioning other basic needs (like browser compatibility). I hope any popular library will honor those.

    Read the article

  • How to compile a C project with more than one main function?

    - by Daziplqa
    Hi folks, I am new to C, and now read some textbook and going to apply its examples. The problem is, whenever I creates a new project and try to put more than one file that contains a main function, the linker (as I thougt0 explains saying: /home/mohammed/tmp/abcd/main.c:4: multiple definition of `main' (BTW, I used many IDEs, MonoDevelop, QT creator, VS2010, Codebloks, ...) I am currently uses QT Creator, It seems to be a very nice IDE. So, there's not a workaround to solve such problem??

    Read the article

  • State machines in C#

    - by Sir Psycho
    Hi, I'm trying to work out what's going on with this code. I have two threads iterating over the range and I'm trying to understand what is happening when the second thread calls GetEnumerator(). This line in particular (T current = start;), seems to spawn a new 'instance' in this method by the second thread. Seeing that there is only one instance of the DateRange class, I'm trying to understand why this works. Thanks in advance. class Program { static void Main(string[] args) { var daterange = new DateRange(DateTime.Now, DateTime.Now.AddDays(10), new TimeSpan(24, 0, 0)); var ts1 = new ThreadStart(delegate { foreach (var date in daterange) { Console.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + " " + date); } }); var ts2 = new ThreadStart(delegate { foreach (var date in daterange) { Console.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + " " + date); } }); Thread t1 = new Thread(ts1); Thread t2 = new Thread(ts2); t1.Start(); Thread.Sleep(4000); t2.Start(); Console.Read(); } } public class DateRange : Range<DateTime> { public DateTime Start { get; private set; } public DateTime End { get; private set; } public TimeSpan SkipValue { get; private set; } public DateRange(DateTime start, DateTime end, TimeSpan skip) : base(start, end) { SkipValue = skip; } public override DateTime GetNextElement(DateTime current) { return current.Add(SkipValue); } } public abstract class Range<T> : IEnumerable<T> where T : IComparable<T> { readonly T start; readonly T end; public Range(T start, T end) { if (start.CompareTo(end) > 0) throw new ArgumentException("Start value greater than end value"); this.start = start; this.end = end; } public abstract T GetNextElement(T currentElement); public IEnumerator<T> GetEnumerator() { T current = start; do { Thread.Sleep(1000); yield return current; current = GetNextElement(current); } while (current.CompareTo(end) < 1); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } }

    Read the article

  • WAS Server - Apache critical problem

    - by murali
    hi, I am facing critical problem for integration of WAS Server-Apache Server.I am using the WAS server for the connection pooling for the database calling...and my webpage is hosted in the apache server and the webpage serarch box is calling the WAS Server and i am using struts frame work for autocomplete action... but it is working in IE of all versions.. but it is not working any browser... the JS file HTTPsuggestions are going to the structs frame work... but the response is is giving as null even i am giving the xmlHttpGetSuggestions.status =200 || xmlHttpGetSuggestions.status =0 but i am not getting the autocomplete feature. can you please help to slove this problem..... Thanks, Murali

    Read the article

  • How to ad users using A shiro Plugin

    - by Anirudh
    Hello, I am using Shiro plugin for my grails application security, My application already has a user .Using the shiro plugin, we get a shiro user, now how do i integrate the shiro user with the normal user of my application,show i go ahead and use relationships or is it that the user class ahould be only a shiro user class now ??

    Read the article

  • GUI for Build Process

    - by sarah xia
    Hi All, I've just implemented build and deploy process which consists of java files, ant script and cmd files. In the process, a release manager will have to check out source, hit the build.cmd button and then carry a zip file over to a server. I am wondering if it is worthwhile to make a GUI for it? So that the release manager does not need to check out source manually for example? How do I start? I have quite limited knowledge of javax, but I very much like to learn. Thanks, Sarah

    Read the article

  • idomatic batch processing of text in emacs?

    - by Stephen
    In python, you might do something like fout = open('out','w') fin = open('in') for line in fin: fout.write(process(line)+"\n") fin.close() fout.close() (I think it would be similar in many other languages as well). In emacs lisp, would you do something like (find-file 'out') (setq fout (current-buffer) (find-file 'in') (setq fin (current-buffer) (while moreLines (setq begin (point)) (move-end-of-line 1) (setq line (buffer-substring-no-properties begin (point)) ;; maybe (print (process line) fout) ;; or (save-excursion (set-buffer fout) (insert (process line))) (setq moreLines (= 0 (forward-line 1)))) (kill-buffer fin) (kill-buffer fout) which I got inspiration (and code) from here. Or should I try something entirely different? And how to remove the "" from the print statement? Thanks!

    Read the article

  • Structuring projects & dependencies of large winforms applications in C#

    - by Benjol
    UPDATE: This is one of my most-visited questions, and yet I still haven't really found a satisfactory solution for my project. One idea I read in an answer to another question is to create a tool which can build solutions 'on the fly' for projects that you pick from a list. I have yet to try that though. How do you structure a very large application? Multiple smallish projects/assemblies in one big solution? A few big projects? One solution per project? And how do you manage dependencies in the case where you don't have one solution. Note: I'm looking for advice based on experience, not answers you found on Google (I can do that myself). I'm currently working on an application which has upward of 80 dlls, each in its own solution. Managing the dependencies is almost a full time job. There is a custom in-house 'source control' with added functionality for copying dependency dlls all over the place. Seems like a sub-optimum solution to me, but is there a better way? Working on a solution with 80 projects would be pretty rough in practice, I fear. (Context: winforms, not web) EDIT: (If you think this is a different question, leave me a comment) It seems to me that there are interdependencies between: Project/Solution structure for an application Folder/File structure Branch structure for source control (if you use branching) But I have great difficulty separating these out to consider them individually, if that is even possible. I have asked another related question here.

    Read the article

  • Asp.Net Export to Excel - Japanese Characters

    - by Kalyan
    I am currently using Visual Studio 2008 for my ASP .NET application. I am trying to Export some reports with Japanese Characters to Excel via the Response object. When I try to Export, all the Japanese characters looks garbled. It works fine with Chinese Characters. Here is what I tried: I tried Installed Japanese Language Pack / Encoding to UTF-8 / UTF-7 / Shift-JIS / Globalization (Web.Config) .. but no luck. Any Ideas how this can be fixed ? Thanks !! string attachment = "attachment; filename=PerksPlusReport.xls"; //Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("content-disposition", attachment); //Response.Charset = "UTF-8"; //Response.Charset = "UTF-7"; //Response.Charset = "Shift_JIS"; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); // Create a form to contain the grid HtmlForm frm = new HtmlForm(); ReportGridView.Parent.Controls.Add(frm); frm.Attributes["runat"] = "server"; GridView GridView2 = new GridView(); ReportView reportDetails = GetReportDetails(); GridView2.DataSource = GetReportResults(this.ReportId.Value, reportDetails.Sql); GridView2.DataBind(); PrepareGridViewForExport(GridView2); frm.Controls.Add(GridView2); frm.RenderControl(htw); string fileContents = sw.ToString(); int startSpot = fileContents.IndexOf("<table"); fileContents = fileContents.Substring(startSpot); int endSpot = fileContents.IndexOf("</table>"); fileContents = fileContents.Substring(0, endSpot + 8); try { // Replace all &lt; and &gt; with < and > fileContents = fileContents.Replace("&lt;", "<"); fileContents = fileContents.Replace("&gt;", ">"); fileContents = fileContents.Replace("€", "&euro;"); string RegularExpression = @"<a[^>]*>([^<]*)</a>"; Regex regex = new Regex(RegularExpression); //If match found .. uses the delegate function to replace the whole content with the filtered values if (regex.IsMatch(fileContents)) { regex.Replace(fileContents, delegate (Match m){return fileContents.Replace(m.Captures[0].Value, m.Groups[1].Value);}); } } catch (Exception ex2) { Response.Write(ex2.ToString()); } Response.Write(fileContents); Response.End();

    Read the article

  • PHP - My array returns NULL values when placed in a function, but works fine outside of the function

    - by orbit82
    Okay, let me see if I can explain this. I am making a newspaper WordPress theme. The theme pulls posts from categories. The front page shows multiple categories, organized as "newsboxes". Each post should show up only ONCE on the front page, even if said post is in two or more categories. To prevent posts from duplicating on the front page, I've created an array that keeps track of the individual post IDs. When a post FIRST shows up on the front page, its ID gets added to the array. Before looping through the posts for each category, the code first checks the array to see which posts have ALREADY been displayed. OK, so now remember how I said earlier that the front page shows multiple categories organized as "newsboxes"? Well, these newsboxes are called onto the front page using PHP includes. I have 6 newsboxes appearing on the front page, and the code to call them is EXACTLY the same. I didn't want to repeat the same code 6 times, so I put all of the inclusion code into a function. The function works, but the only problem is that it screws up the duplicate posts code I mentioned earlier. The posts all repeat. Running a var_dump on the $do_not_duplicate variable returns an array with null indices. Everything works PERFECTLY if I don't put the code inside a function, but once I do put them in a function it's like the arrays aren't even connecting with the posts. Here is the code with the arrays. The key variables in question here include $do_not_duplicate[] = $post-ID, $do_not_duplicate and 'post__not_in' = $do_not_duplicate <?php query_posts('cat='.$settings['cpress_top_story_category'].'&posts_per_page='.$settings['cpress_number_of_top_stories'].'');?> <?php if (have_posts()) : ?> <!--TOP STORY--> <div id="topStory"> <?php while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('top-story-thumbnail'); ?></a> <h2 class="extraLargeHeadline"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <div class="topStory_author"><?php cpress_show_post_author_byline(); ?></div> <div <?php post_class('topStory_entry') ?> id="post-<?php the_ID(); ?>"> <?php if($settings['cpress_excerpt_or_content_top_story_newsbox'] == "content") { the_content(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php } else { the_excerpt(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php }?> </div><!--/topStoryentry--> <div class="topStory_meta"><?php cpress_show_post_meta(); ?></div> <?php endwhile; wp_reset_query(); ?> <?php if(!$settings['cpress_hide_top_story_more_stories']) { ?> <!--More Top Stories--><div id="moreTopStories"> <?php $category_link = get_category_link(''.$settings['cpress_top_story_category'].''); ?> <?php if (have_posts()) : ?> <?php query_posts( array( 'cat' => ''.$settings['cpress_top_story_category'].'', 'posts_per_page' => ''.$settings['cpress_number_of_more_top_stories'].'', 'post__not_in' => $do_not_duplicate ) ); ?> <h4 class="moreStories"> <?php if($settings['cpress_make_top_story_more_stories_link']) { ?> <a href="<?php echo $category_link; ?>" title="<?php echo strip_tags($settings['cpress_top_story_more_stories_text']);?>"><?php echo strip_tags($settings['cpress_top_story_more_stories_text']);?></a><?php } else { echo strip_tags($settings['cpress_top_story_more_stories_text']); } ?> </h4> <ul> <?php while( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?> <li><h2 class="mediumHeadline"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php if(!$settings['cpress_hide_more_top_stories_excerpt']) { ?> <div <?php post_class('moreTopStory_postExcerpt') ?> id="post-<?php the_ID(); ?>"><?php if($settings['cpress_excerpt_or_content_top_story_newsbox'] == "content") { the_content(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php } else { the_excerpt(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php }?> </div><?php } ?> <div class="moreTopStory_postMeta"><?php cpress_show_post_meta(); ?></div> </li> <?php endwhile; wp_reset_query(); ?> </ul> <?php endif;?> </div><!--/moreTopStories--> <?php } ?> <?php echo(var_dump($do_not_duplicate)); ?> </div><!--/TOP STORY--> <?php endif; ?> And here is the code that includes the newsboxes onto the front page. This is the code I'm trying to put into a function to avoid duplicating it 6 times on one page. function cpress_show_templatebitsf($tbit_num, $tbit_option) { global $tbit_path; global $shortname; $settings = get_option($shortname.'_options'); //display the templatebits (usually these will be sidebars) for ($i=1; $i<=$tbit_num; $i++) { $tbit = strip_tags($settings[$tbit_option .$i]); if($tbit !="") { include_once(TEMPLATEPATH . $tbit_path. $tbit.'.php'); } //if }//for loop unset($tbit_option); } I hope this makes sense. It's kind of a complex thing to explain but I've tried many things to fix it and have had no luck. I'm stumped. I'm hoping it's just some little thing I'm overlooking because it seems like it shouldn't be such a problem.

    Read the article

  • Keeping object in memory (iPhone SDK)

    - by Chris
    I am trying to create a UIImageView called theImageView in the touchesBegan method that I can then then move to a new location in touchesMoved. Currently I am receiving an "undeclared" error in touchesMoved where I set the new location for theImageView. What can I do to keep theImageView in memory between these two methods? - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { ... UIImageView *theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; theImageView.frame = CGRectMake(263, 228, 193, 300); [theImageView retain]; ... } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { ... theImageView.frame = CGRectMake(300, 300, 193, 300); ... }

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >