w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
unable to output string variable from sql result notice
Here: '$msg' outputs $msg literally. Use double quotes: "$msg" will output the contents of the variable $msg. Or you can just directly call $msg with no quotes.

Categories : PHP

in rspec, can you just output the string in the describe blocks and not run the spec
The alternative method xit will do what you want. The various alternatives for treating "pending" examples like this are covered at https://www.relishapp.com/rspec/rspec-core/v/2-3/docs/pending/pending-examples.

Categories : Ruby On Rails

R: Produce machine-readable output for summary / describe
You could run the table function through apply For instance fruit <- c("Apple", "Apple", "Pear") veg <- c("Carrot", "Potato", "Peas") meat <- c("Steak", "Chicken", "Duck") df <- data.frame(fruit, veg, meat) apply(df, 2, table) $fruit Apple Pear 2 1 $veg Carrot Peas Potato 1 1 1 $meat Chicken Duck Steak 1 1 1

Categories : R

Converting datetime series.describe() output from nanoseconds to something legible
You can convert the datetime objects to date objects like so In [26]: s = Series(date_range('1/1/2001', '1/1/2002')) In [27]: def try_convert_date(obj): ...: try: ...: return obj.date() ...: except AttributeError: ...: return obj ...: In [28]: s.describe().map(try_convert_date) Out[28]: count 366 unique 366 first 2001-01-01 last 2002-01-01 top 2001-01-01 freq 1 dtype: object

Categories : Python

jQuery htmlentities output result without enclosing "" and output result in a separate div
This <img src="pathtoimage/img.jpg>" should read as <img src="pathtoimage/img.jpg"> Try that, could be the problem. Double quote was outside the src Change: print json_encode($_SESSION['StoreImageCode'] =htmlentities('<img src="pathtoimage/img.jpg>" />')); to: print json_encode($_SESSION['StoreImageCode'] =htmlentities('<img src="pathtoimage/img.jpg"> />'));

Categories : PHP

Does each assignment of values to an output NetCDF variable result in a rewrite of the entire dataset?
I use NetCDF4-Python for reading/writing NetCDF, and no, the whole file is not written when you write a variable, or chunk of a variable. Here's a full example: http://nbviewer.ipython.org/5764942

Categories : Python

PHP result as variable in text / element field (use php output in 'placeholder' field)
You can provide an id to your input field and then set the attribute placeholder through jquery. var auto_refresh = setInterval( function() {$.get('gox.php', function (data) { $("#inputid").attr('placeholder', data); });}, 10000);

Categories : PHP

Weird result from DBPedia
The DBpedia ontology (dbpedia-owl) data tends to be a bit cleaner than the older infobox data (dbprop), so I thought you might want to use a query that uses the dbpedia-owl properties: SELECT ?airport ?iata ?name WHERE { ?airport a dbpedia-owl:Airport ; dbpedia-owl:iataLocationIdentifier ?iata ; rdfs:label ?name . FILTER langMatches( lang( ?name ), "EN" ) } order by ?airport SPARQL Results The data is somewhat better, but there are still some bizarre results like: http://dbpedia.org/resource/Prince_Albert_(Glass_Field)_Airport "YPA"@en "Prince Albert (Glass Field) Airport"@en http://dbpedia.org/resource/Prince_George_Airport "YXS"@en "Prince Albert (Glass Field) Airport"@en http://dbpedia.org/resource/Prince_Mohammad_Bin_Abdulaziz_Airport "

Categories : Misc

Capture scalar output of a stored procedudure which does not use output parameters and does not return a result
As you can't change the SP, you can use insert...exec declare @returnedID int declare @t table (result int) insert @t (result ) exec spDoSomething select @returnedID = result from @t select @returnedID or if you need to use sp_executesql for some reason declare @returnedID int exec sp_ExecuteSQl N'declare @t table (result int);insert @t (result ) exec spDoSomething; select @returnedID = result from @t', N'@returnedID int output', @returnedID output select @returnedID

Categories : Sql Server

