w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Compiler not giving error for alternative name for 'default' case in switch
It's a normal (goto) label. You could do this, for example: int main() { int a=10; switch(a) { case '1': printf("ONE "); break; case '2': printf("TWO "); break; defa1ut: printf("NONE "); } goto defa1ut; return 0; }

Categories : C

MySQL case-insensitive DISTINCT
Try to use upper function SELECT DISTINCT UPPER(email) FROM `jm_order` you can also use lower instead SELECT DISTINCT LOWER(email) FROM `jm_order` More information.

Categories : Mysql

Distinct node js MongoDB case insensitive
That is a brilliant case for a "$downcase" operator in MongoDB's aggregation framework; yet, at this time, it does not exist. The best you can do is store a searchable, downcased version of title for every document. Thus, your schema would look like: { title: "War and Peace", searchable_title: "war and peace" } Your query logic would downcase the values prior to querying for the searchable title. For scale, stay away from case insensitive regexes, and go with downcased titles.

Categories : Node Js

SQL Server 2008 Count(Distinct CASE?
You can't really count half things using count, so that is not the way to go. But, you can do it with arithmetic. I think something like this: select (count(distinct (case when DATENAME(weekday, a.ApptStart) <> 'Friday' then cast(a.apptstart as date) end) ) + 0.5 * count(distinct (case when DATENAME(weekday, a.ApptStart) = 'Friday' then cast(a.apptstart as date) end) ) ) as ScheduleDays If the docs only work on Fridays for half a day, I don't think you need to check for the time of the appointment. Of course, you can if you like by adding it into the second count. Note that to count days, I used the simpler syntax

Categories : SQL

Excel column (distinct) write into CASE statement
Maybe like this .. SELECT CASE "Project"."Current Status" Case Is 'Submitted': '#008000' Case Is 'In Progress': '#F1E87D' Case Is 'Rejected': '#CD0000' Case Is 'Approved': '#0000EB' CaseElse: 'WhatEver .. END SELECT

Categories : Excel

Function giving correct answer in one case, not in any others
function getUserDetailsByName($name, $fields = "*"){ $db = connect_db(); $query = "SELECT {$fields} FROM UserDetails WHERE userName = :username LIMIT 1;"; if(!$result = $db->prepare($query)){ return null; } $result->bindParam(":username", $name); if(!$result->execute()) { sendMessage (1,1,'Query failed',$query); return null; } if(!$user = $result->fetch(PDO::FETCH_NUM)) { return false; } return $user; } Why 2 fetches? Checkout and compare this to your code. Use like this: if($user = getUserDetailsByName($_POST['value'])){ // we have a user! }else{ // we don't have a user! }

Categories : PHP

When i use Activity in camel case it gives error but works fine in upper case spelled
You probably want to be defining an intent for a specific component: Intent startUpIntent = new Intent(Startup.this, MainActivity.class); Then you don't need to bother with an <intent-filter> for MainActivity in your manifest.

Categories : Android

When reloading an RTC component that is out of sync, receive error "case-sensitive names while loading on a case insensitive platform"
Following the thread "Suggestions about RTC naming conventions", I usually do a: delete of the file already loaded in my local worskpace refresh said local workspace and accept what the stream proposes for that file checking/commit the changes reload everything

Categories : Misc

In a switch case statement, it says "duplicate case value" comes up as an error. Anyone know why?
That switch statement does not do what you think. Each case defines one value that the value of computer is matched against. Combining several values with logical disjunction to give the value associated with a single case label does not make the corresponding block be entered when the value of computer is equal to any of those values, but rather when it is equal to the result of their logical OR combination. Not very meaningful, indeed. This is how you could rewrite your switch statement in order to make more sense: switch(computer) { case rock1: // Is it rock1? case rock2: // Or perhaps rock2? case rock3: // Or maybe rock3? c = 1; // Well, if it's one of the above, do this... break; case scissors1: // OK, it wasn't. So is it scissors1? case scisso

Categories : C++

Does 'select distinct' returns the first distinct value or last distinct?
I think there's a misunderstanding here: Your query does not return the records, only the distinct column values. Which, in your example, are 'Sam' and 'Tom'. They have no particular order which can safely be expected. It may be the natural order, or the order in which they are processed on the database (completely depending on the database implementation), or semi-random (such as iterating over items in a set). The order may also vary depending on whether the result was retreived from the data or from the cache. If you want a particular order, then specify it as order criterium: select distinct Name from Emp order by Name asc If you want the distinct values and the first record containing it, use group by: select min(ID), Name from Emp group by Name

Categories : SQL

Why does this code keep giving this error? Syntax error: Bad for loop variable
Your code compiles correctly. This is the proof : http://codepad.org/hryZ2dEm I have also added the return type and the return instruction in the main function to make your code conform to the standard. Try to use the small changes I have inserted. Let me know if you still have a problem.

Categories : C

Error giving confirm button a class Producing error
Maybe this would help, im not sure where you get $confirmMessage Form->postLink( 'Delete', 'action' => 'delete', $location['Location']['id'], 'class' => 'btn btn-small btn-primary', 'confirm' => 'Are you sure?'); ?>

Categories : CSS

SQL Insert rows into table that must have 2 distinct columns but also one non distinct column
You'll have to just replace the PRIZEID value with new ones. Because it sounds like you currently have duplicates on your PROMOTION table First add all the distinct PRIZENAMEs and COSTs to your new PRIZE table: INSERT INTO prize(PRIZEID, COST, PRIZENAME) SELECT DISTINCT (SELECT MAX(PRIZEID)+1 FROM PRIZE), r.COST, r.PRIZENAME FROM PROMOTION r; Then update your PROMOTIONs table with the new PRIZEID UPDATE PROMOTION R SET R.PRIZEID = (SELECT P.PRIZEID FROM PRIZE WHERE P.PRIZENAME=R.PRIZENAME AND P.COST=R.COST); Then, I think from there you can safely delete the columns from your PROMOTIONs table

Categories : SQL

Switch case, case was not found, but similar to the other case, give suggestion
I can point you in the right direction: http://php.net/manual/en/function.levenshtein.php Is a php function that can be used for your cause, there is a nice example on that page as well. A related stack overflow question has more info on when your strings are longer than 255 characters: String similarity in PHP: levenshtein like function for long strings

Categories : PHP

vb.net how to check case of label.text i.e lower case, upper case
isUpper and isLower apply to single characters within a string. I think a better solution is to create a temporary string that is formatted the way you want it and return the comparison. As an example (for ProperCase) If String.Format(yourString, vbStrConv.ProperCase) = yourString then 'your code for proper case End If With this, you should be able to get most of your comparisons going. As for toggle case, you are going to have to write an algorithm that does the string conversion for you. See http://www.codeproject.com/Tips/162540/Letter-Case-Conversion-Algorithms-Title-Case-Toggl for a fairly useful algorithm.

Categories : Vb.Net

MySQL Distinct Query Error
SELECT DISTINCT(isbn) AS isbn, price,qty, date,total FROM reserved_dummy The syntax for the SQL DISTINCT clause is: SELECT DISTINCT columns FROM tables Don't use . (dot) operator when aliasing

Categories : PHP

Distributing k distinct items among r distinct groups without ordering
The solution is Stirling's Number of the Second Kind * r! So that's: 1/r! * (SUMMATION(j=0 --> r), (-1)^(r-j) * C(r,j) * j^k) * r! Which simplifies to: (SUMMATION(j=0 --> r), (-1)^(r-j) * C(r,j) * j^r)

Categories : Misc

Aggregate String[] grabbing first distinct, but I want it to grab the last distinct
Consider using the overload of Select that takes in the index as part of the transformation (documented here). If you want the last distinct element of each distinct element, you might try to use GroupBy order each IGrouping accordingly, and grabbing the correct element of each group. repeat = domain + dir.Split('/') .Select((word, index) => Tuple.Create(word, index)) .Where(x => keep.Contains(x.Item1)) .GroupBy(x => x.Item1) .Select(g => g.OrderByDescending(x => x.Item2).First()) .OrderBy(x => x.Item2) .Select(x => x.Item1) .Aggregate((gi, j) => gi + "/" + j) + repeat.Substring(lastSlash); Here, we couple each word with its index (using the Select overload mentioned above). Then we filter down to the words of interest. Instead of using Distinct, we now use

Categories : C#

MSQL select regardless of distinct or not distinct (count greater than zero)
In the data in the question, there is no repeating id in table A. The query should be returning only one row from A, then. However, your query has an error. The second join should be back to the first table, not the second: SELECT a.col1, b.col1, c.col2 FROM a LEFT JOIN b ON b.id = a.id LEFT JOIN c ON c.id = a.id WHERE a.id = 1 You had c.id = b.id and b.id could be NULL if there is no match in that table. Also, from your description, I wonder if a union would be the best approach: select a.col1, 'a' from a where id = 1 union all select b.col1, 'b' from b where id = 1 union all select c.col2, 'c' from c where id = 1

Categories : Mysql

Php tag giving me error
You can't use HTML inside PHP like this. HTML is not a part of PHP syntax. My index.php page works but when I do view source, I can view the whole exact code of the page, it's not incripted or protected. So I thought well, this is what php is for PHP is not intended, nor can it be used, to hide HTML source code from the browser. The browser needs this code to be able to render the webpage. PHP is a language in which you can program a great deal of things. Popular uses are pulling data from databases and presenting information based on dynamically generated stuff. However, mostly the output in a web application context is still pure (x)HTML code. The browser needs this to display stuff - it's all it understands.

Categories : PHP

Select distinct values of distinct group
You can use the following code to get your desired array with only 1 SQL executed $sql = "SELECT title, group_concat(year) as years FROM table_name group by title" $rs = mysql_query($sql); $arr = array(); while($row = mysql_fetch_assoc($rs)) { $arr[$row['title']] = explode(',',$row['years']); }

Categories : PHP

Why is keyword 's' giving me an error?
Look at your loop condition; it loops under the condition that j < words.length. You are trying to access an element at j+1, causing it to throw an IndexArrayOutOfBoundsException. You either need to change j < words.length to j < words.length-1 or use an alternate method for whatever it is you are trying to accomplish.

Categories : Java

managedObjectContext giving an error
It would seem that you have made changes to your data model, and are trying to load old data from the persistent store. You can delete your app from the device/simulator and try to reload it. That should fix the problem. You should look up Core Data persistent store migration since you won't be able to delete all your data in a production app. Here is a quick overview of Core Data migration: http://i.ndigo.com.br/2012/04/ios-core-data-migration/

Categories : IOS

Javascript giving NaN error
<script type="text/javascript"> function minus() { var t = parseInt(document.getElementById("totalcost").value, 10), u = parseInt(document.getElementById("advpay").value, 10), set = (t - u); document.getElementById("textfield").value = set; return true; } </script> This is happening because you are trying to subtract two strings! value returns the string of the input, you need to parse it to a number in order to subtract them. Remember to specify radix of parseInt, otherwise the number could be parsed not as a decimal. See this answer for more detailed informations.

Categories : Javascript

php isn't giving any error in output
Set your php.ini settings to display errors : - error_reporting to E_ALL - display_errors to on (those are developement environment settings of course ; more about error_reporting levels here) You can find your php.ini location using phpinfo() in a PHP script. EDIT In case it isn't that, try to execute a valid script, and tell us if it runs correctly. If it doesn't, it probably means that your php module installation failed somehow. EDIT 2 Restarting Apache will be necessary after editing such parameters.

Categories : PHP

WordPress is giving 500 error
You're missing a semi-colon on this row: $data = array("model"=>"Ford") Also, you might want to enable WP_DEBUG - this way you'll see the actual error and not a standard Error 500 message: http://codex.wordpress.org/WP_DEBUG

Categories : Wordpress

Same queries giving error
My only explanation is that the database is set up to expect the month ahead of the day. The second query can be interpreted as Nov-04, 2013 in this format, but the first query would have an error because there is no month number 20.

Categories : SQL

ReverseGeocodeQuery giving error
GOT THE ANSWER GeoCoordinateWatcher myLocationWatcher; private GeoCoordinate MyCoordinate = null; private async void GetCurrentCoordinate() { Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracy = PositionAccuracy.High; try { Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); _accuracy = currentPosition.Coordinate.Accuracy; MyCoordinate = new GeoCoordinate(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude); if (MyReverseGeocodeQuery == null || !MyReverseGeocodeQuery.IsBusy) { MyReverseGeocodeQuery = new ReverseGeocodeQuery(); MyReverseGeocodeQuery.GeoCo

Categories : Windows Phone 8

Why not giving compilation error?
Because software has bugs? https://issues.scala-lang.org/browse/SI-7475 That would be my guess. The related ticket has received recent attention: https://issues.scala-lang.org/browse/SI-2568

Categories : Scala

setOnTouchListener() is giving me an error
Use this code: button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this, "YOUR TEXT", 5000).show(); } });

Categories : Android

Allegro4/C++ giving error
You are getting the error because you are attempting to integrate allegro into a project that is non-empty. You must create the project as an EMPTY PROJECT type: New... > Project... > Visual C++ > Empty Project --EDIT FOR SECOND ERROR-- You must append END_OF_MAIN() after the closing brace of int main(): int main() { //... } END_OF_MAIN()

Categories : C++

setContentView() giving error
Your layout file R.layout.activity_locate_user_in_map is missing, maybe it is on another project or it is in correct project but somehow it can't be resolved, try to clean the project

Categories : Android

How to fix kmeans error in r : 'more cluster centers than distinct data points'
Fix for this is to use : cells = c(read.csv("c:\data-files\kmeans\cells.csv", header = FALSE)) rnames = c(read.csv("c:\data-files\kmeans\rnames.csv", header = FALSE)) cnames = c(read.csv("c:\data-files\kmeans\cnames.csv", header = FALSE)) instead of cells = c(read.csv("c:\data-files\kmeans\cells.csv", header = TRUE)) rnames = c(read.csv("c:\data-files\kmeans\rnames.csv", header = TRUE)) cnames = c(read.csv("c:\data-files\kmeans\cnames.csv", header = TRUE))

Categories : R

Datetime is giving error while conversion
Note that you have space before the date time, you need to remove that string before parse to DateTime using given format var date = DateTime.ParseExact(DateOfBirth.Trim(), "d/M/yyyy", CultureInfo.InvariantCulture); if you have multiple date time formats then var date = DateTime.ParseExact(DateOfBirth.Trim(), new string[] {"d/M/yyyy","M/d/yyyy"} , CultureInfo.InvariantCulture, DateTimeStyles.None);

Categories : C#

php mail() giving me a "no disk" error
I am guessing you are using XAMPP? If so you will need to modify the php.ini located in your XAMPP installion, look for the following lines: ; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder) ;sendmail_path = ""C:xamppsendmailsendmail.exe" -t" ; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:xamppmailoutput folder sendmail_path = "C:mailtodiskmailtodisk.exe" mail cannot be delivered in PHP even SMTP server is running and PHP mail() returns true This should also help: http://blog.joergboesche.de/xampp-sendmail-php-mailversand-fuer-windows-konfigurieren#xampp_180_sendmail

Categories : PHP

php ternary operator giving an error
It's supported in PHP 5.3 and up. From PHP.net Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.

Categories : PHP

Why is JsFiddle giving not defined error?
Your shiftLeft function isn't defined in the global scope but in the one of the onload event handler. Remove it from the onload function code and change the fiddle wrapping setting to "no wrap - in head". Or, better, bind it using the click function. But you have other bugs in your function. Maybe you want this : <button id="idofthebutton">Left</button> <script> $('#idofthebutton').click(function(){ $('#chars').children().each(function(){ $(this).css({left:$(this).position().left -100}); }); }); </script> Demonstration

Categories : Javascript

svn import command giving error?
Finally, i got the answer on my own. The problem is the files in /var/www/svn/repos/db/transactions and /var/www/svn/repos/db/txn-protorevs don't have access permissions. I gave 777 permissions to these folders, but, i forgot to give permissions to the files inside in those folders. So, Need to check permissions of all the folders and files correctly. Thank you.

Categories : Svn

Why is this giving me an index error in python?
If s is empty string s[-1] causes IndexError: >>> s = "" >>> s[-1] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: string index out of range Instead of s[-1] == "a", you can use s.endswith("a"): >>> s = "" >>> s.endswith('a') False >>> s = "insta" >>> s.endswith('a') True

Categories : Python

PHP form giving internal error
With error messages enabled I see: PHP Parse error: syntax error, unexpected '$aemail' (T_VARIABLE) in file.php on line 33 The typo is here in line 33: $headers = "From: " $aemail . " "; // ^------------------ note the missing point Write: $headers = "From: " . $aemail . " ";

Categories : PHP



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