w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
The following code is working in eclipse but when i convert into maven project this code giving error
i check your pom.xml and code this problem will comes only the mismatch the version json-lib-0.9 and json-lib-2.4 or other version of library so you remove all library and try the following way and one more things you have to remove from json-lib from apche-tomacat lib also and then you try this following code and used the json-lib 2.4 version. String user1 = "{'Main':[{'h1':[ {'userId':'userId123'} ],'body':[{'data': [{'userId':'one'}]}] }]}"; JSONObject jsonObj = (JSONObject) JSONSerializer.toJSON(user1); JSONArray snefoCareEnvelopeMain = (jsonObj.getJSONArray("Main")); //main object JSONObject Main = snefoCareEnvelopeMain.getJSONObject(0); // this for reading h1 data JSONArray headerarray = (Main.getJSONArray("h1")); JSONObject

Categories : Java

Replace near working array code with hash code in ruby to find mode
This seems to fit your requirements: def mode(array) histogram = array.each_with_object(Hash.new(0)) do |element, histogram| histogram[element] += 1 end most_frequent = histogram.delete_if do |element, frequency| frequency < histogram.values.max end most_frequent.keys.reduce(&:+) / most_frequent.size.to_f end It creates a hash of frequencies histogram, where the keys are the elements of the input array and the values are the frequency of that element in the array. Then, it removes all but the most frequent elements. Finally, it averages the remaining keys.

Categories : Ruby

Error Code: 1289. The 'SHOW PROCEDURE|FUNCTION CODE' feature is disabled; to have it working
It's by design. SHOW PROCEDURE CODE Syntax This statement is a MySQL extension that is available only for servers that have been built with debugging support. It displays a representation of the internal implementation of the named stored procedure. As the error message explicitly says if you want to be able to use this feature you need to build your MySql with --with-debug option.

Categories : Mysql

Bootstrap Popover not working when code hosted locally, but working on jsbin
I had a similar issue a long time ago. Here's how i solved it: i changed the order of my imported .css and .js files. Try to load first bootstrap's required files and then everything else. Hopefully it will work for you too! if not then there's something wrong with your code.

Categories : Javascript

My code is working in c++ exclusively but the same code will not work from within Node.js
It's a wild guess since no code has been provided but is it possible that v8 code is being executed in another thread (different from the main)? For example, some callback invoked on successful connection that makes calls to node/v8 functions (I assume those external libraries you mention start their own threads to do their work). If that's the case, the problem is that node/v8 code can only be invoked from the main thread. Those SO threads might be useful: Calling callback from node.js native code Callback from different thread in NodeJS Native extension As for debugging, except from examining a core, you could also run your code with gdb so you can set breakpoints at some interesting places. $ gdb node (gdb) run test_connection.js or (gdb) start test_connection.js (gdb)

Categories : Javascript

PHP-MySQLi Prepared Statement not working in code but working is PHPMyAdmin
A prepared statement would look like this SELECT `id` FROM `registgrations` WHERE `email` = :email AND `license_type` = :license_type Checkout the PDO manual docs to learn how to use it. http://php.net/manual/en/class.pdostatement.php

Categories : PHP

Jquery code not working on mobile device but working in browser
Since you're using jQuery Mobile, try using vclick rather than click. http://api.jquerymobile.com/vclick vclick will work with both touch events and mouse click events, whereas click only deals with actual click events - which can be finicky on a mobile device (and sometimes not fire at all when tapping on things). UPDATE: some questions/feedback: why do you have a click event on a form? $('#choosefriendsform').click(function() { That doesn't look right to me... Click events should be on buttons, or clickable elements. This could be the source of your issue. If you're trying to do event delegation on the form, then you need to use 'on' or 'delegate' I.e. this should target just the list items of peoples names: $('#choosefriendsform').on('vclick', '.ui-listview .ui-li', function

Categories : Jquery