Visual leak detector output analysis: not able to decode what the result on output screen means
The output basically tells you that your program allocated some memory, but it did not free it before terminating. The first output tells you how much and what data is contained in the memory. The call stack tells you where the memory was allocated.

Categories : C++

How to output one result from a duplicated result using regular expressions?
Description Given a space delimited list of values like £1.00 £2.00 £2.00 £1.00 £1.00 you can validate if there are duplicates by using a negative look ahead to find a back referenced value. I also added a $ and sign to the character class to allow for multiple currency types. This will return the last instance of each value which essentially makes the output unique. Regex: (?:s|^)((?:£|$|xC2|xA3)d+.d{1,2})(?=s|$)(?!.*?s1(?=s|$)) Input: £1.00 £2.00 £2.00 £1.00 £1.00 link to example $matches Array: ( [0] => Array ( [0] => £2.00 [1] => £1.00 ) [1] => Array ( [0] => £2.00 [1] => £1.00 ) ) So we can carry this idea a step further to include your test expression &

Categories : Regex

PHP search result output different result if you give one letter only
Your sql query needs to group your conditions properly $query=mysql_query("select * from persons where status like 'found' and (firstname like '%$searchtext%' or lastname like '%$searchtext%') order by date desc LIMIT $start,$per_page "); What you were doing is equivalent to something like this in code: if (status == 'found' && firstname like 'a') { return row; } else if (lastname like 'a') { return row; } If you see this it may be a bit clearer, if the first condition fails (the only one that checks if status == 'found' then it will skip to the next condition (after the OR statement) and only check if lastname matches. You will need to group your select statement condition so it checks it correctly: ...where status like 'found' and (firstname like '%$searchtext%' o

Categories : PHP

Weird conditional statement (same result)
The code returns the same output for both the conditions. This is just a redundancy and moreover, the float(int(x)) doesn't make a point. Because int(x) converts the number to an integer, again converting it to float or double makes no difference but only the type of the variable returned.

Categories : C++

php calculation gives a weird result for 1500000-20%
Format the number explicitly as an integer? round returns a float and so I believe the default formatting is "getting confused" or "hitting an edge case" and reverts to displaying scientific notation. (I can't trigger the problem on ideone - it might be specific to a particular PHP version/environment - but the symptoms fit.) Try sprintf: return sprintf("%d-%d", $minvalue, $maxvalue); (I removed round as the %d forces the arguments to be treated as integers; however, there might be subtle differences in the rounding rules .. I don't know.)

Categories : PHP

where clause produce weird result
Take the extreme case of the limit being 1. That means, the subquery returns any row (there's no order by to make the row deterministic) that has id<1000000, which makes MAX(id) and MAX(d20) return the values from that row only. Hardly representative of the total collection. Raising the limit to 1000 will just make the sample bigger, but will still give an indeterministic result depending on which 1000 rows are sampled (assuming there are more than 1000 rows that match). You may very well get a different result every time you execute the query, so expecting a particular result won't work. If you need a deterministic result, add an ORDER BY to your subquery before limiting the results.

Categories : Mysql

Weird result of adding up two variables
It's because top is a pre-existing object. You're not using the var keyword to declare it, so you're simply assigning the value to the existing object. Change: top=event.pageY-minY; To: var top=event.pageY-minY; http://jsfiddle.net/YtTFb/1/

Categories : Jquery

Rails weird result with find and where
This is due to the use floating point numbers. Floating point numbers involve a binary representation, in which some numbers that can be exactly represented in decimal notation easily are not stored exactly. For example, 0.6 in decimal is (approximately) 0.111111000110011001100110011010 in binary. When converted back to decimal this number is (approximately) 0.6000000238418579. Due to this, when you store 0.6 in a float column, the value returned to you will be (slightly) different. The exact value you receive depends on the specific handling that the value has gone through, which may differ depending on a variety of factors. In order to avoid this, you would be better off using a BigDecimal, and setting the storage type on that column to :decimal.

Categories : Ruby On Rails

PHP : Weird Output with strtotime
Have you setted the date_default_timezone_set BEFORE the script? As suggested on the php documentation: To avoid frustrating confusion I recommend always calling date_default_timezone_set('UTC') before using strtotime(). Because the UNIX Epoch is always in UTC; you will most likely output the wrong time if you do not do this. Cheers If you did it, maybe can you check what does output, in general, another date? E.G.: $listdate = date("Y-m-d",strtotime("now")); Also, does mktime work for you? EDIT after comments: It seems that you're not the only one experiencing such problems with PHP 5.3, in fact, always from the documentation, a user experienced something similar and gave a solution for windows platforms: Most of the scripts here depend on PHP identifying th

Categories : PHP

Weird Output Explanation
You got lucky. You ended up with ptr pointing to the byte following the terminating null for Princess Leia. Not unreasonabley, this is pointing to the next const char that you defined, i.e. %d . This is undefined behaviour (even if it's vaguely predictable), don't rely on it.

Categories : C

Python threading isAlive weird result
When you restart a worker, you need to update workers. Assigning to _worker won't do that: workers will still contain the old thread and you'll keep checking that old thread over and over again.

Categories : Python

PHP Weird output by simple code
Here how your for-loop works: // i = 0; fwrite($fp, $str, 0); // writes nothing // i = 1; fwrite($fp, $str, 1); // writes a // i = 2; fwrite($fp, $str, 2); // writes ab // i = 3; fwrite($fp, $str, 3); // writes abc // total write 'aababc' UPDATE: And to achive your goal: for ($i = 0; $i < 4; $i++) { fwrite($fp, substr($str, $i, 1)); } // will write 'abcd' I cant stop) Or without loop: // will take 3 first symbols from string and write to file fwrite($fp, substr($str, 0, 3)); // will write 3 symbols from string to file fwrite($fp, $str, 3);

Categories : PHP

Why is my date output appearing weird?
MySQL expects dates to be formatted like 1987-12-04, not 12-04-1987. So either change your datepicker to use: dateFormat: 'yy-mm-dd' or change your MySQL code to use STR_TO_DATE() to parse the date in the format you're providing. To get the selected date, don't use your str.split() code, use: userDate = $(this).datepicker('getDate'); Here's how you can display the date in one format, but send it to the server in a different format. Add a hidden input field: <input type="hidden" name="delivery_date" id="hidden_delivery_date"> and change the original delivery_date field to: <input type="text" name="displayed_delivery_date" id="delivery_date"> Then add the following options to your datepicker: altField: "hidden_delivery_date", altFormat: "yy-mm-dd" and leave the da

Categories : Jquery

Rounding off error yields weird subsetting result in R
Did you check what ((length(data) / 2)+1):length(data) actually is? > data <- 1:11 > ((length(data) / 2)+1):length(data) [1] 6.5 7.5 8.5 9.5 10.5

Categories : R

weird redirect behavior - request should result in 404 but sends me to page without .php
It looks like you have mod_negotiation turned on, try turning off Multiviews: Options -Multiviews Can do that in either vhost/server config or in the htaccess file in your document root. More info about content negotiation here: https://httpd.apache.org/docs/current/content-negotiation.html More info in this answer: http://stackoverflow.com/a/16182533/851273

Categories : Htaccess

Weird output to text file using fprintf()
sample looks to be a float or double. You shouldn't compare a floating point variable against a fixed value, as it most likely will never have this value. For floating point variable you should always compare against a delta. Your if clause will probably always be entered. fprintf shouldn't print NUL though. Can you show the exact output (or part of it)?

Categories : C

Weird output for Math.sqrt() in android
When you perform Math.sqrt on a negative number you get NaN (Not a Number), check your maths. Using Math.abs prior to Math.sqrt should get you an number (it makes your input to Math.sqrt positive), probably not the right number though; fin = h1 + (Math.sqrt(Math.abs(sq2))/(2* 0.5 * h3); fin2 = (h1 - (Math.sqrt(Math.abs(sq))))/(2* 0.5 * h3);

Categories : Android

Distance using taxicab geometry: weird output
Syntax mistake, the second for loop has no brackets. This is ok for single line statements, but without brackets, if, for, while, etc, only apply to the first line after it (up to the semicolon). Add brackets to multiline for loops: for (i=0; i<3; i++) { for(j=0; j<3; j++) { matrix[i][j] = abs(i-1) + abs(j-1) + 1; //taxicab algorithm printf("%d ",matrix[i][j]); //prints the matrix } printf(" "); } In your code this was causing the print statements to not be called as often as you thought. (I actually recommend always using brackets on all for loops, and most if statements for this reason)

Categories : C

Bash arrays and pathname expansion: Weird output
You should declare -A (capital A) an associative array in bash. This is the correct syntax: $ declare -A my_array_filename_var=([.phpsh]=10 [.php_history]=20) $ echo "${my_array_filename_var[.phpsh]}" 10 Or $ declare -A my_array_filename_var $ my_array_filename_var=([.phpsh]=10 [.php_history]=20) $ echo "${my_array_filename_var[.phpsh]}" 10

Categories : Arrays

weird output generation of maze using DFS Algorithm in javascript
@Phpdna: Thanks for your effort. I now have made slight changes in the code this.calc_neighbours = function() { var pot = [[ this.center_cell[0] + 1, this.center_cell[1] ], [ this.center_cell[0], this.center_cell[1] + 1 ], [ this.center_cell[0] - 1, this.center_cell[1]], [ this.center_cell[0], this.center_cell[1] - 1 ]]; for(var l=0;l<4;l++) { if (pot[l][0] > -1 && pot[l][0] < maze.height && pot[l][1] > -1 && pot[l][1] < maze.width) { //this.neighbours = new Array(n_top, n_right, n_bottom, n_left); this.neighbours.push(pot[l]); } } // Inline function to reset the indexes function startFromZero(arr) { var newArr = []; var count = 0; for

Categories : Javascript

Weird output as the numbers get bigger in Fibonacci sequence
I'll bet it does have something to do with the range of int. you're probably overflowing An integer normally has 32 bits, and one of those bits is the sign, so if you have a number like 01111111111111111111111111111111 which is a little bit over 2 billion, and you add 2 to it, then you get 10000000000000000000000000000001 which is negative(the first number is the sign, 0 is positive and 1 is negative) If you want to store more numbers, you can use long ints.

Categories : C++

How to do Xpath's result becomes my output result?
transformer.transform takes a javax.xml.transform.Source which can also be a DOMSource. javax.xml.transform.dom.DOMSource has a constructor that takes a node. When you evaluate you xpath expression, ask for a NODE as a return value. ( text is the default ) and call DOMsource on that as your source. In Jython, for example, it would be something like: from javax.xml.transform.stream import StreamSource, StreamResult from javax.xml.transform import * from javax.xml.xpath import * from org.xml.sax import InputSource from javax.xml.xpath.XPathConstants import * from javax.xml.transform.dom import DOMSource xsl=StreamSource('catalog.xsl') # source = StreamSource( 'catalog.xml' ) result = StreamResult( 'output.html' ) xfact=XPathFactory.newInstance() xpath=xfact.newXPath() expr = xpath.com

Categories : Java

opencv flann module: knn-search for hierarchical kmeans tree giving weird result
knnSearch is looking for the k-nearest neighbours in the index (it does not give the cluster-ID!). You build your index using cluster_data, and then you try to match cluster_data against itself. In this situation, it is not surprising that the closest neighbour to each descriptor is itself... EDIT: If you want to get the centers, have a look at this (from the source of the FLANN library): /** * Chooses the initial centers using the algorithm proposed in the KMeans++ paper: * Arthur, David; Vassilvitskii, Sergei - k-means++: The Advantages of Careful Seeding */ template <typename Distance> class KMeansppCenterChooser : public CenterChooser<Distance> { ...

Categories : Opencv

find two words with the same hash code in a large file - weird output
HashSet<String> fileWords = new HashSet<>(); You instantiate just a single set and add all your words into it. You must add logic which will: check whether there is already a set under your current hashcode key; if there is, just add the word to it; if not, create a new set, add the word, and put it into the map. The way you have it now, you are putting the same set under all the map keys.

Categories : Java

Perl: how can I capture output in a variable in the same time showing it in standard output?
something like this might do the trick use strict; my $fh; open $fh, "find /|"; #don't forget to check it opens!! while (<$fh>){ chomp; print "here--$_ "; }

Categories : Perl

Save command output to variable without it printing to standard output
fpings=$( {fping -c 1 -t 1 $ips | sort; } 2>&1 ) should work the {} capture everything and then it redirects both streams (out and err) to just out and saves in the variable

Categories : Linux

Weird issue with verifying variable in PHP
I do believe this is wrong: !ctype_alpha($_GET) $_GET is an array, not a string. ctype_alpha($_GET) will always equal false. You probably want this instead: if(!isset($_GET["a"]) || !ctype_alpha($_GET["a"])) { header("Location: http://pattersoncode.ca/error.php?ec=406"); exit(); } Which should take care of both 406 conditions. In most cases you also want to do an exit() when you do a redirect. If possible it would be better to send an actual http response code rather than redirect: header('HTTP/1.1 406 Not Acceptable', true, 406);

Categories : PHP

Variable returning weird number
This is because ord() returns the ASCII code of the number, and the ascii list contains the codes. See the example - >>> testString = "test" >>> testList = [ord(elem) for elem in testString] # testList = map(ord, testString) is another way. >>> testList [116, 101, 115, 116] And, when you iterate over the list, you get integer values which get printed out. It prints 97 because you must be having an 'a' in your input string, as >>> chr(97) 'a' See what the help function has to say - >>> help(ord) Help on built-in function ord in module __builtin__: ord(...) ord(c) -> integer Return the integer ordinal of a one-character string. If you want to add up all the ASCII codes for the characters in your string, do >>> su

Categories : Python

Perl- Dereferencing an arrayref and assigning the result to a variable results in variable having the value 1
$logline is not an array reference, it is a plain string. However, you are treating it as an array reference, so it looks for an array variable like this: @{'2013-06-07 17:22:32.219 <TID 1B344> [uss_smm.reqserv] 162.34.22.1: "POST /ts/start/500000-b/500000/ts/june7test1/backup/20130607T102446-02-ts&action=setarchiver&timestamp=1370625752.172546&as=new2 HTTP/1.1" 200 - Success.'} which would have failed under use strict (which keeps you from accidentally using symbolic references like this). You should enable use strict; and use warnings; in all your code to catch many simple errors. Even if it had been an array reference, this code: my $temp_line = @{ $logline }; assigns the number of elements in the array to $temp_line; because you are getting 1, you are acciden

Categories : Perl

Storing nodejs fs.readfile's result in a variable and pass to global variable
The problem you have isn't a problem of scope but of order of operations. As readFile is asynchronous, console.log(global_data); occurs before the reading, and before the global_data = data; line is executed. The right way is this : fs.readFile("example.txt", "UTF8", function(err, data) { if (err) { throw err }; global_data = data; console.log(global_data); }); In a simple program (usually not a web server), you might also want to use the synchronous operation readFileSync but it's generally preferable not to stop the execution. Using readFileSync, you would do var global_data = fs.readFileSync("example.txt").toString();

Categories : Javascript

Go weird behaviour - variable not incrementing correctly
You are incrementing Qty in the copy of the box.BoxItems because range will yield the copy of the elements in the slice. See this example. So, in for _, item := range box.BoxItems, item is a copy of of the elements in box.BoxItems. Change your loop to for i := 0; i < len(box.BoxItems); i++ { if box.boxItems[i].Id == boxItem.Id { box.boxItems[i].Qty++ return box.BoxItems[i] } } Playground

Categories : Go



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