Search Results

Search found 91526 results on 3662 pages for 'clean code'.

Page 147/3662 | < Previous Page | 143 144 145 146 147 148 149 150 151 152 153 154  | Next Page >

  • Memory problems while code is running (Python, Networkx)

    - by MIN SU PARK
    I made a code for generate a graph with 379613734 edges. But the code couldn't be finished because of memory. It takes about 97% of server memory when it go through 62 million lines. So I killed it. Do you have any idea to solve this problem? My code is like this: import os, sys import time import networkx as nx G = nx.Graph() ptime = time.time() j = 1 for line in open("./US_Health_Links.txt", 'r'): #for line in open("./test_network.txt", 'r'): follower = line.strip().split()[0] followee = line.strip().split()[1] G.add_edge(follower, followee) if j%1000000 == 0: print j*1.0/1000000, "million lines done", time.time() - ptime ptime = time.time() j += 1 DG = G.to_directed() # P = nx.path_graph(DG) Nn_G = G.number_of_nodes() N_CC = nx.number_connected_components(G) LCC = nx.connected_component_subgraphs(G)[0] n_LCC = LCC.nodes() Nn_LCC = LCC.number_of_nodes() inDegree = DG.in_degree() outDegree = DG.out_degree() Density = nx.density(G) # Diameter = nx.diameter(G) # Centrality = nx.betweenness_centrality(PDG, normalized=True, weighted_edges=False) # Clustering = nx.average_clustering(G) print "number of nodes in G\t" + str(Nn_G) + '\n' + "number of CC in G\t" + str(N_CC) + '\n' + "number of nodes in LCC\t" + str(Nn_LCC) + '\n' + "Density of G\t" + str(Density) + '\n' # sys.exit() # j += 1 The edge data is like this: 1000 1001 1000245 1020191 1000 10267352 1000653 10957902 1000 11039092 1000 1118691 10346 11882 1000 1228281 1000 1247041 1000 12965332 121340 13027572 1000 13075072 1000 13183162 1000 13250162 1214 13326292 1000 13452672 1000 13844892 1000 14061830 12340 1406481 1000 14134703 1000 14216951 1000 14254402 12134 14258044 1000 14270791 1000 14278978 12134 14313332 1000 14392970 1000 14441172 1000 14497568 1000 14502775 1000 14595635 1000 14620544 1000 14632615 10234 14680596 1000 14956164 10230 14998341 112000 15132211 1000 15145450 100 15285998 1000 15288974 1000 15300187 1000 1532061 1000 15326300 Lastly, is there anybody who has an experience to analyze Twitter link data? It's quite hard to me to take a directed graph and calculate average/median indegree and outdegree of nodes. Any help or idea?

    Read the article

  • Why does gcc generate verbose assembly code?

    - by Jared Nash
    I have a question about assembly code generated by GCC (-S option). Since, I am new to assembly language and know very little about it, the question will be very primitive. Still, I hope somebody will answer: Suppose, I have this C code: main(){ int x = 15; int y = 6; int z = x - y; return 0; } If we look at the assembly code (especially the part corresponding to int z = x - y ), we see: main: ... subl $16, %esp movl $15, -4(%ebp) movl $6, -8(%ebp) movl -8(%ebp), %eax movl -4(%ebp), %edx movl %edx, %ecx subl %eax, %ecx movl %ecx, %eax movl %eax, -12(%ebp) ... Why doesn't GCC generate something like this, which is less copying things around. main: ... movl $15, -4(%ebp) movl $6, -8(%ebp) movl -8(%ebp), %edx movl -4(%ebp), %eax subl %edx, %eax movl %eax, -12(%ebp) ... P.S. Linux zion-5 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

    Read the article

  • Python beginer having trouble running code

    - by Protean
    For some reason this code will not seem to run in the interpreter. When I hit F5 nothing happens, not even the debugger seems to recognize it. I assume it has something to do with the class, as when removed the interpreter seems to recognize the rest of the code. Please tell me what I am doing wrong. Edit: I have restarted the interpreter multiple times, any other piece of code I try to load runs fine, just this one is having trouble. print ('Why won't this work?') class sorting_class: def __init__(self): self.order = ['a', 'b', 'c', 'd'] self.globali = 0 self.orderi = 0 self.sortedlist = [] def sort(self, array): carry, leave = [] for arrayi in array: print ('run', arrayi) if self.order[self.orderi] == arrayi[self.globali]: carry.append(arrayi) else: if self.globali != 0: leave.append(arrayi) return carry, leave def srt(self, array): globalii = 0 carry, leave = my.sort(array) while len(self.sortedlist) != len(array): if len(self.carry) == 1: self.sortedlist.append(carry) arrayt = leave self.globali = 1 self.orderi = 0 carry, leave = my.sort(arrayt) elif len(self.carry) == 0: if len(self.leave) != 0: arrayt = leave self.globali = 1 self.orderi += 1 my.sort(arrayt) else: self.arrayt globalii += 1 self.orderi = globalii self.globali = 0 my.sort(arrayt) self.orderi = 0 else: arrayt = carry carry = [] self.globali += 1 carry, leave += my.sort(arrayt) my = sorting_class() x = ['ac', 'bc' ,'ab', 'da'] my.srt(x)

    Read the article

  • PHP Serialize Function - Adding serialized data to mysql and then fetch and display

    - by Abhilash Shukla
    I want to know whether the PHP serialize function is 100% secure, also if we store serialized data into a database and want to do something after fetching it, will it be a nice way. For example:- I have a website with different user privileges, now i want to store the permissions settings for a particular privilege to my database (This data i want to store is to be done through php serialize function), now when a user logs in i want to fetch this data and set the privilege for the customer. Now i am ok to do this thing, what i want to know is, whether it is the best way to do or something more efficient can be done. Also, i was going through php manual and found this code, can anybody explain me a bit what's happening in this code:- [Specially why base64_encode is used?] <?php mySerialize( $obj ) { return base64_encode(gzcompress(serialize($obj))); } myUnserialize( $txt ) { return unserialize(gzuncompress(base64_decode($txt))); } ?> Also if somebody can provide me their own code to show me to do this thing in the most efficient manner. Thanks.

    Read the article

  • Condensing repeating JQuery code

    - by Craig Ward
    I have a page that has a large image on it with a number of thumbnails. When you mouse over a thumbnail the main image changes to the image you have just rolled your mouse over. The problem is the more thumbnails I have, the more repeated code I have. How could I reduce it? The Jquery code is as follows. <script type="text/javascript"> $('#thumb1') .mouseover(function(){ $('#big_img').fadeOut('slow', function(){ $('#big_img').attr('src', '0001.jpg'); $('#big_img').fadeIn('slow'); }); }); $('#thumb2') .mouseover(function(){ $('#big_img').fadeOut('slow', function(){ $('#big_img').attr('src', 'p_0002.jpg'); $('#big_img').fadeIn('slow'); }); }); $('#thumb3') .mouseover(function(){ $('#big_img').fadeOut('slow', function(){ $('#big_img').attr('src', '_img/p_0003.jpg'); $('#big_img').fadeIn('slow'); }); }); $('#thumb4') .mouseover(function(){ $('#big_img').fadeOut('slow', function(){ $('#big_img').attr('src', '0004.jpg'); $('#big_img').fadeIn('slow'); }); }); </script> #big_img = the ID of the full size image #thumb1, #thumb2, #thumb3, #thumb4 = The ID's of the thumbnails The main code for the page is PHP if that helps.

    Read the article

  • Response.Redirect not firing due to code to prevent re-submission

    - by Marco
    I have an event which needs to contact some third party providers before performing a redirect (think 'final payment page on ecommerce site') and hence has some lag associated with its processing. It is very important that these third party providers are not contacted more than once, and sometimes impatient users may try and refresh the page (hence re-submitting the data). The general code structure is: If Session("orderStatus") <> 'processing' Then Session("orderStatus") = 'processing' DoThirdPartyStuffThatTakesSomeTime() Response.Redirect("confirmationPage.asp", True) End If The problem is, if the user refreshes the page, the response.redirect does not happen (even though the rest of the code will run before the redirect from the original submission). It seems that the new submission creates a new thread for the browser which takes precedence - it skips this bit of code obviously to prevent the third party providers being contacted a second time, and since there is no redirect, just comes back to the same page. The whole second submission may have completed before the first submission has finished its job. Any help on how I can still ignore all of the subsequent submissions of the page, but still make the redirect work...? Thanks

    Read the article

  • [F#] Parallelize code in nested loops

    - by Juliet
    You always hear that functional code is inherently easier to parallelize than non-functional code, so I decided to write a function which does the following: Given a input of strings, total up the number of unique characters for each string. So, given the input [ "aaaaa"; "bbb"; "ccccccc"; "abbbc" ], our method will returns a: 6; b: 6; c: 8. Here's what I've written: (* seq<#seq<char>> -> Map<char,int> *) let wordFrequency input = input |> Seq.fold (fun acc text -> (* This inner loop can be processed on its own thread *) text |> Seq.choose (fun char -> if Char.IsLetter char then Some(char) else None) |> Seq.fold (fun (acc : Map<_,_>) item -> match acc.TryFind(item) with | Some(count) -> acc.Add(item, count + 1) | None -> acc.Add(item, 1)) acc ) Map.empty This code is ideally parallelizable, because each string in input can be processed on its own thread. Its not as straightforward as it looks since the innerloop adds items to a Map shared between all of the inputs. I'd like the inner loop factored out into its own thread, and I don't want to use any mutable state. How would I re-write this function using an Async workflow?

    Read the article

  • Separating Content (aspx) from Code (aspx.cs) in ASP.NET

    - by firedrawndagger
    I would like to know what is the best practice on separating the content of an aspx page (ASP.NET 3.5) from the code (I'm using C#). I have a form that users can type data in - for example they are allowed to enter a percent. If they Otherwise for example I would like to display the following error messages: <p id="errormsg" class="percenthigh">Please enter a percent below 100</p> <p id="errormsg" class="percentnegative">Percent cannot be below 0</p> <p id="errormsg" class="percentnot">This is not a percent</p> So in essence I'm hiding the error messages and showing one depending on what the user input is. I believe this is the best way to seperate the content from the code behind. However, how do I select elements and hide/unhide them depending on the user input? I'm aware I can do a runat="server" on the elements but the problem is that I can't select by class and am limited only to ID's. What workarounds do you recommend? Aside from putting in the values in code behind which is notoriously difficult to debug. Also has this been "fixed" in ASP.NET 4?

    Read the article

  • Strategy for developing namespaced and non-namespaced versions of same PHP code

    - by porneL
    I'm maintaining library written for PHP 5.2 and I'd like to create PHP 5.3-namespaced version of it. However, I'd also keep non-namespaced version up to date until PHP 5.3 becomes so old, that even Debian stable ships it ;) I've got rather clean code, about 80 classes following Project_Directory_Filename naming scheme (I'd change them to \Project\Directory\Filename of course) and only few functions and constants (also prefixed with project name). Question is: what's the best way to develop namespaced and non-namespaced versions in parallel? Should I just create fork in repository and keep merging changes between branches? Are there cases where backslash-sprinkled code becomes hard to merge? Should I write script that converts 5.2 version to 5.3 or vice-versa? Should I use PHP tokenizer? sed? C preprocessor? Is there a better way to use namespaces where available and keep backwards compatibility with older PHP?

    Read the article

  • [Delphi] How would you refactor this code?

    - by Al C
    This hypothetical example illustrates several problems I can't seem to get past, even though I keep trying!! ... Suppose the original code is a long event handler, coded in the UI, triggered when a user clicks a cell in a grid. Expressed as pseudocode it's: if Condition1=true then begin //loop through every cell in row, //if aCell/headerCellValue>1 then //color aCell red end else if Condition2=true then begin //do some other calculation adding cell and headerCell values, and //if some other product>2 then //color the whole row green end else show an error message I look at this and say "Ah, refactor to the strategy pattern! The code will be easier to understand, easier to debug, and easier to later extend!" I get that. And I can easily break the code into multiple procedures. The problem is ultimately scope related. Assume the pseudocode makes extensive use of grid properties, values displayed in cells, maybe even built-in grid methods. How do you move all that to another unit, without referencing the grid component in the UI--which would break all the "rules" about loose coupling that make OOP valuable? ... I'm really looking forward to responses. Thanks, as always -- Al C.

    Read the article

  • Cairo / GTK example code crashes when window is too big or maximized

    - by user1890673
    I have copied and compiled the source code available in the section titled "Full Source". http://cairographics.org/threaded_animation_with_cairo/ I adapted this code to a project that I'm working on only to find that the app would crash when I made the window too big. Going back to the original example code, it too crashes when the window is too big ( 1000x1000 or so). I narrowed down in the example that this line appears to be responsible: pixmap = gdk_pixmap_new(window-window,500,500,-1); Where pixmap is of type GdkPixmap*. Resizing the window overwrites pixmap with a new pixmap that is the size of the window. I am doing this in Eclipse Juno in Windows Vista, 32-bit. My compiler is MinGW version 0.5-beta-20120426-1. My GTK+ version is 2.24.10 and apparently Cairo is 1.10.2 I added all of the includes and libraries for GTK and also added compiler switch -mms-bitfields. Is there a limit to the size of a pixmap or something? I'm just starting with GTK with examples so I'm not sure where to go if this example doesn't work.

    Read the article

  • Properly design a code editor application

    - by Hemaulo
    I'm working on personal project which is basically a code editor. Imagine standard File menu with menu items New, Open, Save, Save As, Save All, Close, Close All. I'm stuck with proper design. Currently I have: A Document class which represents a document - code editing control, respective tab in tab bar and various properties such as Caption, Filename, IsModified etc. A Documents class which represents all open documents. Contains methods like New, Open(FileName), ... The problem is that I can't figure out which class / menu command is responsible for which tasks. For example, with File-New menu command is simple - call Documents.New and that's it. But what for File-Open? The Documents.Open method expects filename as a parameter. So before calling this method I need to open an file selection dialog, let user select files and for each file call Documents.Open(FileName). Where is best place for this supporting code, in menu command, rewrite Documents.Open and put it there? The same with Save actions. Which is responsible for saving? Is it Documents class which uses Document.Editor.SaveToFile(FileName) or better create Save method in Document class? Somewhere in the middle also need to ask user if he wants to save current document... I'm stuck. Any ideas? Edited: The programming language is Delphi.

    Read the article

  • Cocoa framework development: sharing between projects

    - by e.James
    I am currently developing a handful of similar Cocoa desktop apps. In an effort to share code between them, I have identified a set of core classes and functions that can be common across all of these applications. I would like to bundle this common code into a framework which all of my current applications (and any future ones) can link against. Now, here's the hard part: I'm going to be developing this framework as I go, so I need each of my desktop apps to have a reference to it, but I want to be able to edit the framework source code from within each of the app projects and have the framework automatically rebuilt as required. For example, let's say I have the Xcode project for DesktopAppNumberOne open, and I decide that one of my framework classes needs to be changed. I would like to: Open and edit the source file for that framework class without having to open the framework project in Xcode. Hit "build" on DesktopAppNumberOne, and see the framework rebuilt first (because one of its sources has changed), then see parts of DesktopAppNumberOne rebuilt (because one of the frameworks it links against has changed). I can see how to do this with only one app and one framework, but I'm having trouble figuring out how to do it with multiple apps that share a single framework. Has anyone had success with this approach? Am I perhaps going about this the wrong way? Any help would be appreciated.

    Read the article

  • Enable Query Strings in Code Igniter

    - by tarnfeld
    Hey, I am trying to implement Twitter's OAuth into my Code Igniter web application at which the callback URL is /auth/ so once you have authenticated with Twitter you are taken to /auth/?oauth_token=SOME-TOKEN. I want to keep the nice clean URL's the framework provides using the /controller/method/ style of URL but I want to enable query strings as well, there will only ever be one name of the data oauth_token so it's ok if it has to be hard coded. Any ideas? I have tried tons of the things people are saying to do, but none work :( PS: I'm using the .htaccess method of URL rewriting.

    Read the article

  • Code picks up value from selectOneMenu and selectBooleanCheckbox, even though it is not rendered

    - by hpe
    I've got code the following code in my .xhtml <t:panelGroup rendered="false"> <t:selectOneMenu id="id" value="#{row.someValue}" displayValueOnly="#{form.readState}"> <f:selectItems value="#{row.listOfValues}"/> </t:selectOneMenu> </t:panelGroup> The listOfValues is set in a form populator, and is thus present in the form object. Also, as expected, the portion outlined above is not rendered in the output HTML. But, when clicking the save button in the page the following code tries to get the value from the XHTML, even though it is not rendered. It will thus not copy the value present in the form, but set it to null (as it is not set in the XHTML). object1.setSomeValue(form.getSomeValue()); As far as I can see this only happens with selectBooleanCheckbox and selectOneMenu. E.g. inputText works fine. Any idea on how to fix it?

    Read the article

  • Visual studio feature - commenting code Ctrl K - Ctrl C

    - by Michael
    I commented on this answer some time ago regarding how visual studio comments out code with // or /* */. I was thinking to revise the answer (to include my findings) but I had to test it first, which kind of confused me. My finding is that depending on where your marker is when you press Ctrl - K, Ctrl - C you will get either // or /* */. So I tried it out on the following code: [1] [2]FD_ZERO(&mFSet); FD_SET(user->mSender, &mFSet); timeval zeroTime = { 0, 0 }; int sel = select(0, NULL, &mFSet, NULL, &zeroTime); [3] if (sel == SOCKET_ERROR){ [5]return false; [4] } if (sel == 0){ [6] return false; [7] } The [x] is markerpositions. All [1] positions give // for all marked lines. However Start position End Position: gives: [2] [3] : /* */ [2] [4] : // [2] [5] : /* */ [2] [more than 5] : // [5] [6] : /* */ [5] [7] : // I guess it has to do with forward indentation (not backwards), that whenever code is indented more than the starting line you get // except when you haven't selected any text on the indented line ([2] [5]). But why the distinction? Why not use /* */ for when you start at [2] and // when you start at [1]?

    Read the article

  • Differences between Assembly Code output of the same program

    - by ultrajohn
    I have been trying to replicate the buffer overflow example3 from this article aleph one I'm doing this as a practice for a project in a computer security course i'm taking so please, I badly need your help. I've been the following the example, performing the tasks as I go along. My problem is the assembly code dumped by gdb in my computer (i'm doing this on a debian linux image running on VM Ware) is different from that of the example in the article. There are some constructs which I find confusing. Here is the one from my computer: here is the one from the article... Dump of assembler code for function main: 0x8000490 <main>: pushl %ebp 0x8000491 <main+1>: movl %esp,%ebp 0x8000493 <main+3>: subl $0x4,%esp 0x8000496 <main+6>: movl $0x0,0xfffffffc(%ebp) 0x800049d <main+13>: pushl $0x3 0x800049f <main+15>: pushl $0x2 0x80004a1 <main+17>: pushl $0x1 0x80004a3 <main+19>: call 0x8000470 <function> 0x80004a8 <main+24>: addl $0xc,%esp 0x80004ab <main+27>: movl $0x1,0xfffffffc(%ebp) 0x80004b2 <main+34>: movl 0xfffffffc(%ebp),%eax 0x80004b5 <main+37>: pushl %eax 0x80004b6 <main+38>: pushl $0x80004f8 0x80004bb <main+43>: call 0x8000378 <printf> 0x80004c0 <main+48>: addl $0x8,%esp 0x80004c3 <main+51>: movl %ebp,%esp 0x80004c5 <main+53>: popl %ebp 0x80004c6 <main+54>: ret 0x80004c7 <main+55>: nop As you can see, there are differences between the two. I'm confuse and I can't understand totally the assembly code from my computer. I would like to know the differences between the two. How is pushl different from push, mov vs movl , and so on... what does the expression 0xhexavalue(%register) means? I am sorry If I'm asking a lot, But I badly need your help. Thanks for the help really...

    Read the article

  • C89, Mixing Variable Declarations and Code

    - by rutski
    I'm very curious to know why exactly C89 compilers will dump on you when you try to mix variable declarations and code, like this for example: rutski@imac:~$ cat test.c #include <stdio.h> int main(void) { printf("Hello World!\n"); int x = 7; printf("%d!\n", x); return 0; } rutski@imac:~$ gcc -std=c89 -pedantic test.c test.c: In function ‘main’: test.c:7: warning: ISO C90 forbids mixed declarations and code rutski@imac:~$ Yes, you can avoid this sort of thing by staying away from -pedantic. But then your code is no longer standards compliant. And as anybody capable of answering this post probably already knows, this is not just a theoretical concern. Platforms like Microsoft's C compiler enforce this quick in the standard under any and all circumstances. Given how ancient C is, I would imagine that this feature is due to some historical issue dating back to the extraordinary hardware limitations of the 70's, but I don't know the details. Or am I totally wrong there?

    Read the article

  • Can anyone share a code snippet to Update Google Documents

    - by Sana
    Hi, I am relentlessly trying to update an existing google doc with the Google Protocol Data API, but the contents do not get updated, even though the PUT runs perfectly fine with a return response code of 200. Here is the code that I am using try { HttpRequest requestPost = transport.buildPutRequest(); requestPost.url = DocsUrl.forUploadingFile(editLink); ((GoogleHeaders) requestPost.headers).setSlugFromFileName("books1.xml"); InputStreamContent content = new InputStreamContent(); File file = new File("//sdcard/books.xml"); content.setFileInput(file); content.type = "text/plain"; content.length = file.length(); System.out.println("Length of the file = "+content.length); requestPost.content = content; HttpResponse responseUpload = requestPost.execute(); System.out.println("Uploading code = "+responseUpload.statusCode); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (ClientProtocolException e) { System.out.println("Client Protocol Exception"); } catch (IOException e) { handleException(e); } where editLink is the editLink edit-media link returned from google doc feeds.

    Read the article

  • CSS call from code behind not working

    - by SmartestVEGA
    I have the following entries in the css file. a.intervalLinks { font-size:11px; font-weight:normal; color:#003399; text-decoration:underline; margin:0px 16px 0px 0px; } a.intervalLinks:link { text-decoration:underline; } a.intervalLinks:hover { text-decoration:none; } a.intervalLinks:visited { text-decoration:underline; } a.selectedIntervalLink { font-size:12px; font-weight:bold; color:#003399; text-decoration:none; margin:0px 16px 0px 0px; } a.intervalLinks:active { text-decoration:underline; font-size:large ; } Whenever i take the click on some links (not shown) which is embedded in the webpage ..i can see the change in the link a.intervalLinks:active { text-decoration:underline; font-size:large ; (the font of the link will become large) but after clicking the page refreshes ..the changes will go away i want to keep the change for ever in that link ...even there is a page refresh i understood that ..this can achieved only throughg the code behind of asp.net Following code should work:but unfortunately its not ..could anyone help? protected override void OnInit(EventArgs e) { rptDeptList.ItemDataBound += new RepeaterItemEventHandler(rptDeptList_ItemDataBound); } void rptDeptList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem == null) return; LinkButton btn = (LinkButton)e.Item.FindControl("LinkButton1"); btn.Attributes.Add("class", "intervalLinks"); } Current html code for links has been shown below : <ItemTemplate> <div class='dtilsDropListTxt'><div class='rightArrow' ></div> <asp:LinkButton ID="LinkButton1" runat="server" Text=<%#DataBinder.Eval(Container.DataItem, "WORK_AREA")%> CssClass="intervalLinks" OnClick="LinkButton1_Click" ></asp:LinkButton> </div> </ItemTemplate> Could anyone help?

    Read the article

  • Extracting function declarations from a PHP file

    - by byronh
    I'm looking to create an on-site API reference for my framework and application. Basically, say I have a class file model.class.php: class Model extends Object { ... code here ... // Separates results into pages. // Returns Paginator object. final public function paginate($perpage = 10) { ... more code here ... } } and I want to be able to generate a reference that my developers can refer to quickly in order to know which functions are available to be called. They only need to see the comments directly above each function and the declaration line. Something like this (similar to a C++ header file): // Separates results into pages. // Returns Paginator object. final public function paginate($perpage = 10); I've done some research and this answer looked pretty good (using Reflection classes), however, I'm not sure how I can keep the comments in. Any ideas? EDIT: Sorry, but I want to keep the current comment formatting. Myself and the people who are working on the code hate the verbosity associated with PHPDocumentor. Not to mention a comment-rewrite of the entire project would take years, so I want to preserve just the // comments in plaintext.

    Read the article

  • PHP code displayed in browser

    - by Drake
    so, I'm working on a databases project, and i'm trying to code incrementally. the problem is, when i go to test the php in browser, it displays the php code after my use of "-". the html printing is displayed properly, which is AFTER the point where the - is. here is the php: <?php function getGraphicNovel(){ include_once("./connect.php"); $db_connection = new mysqli($SERVER, $USERNAME, $PASSWORD, $DATABASE); if (mysqli_connect_errno()) { echo("Can't connect to MySQL Server. Error code: " . mysqli_connect_error()); return null; } $stmt = $db_connection->stmt_init(); $returnValue = "invalid"; if($stmt.prepare("select series from graphic_novel_main natural join graphic_novel_misc")) { $stmt->execute(); $stmt->bind_result($series); while ($stmt->fetch()) { echo "<tr><td>" . $series . "</td></tr>"; } $stmt->close(); } $db_connection->close(); } getGraphicNovel(); ?> here is a link to the page. hopefully it works for people outside the school's network. http://plato.cs.virginia.edu/~paw5k/cainedb/viewall.html if anyone knows why this is happening, your input would be great!

    Read the article

  • SQL Server stored procedure return code oddity

    - by gbn
    Hello The client that calls this code is restricted and can only deal with return codes from stored procs. So, we modified our usual contract to RETURN -1 on error and default to RETURN 0 if no error If the code hits the inner catch block, then the RETURN code default to -4. Where does this come from, does anyone know...? IF OBJECT_ID('dbo.foo') IS NOT NULL DROP TABLE dbo.foo GO CREATE TABLE dbo.foo ( KeyCol char(12) NOT NULL, ValueCol xml NOT NULL, Comment varchar(1000) NULL, CONSTRAINT PK_foo PRIMARY KEY CLUSTERED (KeyCol) ) GO IF OBJECT_ID('dbo.bar') IS NOT NULL DROP PROCEDURE dbo.bar GO CREATE PROCEDURE dbo.bar @Key char(12), @Value xml, @Comment varchar(1000) AS SET NOCOUNT ON DECLARE @StartTranCount tinyint; BEGIN TRY SELECT @StartTranCount = @@TRANCOUNT; IF @StartTranCount = 0 BEGIN TRAN; BEGIN TRY --SELECT @StartTranCount = 'fish' INSERT dbo.foo (KeyCol, ValueCol, Comment) VALUES (@Key, @Value, @Comment); END TRY BEGIN CATCH IF ERROR_NUMBER() = 2627 --PK violation UPDATE dbo.foo SET ValueCol = @Value, Comment = @Comment WHERE KeyCol = @Key; ELSE RAISERROR ('Tits up', 16, 1); END CATCH IF @StartTranCount = 0 COMMIT TRAN; END TRY BEGIN CATCH IF @StartTranCount = 0 AND XACT_STATE() <> 0 ROLLBACK TRAN; RETURN -1 END CATCH --Without this, we'll send -4 if we hit the UPDATE CATCH block above --RETURN 0 GO --Run with RETURN 0 and fish line commented out DECLARE @rtn int EXEC @rtn = dbo.bar 'abcdefghijkl', '<foobar />', 'testing' SELECT @rtn; SELECT * FROM dbo.foo DECLARE @rtn int EXEC @rtn = dbo.bar 'abcdefghijkl', '<foobar2 />', 'testing2' --updated OK but we get @rtn = -4 SELECT @rtn; SELECT * FROM dbo.foo --uncomment fish line DECLARE @rtn int EXEC @rtn = dbo.bar 'abcdefghijkl', '<foobar />', 'testing' --Hit outer CATCH, @rtn = -1 as expected SELECT @rtn; SELECT * FROM dbo.foo

    Read the article

  • How to see external libraries code when debugging

    - by Sanva
    Hello!! First of all... this is my message #1 in this place, so... please be nice with me ;) I just started recently to study Gnome apps/libraries and I found that debuggers are an excellent way to learn, because seeing the code running helps a lot in understanding the structure of the program. But I have a problem. For example, debugging gnome-panel I found a lot of calls to external functions (basically the GTK+ functions), and although pretending to see all the code of all the functions applications like this call would be crazy, there are a lot that will be very interesting to see in action. The problem is that the debugger hasn't the code of those libraries loaded and it can't show it to me —at most it shows the line number where the execution is. I'm using Nemiver and when it tries to enter in an external function it claims because it can't find a file it supposed to be somewhere. For example, trying to enter in gtk_window_set_default_icon_name it tries to load /build/buildd/gtk+2.0-2.16.1/gtk/gtkwindow.c, and calling XSetIOErrorHandler, ../../src/ErrHndlr.c. So now I think that I'm doing something wrong... Why Nevimer are looking for those source files in those places?? My system does not even have the /build/buildd/ folders... and I don't know if I'm doing something wrong or I need to install somethig or what. Any suggestion? How do you debug this kind of applications? Best regards and thanks a lot for your time —and forgive me if my English is bad.

    Read the article

  • Jquery cycle plugin and image tag from code behind

    - by Geetha
    Hi All, I am using cycle plugin to show images. I am binding the html code for image from code behind. Problem: Images are not getting displayed. If i hard coded the image tag it is working. Code: $(window).load(function() { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", data: "{}", url: "Default.aspx/GetImage", dataType: "json", success: function(data) { alert(data.d); $("#sample").html(data.d); $('#sample').cycle({ fx: 'fade', continuous: true, speed: 7500, timeout: 55000, pause: 1, sync: 1 }); } }); }); Data.d will give: <img src="Images/Frontbanner/s0.jpg" width="664" height="428" border="0" /> <img src="Images/Frontbanner/s111.jpg" width="664" height="428" border="0" /> <img src="Images/Frontbanner/s112.jpg" width="664" height="428" border="0" /> <img src="Images/Frontbanner/s113.jpg" width="664" height="428" border="0" /> <img src="Images/Frontbanner/s114.jpg" width="664" height="428" border="0" /> <img src="Images/Frontbanner/s115.jpg" width="664" height="428" border="0" /> <img src="Images/Frontbanner/s116.jpg" width="664" height="428" border="0" />

    Read the article

< Previous Page | 143 144 145 146 147 148 149 150 151 152 153 154  | Next Page >