using jQuery $(this).addClass not working, simple code not working
You didn't ever close your <a>, but it's working for me otherwise. http://jsfiddle.net/L3nyE/ <ul> <li><a href="#">List Item 1</a></li> <li><a href="#">List Item 2</a></li> <li><a href="#">List Item 3</a></li> <li><a href="#">List Item 4</a></li> </ul> CSS: .on { background-color:red; } jQuery: $('a').click(function(){ //alert('on'); WORKING $(this).addClass('on'); });

Categories : Javascript

Code not working when running normally, but working in debug (eclipse)
I had the same Problem, but with some more specification. The code was working fine in 32bit but I had this issue in 64bit (I am using native library so I need to maintain both). The solution I found is to add Thread.sleep() in the while loop. I don't know why it works, so your guess is as good as mine. A better solution would probably to implement an Observer Pattern instead of having an infinite loop. But that would require some re-factoring.

Categories : Java

How to change code from working with .hover() to working with .click() and .hover()
SOLVED: http://jsfiddle.net/4cPQG/ $j(".swatch-anchor") .on('mousedown mouseover', function () { //... }) .on('mouseup mouseout', function () { //... });

Categories : Javascript

Can't get my JS code working
The problem lies within the browsers' default behavior when clicking on a <button> inside of a <form>. By default, this causes the form to be submitted, which results in a page reload. Thus, execution of your JavaScript code is halted and the XMLHttpRequest is never completed (or, maybe, even started). You can prevent the browser from reloading the page by calling the preventDefault() method of the event object: search: function(event) { event.preventDefault(); // everything else stays the same … With this change, the rest of your code runs through, and you'll be confronted with the JSON syntax error(s) pointed out in the comments. Happy debugging! :)

Categories : Javascript

php IF is not working in my code
Remove the ; at the end of the if, before the { if($_GET["wdl"] == "D"); { should be if($_GET["wdl"] == "D") { and so on.. ; is an instruction separator. Read more here This is a common area of mistake, so to avoid this, you could do if($_GET["wdl"] == "D") { ... That way you can avoid the accidental ; after the looping constructs So the code block looks like this: <?php echo ("Setting up colors..."); if($_GET["wdl"] == "D") { copy ("templates/colors/dr.txt", "tips/$today/color.txt"); copy ("templates/text/dr.txt", "tips/$today/wdl.txt"); } if($_GET["wdl"] == "L") { copy ("templates/colors/lose.txt", "tips/$today/color.txt"); copy ("templates/text/lose.txt", "tips/$today/wdl.txt"); } if($_GET["wdl"] == "W") {

Categories : PHP

EF Code First working with many-to-many relationships
You have to tell the DbContext about how the many-to-many relationship is set up, by overriding OnModelCreating in DocumentAssignment. Replace AssessorDocuments in this code with your relation table name. protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Assessor>() .HasMany(a => a.Documents) .WithMany(d => d.Assessors) .Map(m => { m.MapLeftKey("AssessorID"); m.MapRightKey("DocumentID"); m.ToTable("AssessorDocuments"); }); base.OnModelCreating(modelBuilder); } To assign a Document to an Assessor (assuming a Document exists with DocumentID of 1 and an Assessor exists with an Asse

Categories : C#

How this Knockout code is working
ko.observable is how knockout keeps track of changing variables. If you want knockout to be able to respond to a change, you must use ko.observable. So, if you do this: var myVM = { someProp = true } And then somewhere else in your code you do this: myVM.someProp = false; Knockout won't see the change. However, if you do this: var myVM = { someProp = ko.observable(true); } Then you can change it's value later with: myVM.someProp(false); and Knockout will notice the change and update any bound html automatically. Note: Since ko.obsevable is a function rather than an actual property (thank IE for not supporting Javascript getters and setters), accessing the value is a little different: var whatsMyValue = myVM.someProp(); You have to actually call the method and it wi

Categories : Knockout Js

Why isn't my pagination code working?
looking at the comments, instead of if (!(isset($pagenum))) { $pagenum = 1; } you need this: if (!(isset($_GET['pagenum']))) { $pagenum = 1; } else { $pagenum = $_GET['pagenum']; } // or with a ternary line $pagenum = (isset($_GET['pagenum'])) ? $_GET['pagenum'] : 1; also this part of your code is doing an expensive database call: $data = mysql_query("SELECT * FROM shop WHERE MATCH (name,description,keywords) AGAINST ('$search' IN BOOLEAN MODE)") or die(mysql_error()); $rows = mysql_num_rows($data); do a count instead of fetching the entire table: $data = mysql_query("SELECT COUNT(*) FROM shop WHERE MATCH (name,description,keywords) AGAINST ('$search' IN BOOLEAN MODE)") or die(mysql_error()); $result = mysql_fetch_array($data, MYSQL_NUM); $rows = $result[0];

Categories : PHP

WPF Code-behind DataBinding Not Working
You have only set the Source of the Binding, but not its Path. The declaration should look like this, using the mainWindowViewModel instance as Source: Binding frameBinding = new Binding(); frameBinding.Path = new PropertyPath("PageName"); // here frameBinding.Source = mainWindowViewModel; // and here frameBinding.Converter = this; frameBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; frameBinding.IsAsync = true; frame.SetBinding(Frame.ContentProperty, frameBinding); or shorter: Binding frameBinding = new Binding { Path = new PropertyPath("PageName"), Source = mainWindowViewModel, Converter = this, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, IsAsync = true }; frame.SetBinding(Frame.ContentProperty, frameBinding);

Categories : C#

C code not working properly
Use %d for integers (for confirm) Confirm is declared as an array, but you just want a plain integer. Remove the [100] after confirm in the declaration. It should just be; int confirm; The warning you got was because confirm was an array and it tried to compare the array's base address(confirm) to an integer value (1). Whenever you declare an array, the base address of that array is available in the array name.(Eg. confirm here) Replace the scanf line which takes confirm with scanf("%d",&confirm); it should work fine then

Categories : C

Collision code isn't working?
Your code is out of context and it's hard to know exactly what you are trying to do. If you are using a grid, I would say that you should check the spaces adjacent to the object you are detecting collisions for. If you post more code, perhaps I can help more. var size = 5;//whatever you want var x = new Array(size); for (var i = 0; i < 10; i++) { x[i] = new Array(size); }

Categories : Javascript

Code First EF5: One-to-Zero-or-One relationship is not working
Your mapping with Fluent API is OK, but remove the UserProfile.JoggerId and the Jogger.UserId properties from your model and it should work. The reason is that Entity Framework uses the primary key of Jogger as the foreign key to UserProfile, so you don't need to (and can't) have a separate foreign key property. This kind of one-to-one relationship is called "Shared Primary Key Association". Edit Keep in mind that the primary key of Jogger (as the dependent of the relationship) is not autogenerated in the database, only the primary key of UserProfile is autogenerated (as the principal of the relationship). The way how you would insert a UserProfile or a Jogger or both into the database is the following: If you want to insert a UserProfile without a Jogger just add it to the context:

Categories : C#

Metro UI code not working
You need jQuery to be first , because metrojs uses jQuery,reorder js files like this : <script src="jquery-2.0.3.min.js" type="text/javascript"> </script> <script src="metrojs.js" type="text/javascript"> </script> <script src="metrojs.min.js" type="text/javascript"> </script> Also , i don't think you need both metrojs.js and metrojs.min.js ,only one of them,and i suggest to put jQuery in the head of your page.

Categories : Javascript

gdb-python: why below code is not working under gdb?
gdb is probably linked against a different version of Python than whatever it is you are expecting. You can check this using the usual Python methods, or with "ldd gdb". Python lets you import "with" from "future" -- search for this.

Categories : Python

How is this sorting code working?
It works like this - the key=lambda x: next(it) part is stating: assign an order value of 3, then 1 then 2 to each of the elements in mylist. So two comes first, then one then zero: ["zero", "two", "one"] # original list [ 3, 1, 2 ] # assign this order to each element Now, after sorting: [ 1, 2, 3 ] # sorted keys ["two", "one", "zero"] # and there you go!

Categories : Python

Why is this code not working as expected?
When the SIGINT is sent to your process, it is delivered to the only thread that has it unblocked, your Ctrl_C_handler thread. Signal delivery means taking whatever action is associated with the signal, and the default action for SIGINT is, as you know, process termination. But why doesn't sigwait() calmly intercept the signal, as you intend? sigwait() is designed to remove a signal from a mask of pending signals — that is, generated signals whose delivery is suspended (SIG_BLOCKed) — without the usual asynchronous drama of signal delivery. So, don't SIG_UNBLOCK SIGINT in your thread. Instead, keep it blocked and the code will work as you intend. If you scrutinize the reference you provided, you'll see that that sample code blocks all signals before calling sigwait().

Categories : C

code for Generating PDF is not working?
Ok, first of all download the latest version of the HTMLDoc Software from this link. now extract the files and install the software on your Computer. it will ask "libeay32.dll file is missing. add this file from the folder you have in solution explorer. Now go to the folder which is being created by it after installation. copy all the files and folders and pasted it the folder you have in your project. Now change your code as below: if (!System.IO.Directory.Exists(Request.PhysicalApplicationPath + "pdf")) { System.IO.Directory.CreateDirectory(Request.PhysicalApplicationPath + "pdf"); } string response; url = "http://google.com"; pdfFile = Request.PhysicalApplicatio

Categories : C#

new line in xsl but the code is not working
If you output HTML with your XSLT and want a line break then use a br element e.g. <br/>, see http://www.w3.org/TR/html4/struct/text.html#h-9.3.2.1. The character &#10; is simply treated as white space and does not result in line break unless used inside a pre element or other element with the CSS defining white-space: pre.

Categories : Xslt

While{ while{code}} not working wright
you can't use the pointer from mysql_fetch_assoc($runaug) to run nested loops. because once the child loop finish iterating the parent loop will have gone past the end of the result as well. If you really just want to run two loops use mysql_data_seek($rs,$offset); you will have to keep a reference to the offset of the parent loop when you enter the child loop and then reset the pointer accordingly.

Categories : PHP

Why is this code working without an Exception
You can check the msdn docs, or use reflector/dotPeek to see that Nullable<T> overrides ToString() to return "" if null, instead of throwing. DateTime? is just Nullable<DateTime>, which is why you're getting an empty string and no exception. Edit: The method is probably "ending" when .Substring(0, 10) executes because you're going to get an ArgumentOutOfRangeException. The empty string has length 0, so you cannot ask for a substring of length 10.

Categories : C#

Code on php not working on javascript
Assuming that what you mean is that you want an alert to pop up from the browser when the server reaches a certain point in your php code, the answer is "no", you can't While the server is running your php code, there's no contact with the browser (until the response starts coming back). There are situations in which a server may be streaming content back to the browser, and in such a case it'd be possible to have some agreed-upon convention for the server to mark the content stream with messages to be alerted out immediately, but I don't think that's what you're asking about here.

Categories : PHP

Why is the GUI not working, is the code correct?
panelFirst and panelSecond variable is null it is not declared. before setting background of panel you need to create it: panelFirst= new JPanel(); same thing with panelSecond: panelSecond = new JPanel(); When you have a null pointer exception (also known as NPE): you should try to find an uninitialized variable. When a variable is declared but not initialized its pointer is pointing to null (i.e it is a null pointer!)

Categories : Java

My PHP code is not working properly
When you have specified case ("A" || "a"): $pole[$i] = 10; it evaluates to true. So all your chars matched against true returns true. for 'case' conditions avoid using expressions. Use the static values your comparing such as case "A": case "a": $pole[$i] = 10; break;

Categories : PHP

Cleaning up code but not working
First off standard Java style is Class names are capatilizaed unlike method names. I.E public class GradeSorter; I don't know if you're using the try catch how you want to use it. Right when you try to find the file "grades.dat", if it generates an exception it them creates and intNode object. If there is no exception your program ends. EDIT: You also create an intNode object using "new intNode();", now this will call the no-arg constructor of your intNode class which is non-existant, so as of now it calls the default one. to make this public class intNode { public intNode() {whatever you want when object is created} }

Categories : Java

PHP / Ajax code not working
This line in your AJAX success function is incorrect ($('#data').text(data);): Try instead: success: function(data) { $('#data').html(data); } Another thing to try is to add this to the top of your function.php file (just for one test): <?php echo 'Received OK from PHP'; die();

Categories : PHP

CyclicBarrier code not working?
I've not run your code but there may be a race condition, here is a scenario that reveals it: you start the first thread, it runs during a certain amount of time sufficient for it to finish the processRow method call so it sets done to true and then waits on the barrier, the other threads start but they see that all is "done" so they don't enter the loop and they'll never wait on the barrier, and end directly the barrier will never be activated as only one of the N threads has reached it deadlock Why it is working with the sleep: when one of the thread starts to sleep it lets the other threads work before marking the work as "done" the other threads have enough time to work and can themselves reach the barrier 2 seconds is largely enough for 5 threads to end a processing that should

Categories : Multithreading

Regex C code is not working on my mac osx
Actually, I think There is no errors in my code. The error was on a wrong link to regex.h. Once, I had coded for windows 7 and windows doesn't have /usr/include/regex.h directory (concept) so I installed the pcre package for windows in my current workspace with another regex.h file which was not compatible with my library pcre on my macbook. I cleaned my workspace and everything is back to normal.

Categories : C

Why is clearTimeout not working for this code?
What timers should reset? If the code you posted is in a click handler, then each click produces new timers. The lines: var shuffleTimer = setTimeout(function(){inMotion = false}, 3500); var shuffleStart = setTimeout(oneShuffle, x); create new timers each time, so the first line (clearTimeouts();) makes no sense since the timers don't exist until next two lines. You should put both timers outside the scope of a click handler, so all click invocations would reference same timers. Also all state (inMotin, spins, etc.) should exist outside the function scope, otherwise each click produces new, unrelated variables.

Categories : Javascript

maxlength not working if value is set from js code
one way to get this is ... removing all charaters after 5th character. using substring() <input type="button" id="add" /> JS $('#add').click(function(){ var str=$('#fillingInput').val(); if(str.length > 5) { str = str.substring(0,5); } $('#filledInput').val(str); }); fiddle .. it is recommended not to use inline javascript.

Categories : Javascript

how to get this code working with loadStrings();?
Go to sketch -> Add File to add the text file then use this code to get the string from the text file: PFont font; String string = ""; int fontSize = 10; int specificWidth = 150; int lineSpacing = 2; String lines[]; int textHeight; void setup() { size(600,600); lines[] = loadStrings("text.txt"); font = createFont("Times New Roman", fontSize); textFont(font,fontSize); noLoop(); } void draw() { background(0); string = lines[0]; fill(60); stroke(60); rect(100,100,specificWidth, calculateTextHeight(string, specificWidth, fontSize, lineSpacing)); fill(255); text(string, 100,100,specificWidth,1000); } int calculateTextHeight(String string, int specificWidth, int fontSize, int lineSpacing) { String[] wordsArray; String tempString = ""; int numLines = 0; floa

Categories : String

JavaScript Code isn't working under XP
It can be because 'block' is the default value of display for divs, i.e. if the actual style.display is '', then the div will act as a block. Try inverting your check like this: divid.style.display = (divid.style.display == 'none' ? 'block' : 'none');

Categories : Javascript

captcha code not working
You need session_start() at the very top of your submit.php, that starts or resume your session so that you can access $_SESSION

Categories : PHP

Code not working with Internet Explorer 9
When I run this in IE, the JavaScript works fine, but the form does not submit. If that is the problem you are facing, the cause is: <input name="btnSubmit" type="button" onclick="formatUName(this.form)" value="Submit" /> Change type="button" to type="submit". Browser behavior is unpredictable when you have a type="button" in a form that lacks an explicit submit button.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.