Search Results

Search found 21001 results on 841 pages for 'spelling check'.

Page 104/841 | < Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >

  • Checking deployed port in ruby on rails application

    - by john chan
    Is there an elegant way to check which port you deployed a ruby on rails application using mongrel? I could not find a directive (i.e. such as #{RAILS_ROOT} which contains the root directory of the application) that I can use to perform a check. I need this to do a check since I am deploying the same application on different ports and I need the app to do different things according to the port that is being accessed. Any help would be appreciated, Thanks

    Read the article

  • How to change image on locale base in magento?

    - by Nil
    I want to change search image in magento. On search in magento the image name is btn_search.gif. Right now it take image from skin/frontend/default/default/images. And the file is /app/design/frontend/default/default/template/catalogsearch/form.mini.phtml where mention this tag as <input id="search-button" type="image" src="<?php echo $this->getSkinUrl('images/btn_search.gif') ?>" alt="<?php echo $this->__('Search') ?>" /> I check the code and i found that we can pass locale as _type in this as <input id="search-button" type="image" src="<?php echo $this->getSkinUrl('images/btn_search.gif', array('_type'=>'local')) ?>" alt="<?php echo $this->__('Search') ?>" /> But when i check the code this will just check in locale directory that this file exist in that locale or not. If this exist then it will take skin image. I want to use that locale image instead of that skin image. So when i click on french store i get the image which is i set in /app/design/frontend/default/default/locale/fr_FR/images/btn_search.gif I check the code for getSkinUrl in /app/code/core/Mage/Core/Model/Design/Package.php. And i found that he check locale for file but it return skin url. Is there any method which return locale url ?

    Read the article

  • vc++ - static member is showing error

    - by prabhakaran
    I am using vc++(2010). I am trying to create a class for server side socket. Here is the header file #include<winsock.h> #include<string> #include<iostream> using namespace std; class AcceptSocket { // static SOCKET s; protected: SOCKET acceptSocket; public: AcceptSocket(){}; void setSocket(SOCKET socket); static void EstablishConnection(int portNo,string&); static void closeConnection(); static void StartAccepting(); virtual void threadDeal(); static DWORD WINAPI MyThreadFunction(LPVOID lpParam); }; SOCKET AcceptSocket::s; and the corresponding source file #include<NetWorking.h> #include<string> void AcceptSocket::setSocket(SOCKET s) { acceptSocket=s; } void AcceptSocket::EstablishConnection(int portno,string &failure) { WSAData w; int error = WSAStartup(0x0202,&w); if(error) failure=failure+"\nWSAStartupFailure"; if(w.wVersion != 0x0202) { WSACleanup(); failure=failure+"\nVersion is different"; } SOCKADDR_IN addr; addr.sin_family=AF_INET; addr.sin_port=htons(portno); addr.sin_addr.s_addr=htonl(INADDR_ANY); AcceptSocket::s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(AcceptSocket::s == INVALID_SOCKET) failure=failure+"\nsocket creating error"; if(bind(AcceptSocket::s,(LPSOCKADDR) &addr,sizeof(addr)) == SOCKET_ERROR) failure=failure+"\nbinding error"; listen(AcceptSocket::s,SOMAXCONN); } void AcceptSocket::closeConnection() { if(AcceptSocket::s) closesocket(AcceptSocket::s); WSACleanup(); } void AcceptSocket::StartAccepting() { sockaddr_in addrNew; int size=sizeof(addrNew); while(1) { SOCKET temp=accept(AcceptSocket::s,(sockaddr *)&addrNew,&size); AcceptSocket * tempAcceptSocket=new AcceptSocket(); tempAcceptSocket->setSocket(temp); DWORD threadId; HANDLE thread=CreateThread(NULL,0,MyThreadFunction,(LPVOID)tempAcceptSocket,0,&threadId); } } DWORD WINAPI AcceptSocket::MyThreadFunction(LPVOID lpParam) { AcceptSocket * acceptsocket=(AcceptSocket *) lpParam; acceptsocket->threadDeal(); return 1; } void AcceptSocket::threadDeal() { "You didn't define threadDeal in the derived class"; } Now the main.cpp is #include<Networking.h> int main() { } When I am compiling The error I got is Error 1 error LNK2005: "private: static unsigned int AcceptSocket::s" (?s@AcceptSocket@@0IA) already defined in NetWorking.obj C:\Documents and Settings\prabhakaran\Desktop\check\check\main.obj check Error 2 error LNK1169: one or more multiply defined symbols found C:\Documents and Settings\prabhakaran\Desktop\check\Debug\check.exe 1 1 check Now anybody please enlighten me about this issue

    Read the article

  • Visual SourceSafe (VSS): "Access to file (filename) denied" error

    - by tk-421
    Hi, can anybody help with the above SourceSafe error? I've spent hours trying to find a fix. I've also Googled the heck out of it but couldn't find a scenario matching mine, because in my case only a few files (not all) are affected. Here's what I found: only a few files in my project generate this error other files in the same directory (for example, App_Code has one of the problem files) work fine I've tried checking out from both the VSS client and Visual Studio another developer can check out the main problem file without any problems This sounds like a permission issue for my user, right? However: I found the location of one of the problem files in VSS's data directory (using VSS's naming format, as in 'fddaaaaa.a') and checked its permissions; everything looks fine and its permissions match those of other files I can check out successfully I can see no differences in the file properties between working and non-working files What else can I check? Has anyone encountered this problem before and found a solution? Thanks. P.S.: SourceGear, svn or git are not options, unfortunately. P.P.S.: Tried unsuccessfully to add tag "sourcesafe." EDIT: Hey Paddy, I tried to click 'add comment' to respond to your comment, but I'm getting a javascript error when loading this page in IE8 ("jquery undefined," etc.) so this isn't working. This is when checking out files, and yes, I've obliterated my local copy more times than I can remember. ;) EDIT 2: Thanks for the responses, guys (again I can't 'add comment' due to jQuery not loading, maybe blocked as discussed in Meta). If the problem was caused by antivirus or a bad disk, would other users still be able to check out the file(s)? That's the case here, which makes me think it's a permission issue specific to my account. However I've looked at the permissions and they match both other users' settings and settings on other files which I can check out.

    Read the article

  • Trie Backtracking in Recursion

    - by Darksky
    I am building a tree for a spell checker with suggestions. Each node contains a key (a letter) and a value (array of letters down that path). So assume the following sub-trie in my big trie: W / \ a e | | k k | | is word--> e e | ... This is just a subpath of a sub-trie. W is a node and a and e are two nodes in its value array etc... At each node, I check if the next letter in the word is a value of the node. I am trying to support mistyped vowels for now. So 'weke' will yield 'wake' as a suggestion. Here's my searchWord function in my trie: def searchWord(self, word, path=""): if len(word) > 0: key = word[0] word = word[1:] if self.values.has_key(key): path = path + key nextNode = self.values[key] return nextNode.searchWord(word, path) else: # check here if key is a vowel. If it is, check for other vowel substitutes else: if self.isWord: return path # this is the word found else: return None Given 'weke', at the end when word is of length zero and path is 'weke', my code will hit the second big else block. weke is not marked as a word and so it will return with None. This will return out of searchWord with None. To avoid this, at each stack unwind or recursion backtrack, I need to check if a letter is a vowel and if it is, do the checking again. I changed the if self.values.has_key(key) loop to the following: if self.values.has_key(key): path = path + key nextNode = self.values[key] ret = nextNode.searchWord(word, path) if ret == None: # check if key == vowel and replace path # return nextNode.searchWord(... return ret What am I doing wrong here? What can I do when backtracking to achieve what I'm trying to do?

    Read the article

  • Simple user control for conditionally rendering nested HTML

    - by Goyuix
    What I would like to do, is be able to pass two attributes to a user control, a ListName and a Permission, like so: <uc:check id="uc" List="Shared Documents" Permission="OpenItems" runat="server"> <!-- have some HTML content here that is rendered if the permission is true --> </uc:check> Then in the actual check user control, have something similar to: <%@ Control language="C#" ClassName="check" %> <% // determine permission magic placeholder if (DoesUserHavePermissions(perm)) { // render nested HTML content } else { // abort rendering as to not show nested HTML content } %> I have read the page on creating a templated control on MSDN, and while that would work - it really seems to be a bit overkill for what I am trying to do. Is there a control that already renders content based on a boolean expression or a simpler template example? http://msdn.microsoft.com/en-us/library/36574bf6.aspx

    Read the article

  • ExecuteNonQuery: Connection property has not been initialized

    - by 20151012
    I get an error in my code: The error point at dbcom.ExecuteNonQuery();. Code(connection) public admin_addemp() { InitializeComponent(); con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\EMPS.accdb;Persist Security Info=True"); con.Open(); ds.Tables.Add(dt); ds.Tables.Add(dt2); } Code (Save button) private void save_btn_Click(object sender, EventArgs e) { OleDbCommand check = new OleDbCommand(); check.Connection = con; check.CommandText = "SELECT COUNT(*) FROM employeeDB WHERE ([EmployeeName]=?)"; check.Parameters.AddWithValue("@EmployeeName", tb_name.Text); if (Convert.ToInt32(check.ExecuteScalar()) == 0) { dbcom2 = new OleDbCommand("SELECT EmployeeID FROM employeeDB WHERE EmployeeID='" + tb_id.Text + "'", con); OleDbParameter param = new OleDbParameter(); param.ParameterName = tb_id.Text; dbcom.Parameters.Add(param); OleDbDataReader read = dbcom2.ExecuteReader(); if (read.HasRows) { MessageBox.Show("The Employee ID '" + tb_id.Text + "' already exist. Please choose another Employee ID."); read.Dispose(); read.Close(); } else { string q = "INSERT INTO employeeDB (EmployeeID, EmployeeName, IC, Address, State, " + " Postcode, DateHired, Phone, ManagerName) VALUES ('" + tb_id.Text + "', " + " '" + tb_name.Text + "', '" + tb_ic.Text + "', '" + tb_add1.Text + "', '" + cb_state.Text + "', " + " '" + tb_postcode.Text + "', '" + dateTimePicker1.Value + "', '" + tb_hp.Text + "', '" + cb_manager.Text + "')"; dbcom = new OleDbCommand(q, con); dbcom.ExecuteNonQuery(); MessageBox.Show("New Employee '" + tb_name.Text + "'- Successfuly Added."); } } else { MessageBox.Show("Employee name '" + tb_name.Text + "' already added into the database"); } ds.Dispose(); } I'm using Microsoft Access 2010 as my database and this is stand alone system. Please help me.

    Read the article

  • checking & unchecking a HTML checkbox inside repeater based on database value

    - by subash
    i have a repeater control with item templates having check boxes,and i need the check boxes inside the repeatercontrol to be checked based on the database value of a column field "enabled" of bool type of either true or false. the code is as below what modification should i make to check and uncheck the check box? <asp:Repeater ID="rptrDashboardIssue" runat="server"> <ItemTemplate> <%issueEnum += 1;%> <div style="margin-left: -20px; position: absolute;" id="divModificationCaseflow"> <input type="checkbox" name="chkModificationCaseflow" id="chkModificationCaseflowIssue<%=issueEnum%>" checked="<%# DataBinder.Eval(Container.DataItem, "enabled")%>" /> </div> </ItemTemplate> </asp:Repeater>

    Read the article

  • multi-threading in MFC

    - by kiddo
    Hello all,in my application there is a small part of function,in which it will read files to get some information,the number of filecount would be utleast 50,So I thought of implementing threading.Say if the user is giving 50 files,I wanted to separate it as 5 *10, 5 thread should be created,so that each thread can handle 10 files which can speed up the process.And also from the below code you can see that some variables are common.I read some articles about threading and I am aware that only one thread should access a variable/contorl at a me(CCriticalStiuation can be used for that).For me as a beginner,I am finding hard to imlplement what I have learned about threading.Somebody please give me some idea with code shown below..thanks in advance file read function:// void CMyClass::GetWorkFilesInfo(CStringArray& dataFilesArray,CString* dataFilesB, int* check,DWORD noOfFiles,LPWSTR path) { CString cFilePath; int cIndex =0; int exceptionInd = 0; wchar_t** filesForWork = new wchar_t*[noOfFiles]; int tempCheck; int localIndex =0; for(int index = 0;index < noOfFiles; index++) { tempCheck = *(check + index); if(tempCheck == NOCHECKBOX) { *(filesForWork+cIndex) = new TCHAR[MAX_PATH]; wcscpy(*(filesForWork+cIndex),*(dataFilesB +index)); cIndex++; } else//CHECKED or UNCHECKED { dataFilesArray.Add(*(dataFilesB+index)); *(check + localIndex) = *(check + index); localIndex++; } } WorkFiles(&cFilePath,dataFilesArray,filesForWork, path, cIndex); dataFilesArray.Add(cFilePath); *(check + localIndex) = CHECKED; }

    Read the article

  • Extending jQuery Form Validation Script for new form fields

    - by user982124
    I have a simple HTML form that originally was a series of Questions (A1 to A5 and B1 to B3) with yes/no radio buttons like this: <tr> <td width="88%" valign="top" class="field_name_left">A1</td> <td width="12%" valign="top" class="field_data"> <input type="radio" name="CriteriaA1" value="Yes">Yes<input type="radio" name="CriteriaA1" value="No">No</td> </tr> The user could only answer either the A series of questions OR either the B series of questions, but not both. Also they must complete all questions in either the A or B series. I now have an additional series of questions - C1 to C6 - and need to extend my validation scripts to ensure the user enters either A, B or C and answers all questions within each series. My original script for just the A and B looks like this: $(function() { $("#editRecord").submit(function(){ // is anything checked? if(!checkEmpty()){ $("#error").html("Please check something before submitting"); //alert("nothing Checked"); return false; } // Only A _OR_ B if(isAorB()){ $("#error").html("Please complete A or B, not both"); //alert("please complete A or B, not both"); return false; }; // all A's or all B's if(allAorBChecked()){ $("#error").html("It appears you have not completed all questions"); //alert("missing data"); return false; }; if(haveNo()){ // we're going on, but sending "type = C" } //alert("all OK"); return true; }); }); function checkEmpty(){ var OK = false; $(":radio").each(function(){ if (this.checked){ OK = true; } }); return OK; } function isAorB(){ var OK = false; var Achecked = false; var Bchecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); // if we have an A checked remember it if(theChar == "A" && this.checked && !Achecked){ Achecked = true; } if(Achecked && theChar == "B" && !Bchecked){ if(this.checked){ Bchecked = true; } } if (Achecked && Bchecked){ OK = true; } }); return OK; } function allAorBChecked(){ var notOK = false; var Achecked = false; $(":radio").each(function(){ // skip through to see if we're doing A's or B's var theChar=this.name.charAt(8); // check the A's if(theChar == "A" && this.checked && !Achecked){ Achecked = true; } }); if(Achecked){ // set the input to A $("#type").val("A"); // check _all_ a's are checked var thisName; var thisChecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); var checked = this.checked; if (theChar == "A"){ if (this.name == thisName && !thisChecked){ // Yes wasn't checked - is No? if(!checked){ notOK = true; } } thisChecked = checked; thisName = this.name; } }); }else{ // set the input to B $("#type").val("B"); // check _all_ b's are checked var thisName; var thisChecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); var checked = this.checked; if (theChar == "B"){ if (this.name == thisName && !thisChecked){ // A wasn't checked - is B? if(!checked){ notOK = true; } } thisChecked = checked; thisName = this.name; } }); } return notOK; } function haveNo(){ var thisName; var notOK = false; $(":radio").each(function(){ var checked = this.checked; if (this.name == thisName){ //Is this checked if(checked){ notOK = true; $("#type").val("C"); } } thisName = this.name; }); return notOK; } This worked well but I'm completely stuck at extending it to include the C series. I now have to check that the user hasn't answered any A and B, A and C and B and C questions. Everything I've tried fails to validate. Here's where I'm at right now with my new script: $(function() { $("#editRecord").submit(function(){ // is anything checked? if(!checkEmpty()){ $("#error").html("Please check something before submitting"); //alert("nothing Checked"); return false; } // Only A or B or C if(isAorBorC()){ $("#error").html("Please complete A or B or C, not both"); //alert("please complete A or B, not both"); return false; }; // all A's or all B's or all C's if(allAorBorCChecked()){ $("#error").html("It appears you have not completed all questions"); //alert("missing data"); return false; }; if(haveNo()){ // we're going on, but sending "type = C" } //alert("all OK"); return true; }); }); function checkEmpty(){ var OK = false; $(":radio").each(function(){ if (this.checked){ OK = true; } }); return OK; } function isAorBorC(){ var OK = false; var Achecked = false; var Bchecked = false; var Cchecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); // if we have an A checked remember it if(theChar == "A" && this.checked && !Achecked){ Achecked = true; } if(theChar == "B" && this.checked && !Achecked){ Bchecked = true; } if(theChar == "C" && this.checked && !Achecked){ Cchecked = true; } if(Achecked && theChar == "B" && !Bchecked){ if(this.checked){ Bchecked = true; } } if(Achecked && theChar == "C" && !Cchecked){ if(this.checked){ Cchecked = true; } } if(Bchecked && theChar == "C" && !Cchecked){ if(this.checked){ Cchecked = true; } } if (Achecked && Bchecked){ OK = true; } if (Achecked && CBchecked){ OK = true; } if (Bchecked && Cchecked){ OK = true; } }); return OK; } function allAorBorCChecked(){ var notOK = false; var Achecked = false; $(":radio").each(function(){ // skip through to see if we're doing A's or B's var theChar=this.name.charAt(8); // check the A's if(theChar == "A" && this.checked && !Achecked){ Achecked = true; } }); if(Achecked){ // set the input to A $("#type").val("A"); // check _all_ a's are checked var thisName; var thisChecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); var checked = this.checked; if (theChar == "A"){ if (this.name == thisName && !thisChecked){ // Yes wasn't checked - is No? if(!checked){ notOK = true; } } thisChecked = checked; thisName = this.name; } }); }elseif{ // set the input to B $("#type").val("B"); // check _all_ b's are checked var thisName; var thisChecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); var checked = this.checked; if (theChar == "B"){ if (this.name == thisName && !thisChecked){ // A wasn't checked - is B? if(!checked){ notOK = true; } } thisChecked = checked; thisName = this.name; } }); } return notOK; } }else{ // set the input to C $("#type").val("C"); // check _all_ c's are checked var thisName; var thisChecked = false; $(":radio").each(function(){ var theChar=this.name.charAt(8); var checked = this.checked; if (theChar == "C"){ if (this.name == thisName && !thisChecked){ // A wasn't checked - is B? if(!checked){ notOK = true; } } thisChecked = checked; thisName = this.name; } }); } return notOK; } function haveNo(){ var thisName; var notOK = false; $(":radio").each(function(){ var checked = this.checked; if (this.name == thisName){ //Is this checked if(checked){ notOK = true; $("#type").val("C"); } } thisName = this.name; }); return notOK; } Anyone see what I'm doing wrong?

    Read the article

  • TFS2010 API - Which server event fires when checkin notes are changed?

    - by user3708981
    I've written a TFS plugin that impliments the ISubscribe interface, and creates an external ticket base off of the contents of a check-in note. What I would like to do, if when I go back through older TFS check-ins in VS and edit a check-in note, the plugin would process that event and create an external ticket retroactively. What event / SubscribedType do I need to subscribe to in order for ProcessEvents to fire? My stubbed out code - using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.Common; using Microsoft.TeamFoundation.VersionControl.Client; // From C:\Program Files\Microsoft Team Foundation Server 2010\Tools\ using Microsoft.TeamFoundation.Framework.Server; using Microsoft.TeamFoundation.VersionControl.Server; using Changeset = Microsoft.TeamFoundation.VersionControl.Server.Changeset; public class EmbeddedWorkItemEventHandler : ISubscriber { const string EVENT_NAME = "TicketEvent"; const string APP_LOG = "Application"; public Type[] SubscribedTypes() { return new Type[1] { typeof(CheckinNotification) }; // What else do I need here? } public string Name { get { return EVENT_NAME; } } public SubscriberPriority Priority { get { return SubscriberPriority.Normal; } } public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties) { // Create the event source, if it doesn't exist if (!System.Diagnostics.EventLog.SourceExists(EVENT_NAME)) { System.Diagnostics.EventLog.CreateEventSource(EVENT_NAME, APP_LOG); } statusCode = 0; properties = null; statusMessage = String.Empty; string ErrorLine = ""; try { // Here we'll validate the Ticket name if (notificationType == NotificationType.DecisionPoint && notificationEventArgs is CheckinNotification) { //Check-in blocking logic here. } else if (notificationType == NotificationType.Notification && notificationEventArgs is CheckinNotification) { // Tickets on check-in here. } } Catch { // Error checking } return EventNotificationStatus.ActionPermitted; }

    Read the article

  • Error in Android's clearCheck() for RadioGroup?

    - by Manuel R. Ciosici
    I'm having an issue with RadioGroup's clearChecked(). I'm displaying a multiple choice question to the user and after the user selects an answer I check the answer, give him some feedback and then move to the next question. In the process of moving to the next question I clearCheck on the RadioGroup. Can anyone explain to me why the onCheckedChanged method is called 3 times? Once when the change actually occurs (with the user changes), once when I clearCheck(with -1 as the selected id) and once in between (with the user changes again)? As far as I could tell the second trigger is provoked by clearCheck. Code below: private void checkAnswer(RadioGroup group, int checkedId){ // this makes sure it doesn't blow up when the check is cleared // also we don't check the answer when there is no answer if (checkedId == -1) return; if (group.getCheckedRadioButtonId() == -1) return; // check if correct answer if (checkedId == validAnswerId){ score++; this.giveFeedBack(feedBackType.GOOD); } else { this.giveFeedBack(feedBackType.BAD); } // allow for user to see feedback and move to next question h.postDelayed(this, 800); } private void changeToQuestion(int questionNumber){ if (questionNumber >= this.questionSet.size()){ // means we are past the question set // we're going to the score activity this.goToScoreActivity(); return; } //clearing the check gr.clearCheck(); // give change the feedback back to question imgFeedback.setImageResource(R.drawable.question_mark); //OTHER CODE HERE } and the run method looks like this public void run() { questionNumber++; changeToQuestion(questionNumber); }

    Read the article

  • Credit Card checksums and validations that do not require connection to the financial institution

    - by cjavapro
    The validations I know of are: Checksum the whole card number should add up to zero. (range is 0-9) Check the first digit(s) against the card type Check the length against the card type Check the CCV length against the card type (I think all the major types are 3 anyway) Of course make sure it is accepted card type as well as non expired. Are there any other validations :) (I expect many folks did not know about all of these) The reason I ask is because I overheard there was one to checksum number against expiration or CCV.. I just wanted to check.

    Read the article

  • How to find with javascript if element exists in DOM or it's virtual (has been just created by creat

    - by user326574
    Hello. I hope a topic is self describing. I'm new on your site, it helped me much times but this time i was surprised not to find an answer on internet. The question is quite simple. Say, i have an element created in code: var elem = docuemnt.createElement('div'); ... I wish sometime to check have i placed it into the DOM before or it is still virtual. // check if elem is placed in the DOM (it's not) document.getElementByTagName('body')[0].appendChild(elem); // check - and it's finally in the document When use jquery i can write '$(elem).filter(':visible') or even $(elem).visible() if i remember correctly. But if it's based on the same javascript, then... All i want is to check does the element exist only virtually or it can be found in a document (and still may be not visible).

    Read the article

  • How can I get all the checked items from a submitted form with sinatra's params?

    - by 102405176597896213397
    I'm running Sinatra 1.0 with HAML, my form has a number of checkboxes, for example books I like, and you would select all the books you want. The checkbox name is "books". In sinatra params['books'] there should be an array of all the books that were checked, but it only has the last item that was checked, not an array. How can I get all the checked items? HAML: %form{:action => "/test", :method => 'post'} %input{:name=>'check',:type=>'checkbox',:value=>'item1'} item 1 %input{:name=>'check',:type=>'checkbox',:value=>'item2'} item 2 %input{:name=>'check',:type=>'checkbox',:value=>'item3'} item 3 %input{:type => "submit", :value => "send", :class => "button"} Sinatra get method post '/test' do puts params['check'] #should be an array but is last item checked end

    Read the article

  • PHP contact form, am I doing it wrong?

    - by decimal
    I'm learning PHP and I'm trying to write a simple email script. I have a function (checkEmpty) to check if all the forms are filled in and if the email adress is valid (isEmailValid). I'm not sure how to return true checkEmpty funciton. Here's my code: When the submit button is clicked: if (isset($_POST['submit'])) { //INSERT FORM VALUES INTO AN ARRAY $field = array ('name' => $_POST['name'], 'email' => $_POST['email'], 'message' => $_POST['message']); //CONVERT ARRAY KEYS TO VARIABLE NAMES extract ($field); checkEmpty($name, $email, $message); function checkEmpty($name, $email, $message) { global $name_error; global $mail_error; global $message_error; //CHECK IF NAME FIELD IS EMPTY if (isset($name) === true && empty($name) === true) { $name_error = "<span class='error_text'>* Please enter your name</span>"; } //CHECK IF EMAIL IS EMPTY if (isset($email) === true && empty($email) === true) { $mail_error = "<span class='error_text'>* Please enter your email address</span>"; //AND IF IT ISN'T EMPTY CHECK IF IT IS A VALID ONE } elseif (!isValidEmail($email)) { $mail_error = "<span class='error_text'> * Please enter a valid email</span>"; } //CHECK IF MESSAGE IS EMPTY if (isset($message) === true && empty($message) === true) { $message_error = "<span class='error_text'>* Please enter your message</span>"; } } // This function tests whether the email address is valid function isValidEmail($email){ $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"; if (eregi($pattern, $email)) { return true; } else { return false; } } I know I shouldn't be using globals in the function, I don't know an alternative. The error messages are display beside each form element.

    Read the article

  • How can i optimize this recursive method

    - by Tirdyr
    Hi there. I'm trying to make a word puzzle game, and for that i'm using a recursive method to find all possible words in the given letters. The letters is in a 4x4 board. Like this: ABCD EFGH HIJK LMNO The recursive method is called inside this loop: for (int y = 0; y < width; y++) { for (int x = 0; x < height; x++) { myScabble.Search(letters, y, x, width, height, "", covered, t); } } letters is a 2D array of chars. y & x is ints that shows where in the board width & height is also int, that tells the dimensions of the board "" is the string we are trying to make (the word) covered is an array of bools, to check if we allready used that square. t is a List (wich contains all the words to check against). The recursive method that need optimizing: public void Search(char[,] letters, int y, int x, int width, int height, string build, bool[,] covered, List<aWord> tt) { // Dont get outside the bounds if (y >= width || y < 0 || x >= height || x < 0) { return; } // Dont deal with allrady covered squares if (covered[x, y]) { return; } // Get Letter char letter = letters[x, y]; // Append string pass = build + letter; // check if its a possibel word //List<aWord> t = myWords.aWord.Where(w => w.word.StartsWith(pass)).ToList(); List<aWord> t = tt.Where(w => w.word.StartsWith(pass)).ToList(); // check if the list is emphty if (t.Count < 10 && t.Count != 0) { //stop point } if (t.Count == 0) { return; } // Check if its a complete word. if (t[0].word == pass) { //check if its allrdy present in the _found dictinary if (!_found.ContainsKey(pass)) { //if not add the word to the dictionary _found.Add(pass, true); } } // Check to see if there is more than 1 more that matches string pass // ie. are there more words to find. if (t.Count > 1) { // make a copy of the covered array bool[,] cov = new bool[height, width]; for (int i = 0; i < width; i++) { for (int a = 0; a < height; a++) { cov[a, i] = covered[a, i]; } } // Set the current square as covered. cov[x, y] = true; // Continue in all 8 directions. Search(letters, y + 1, x, width, height, pass, cov, t); Search(letters, y, x + 1, width, height, pass, cov, t); Search(letters, y + 1, x + 1, width, height, pass, cov, t); Search(letters, y - 1, x, width, height, pass, cov, t); Search(letters, y, x - 1, width, height, pass, cov, t); Search(letters, y - 1, x - 1, width, height, pass, cov, t); Search(letters, y - 1, x + 1, width, height, pass, cov, t); Search(letters, y + 1, x - 1, width, height, pass, cov, t); } } The code works as i expected it to do, however it is very slow.. it takes about 2 mins to find the words. EDIT: i clarified that the letters array is 2D

    Read the article

  • Help regarding multi-threading in MFC,please help me firends!

    - by kiddo
    Hello all,in my application there is a small part of function,in which it will read files to get some information,the number of filecount would be utleast 50,So I thought of implementing threading.Say if the user is giving 50 files,I wanted to separate it as 5 *10, 5 thread should be created,so that each thread can handle 10 files which can speed up the process.And also from the below code you can see that some variables are common.I read some articles about threading and I am aware that only one thread should access a variable/contorl at a me(CCriticalStiuation can be used for that).For me as a beginner,I am finding hard to imlplement what I have learned about threading.Somebody please give me some idea with code shown below..thanks in advance file read function:// void CMyClass::GetWorkFilesInfo(CStringArray& dataFilesArray,CString* dataFilesB, int* check,DWORD noOfFiles,LPWSTR path) { CString cFilePath; int cIndex =0; int exceptionInd = 0; wchar_t** filesForWork = new wchar_t*[noOfFiles]; int tempCheck; int localIndex =0; for(int index = 0;index < noOfFiles; index++) { tempCheck = *(check + index); if(tempCheck == NOCHECKBOX) { *(filesForWork+cIndex) = new TCHAR[MAX_PATH]; wcscpy(*(filesForWork+cIndex),*(dataFilesB +index)); cIndex++; } else//CHECKED or UNCHECKED { dataFilesArray.Add(*(dataFilesB+index)); *(check + localIndex) = *(check + index); localIndex++; } } WorkFiles(&cFilePath,dataFilesArray,filesForWork, path, cIndex); dataFilesArray.Add(cFilePath); *(check + localIndex) = CHECKED; }

    Read the article

  • Rich text box with spell checker

    - by user329755
    Hi, I have a very unique requirement for a rich text box with spell check and auto text. The spell check will not happen on any other site thus i need to have the dictionary and the spell check logic in my site only. It should be open source as i will then add auto text feature to that text box. Any help will be appreciated. Thanks.

    Read the article

  • Looping Gridview when the button is click

    - by Nyan
    Hi all, I have create a girdview in dialog and in the girdview I added a check boxes, so that, the user can check/uncheck the gridview. And there is a button which send back the information about the check values to the server. My problem is I don't know how to loop the gridview. Is there a way to loop the girdview. Or is there other way to achieve? Thanks in advance for any help Nyan

    Read the article

  • Possibility of initiating playback of flash video on headless server through the terminal

    - by brendan morrison
    Hey so I have a website which has video's gathered from places around the web, primarily youtube but a few other's as well. Now I am wondering if there is some way to check link's to make sure they are still available through a unix shell. (My idea is to run a cron to check videos are still available and if not delete them.) I am aware i could use user to do this but it always bothered me and was wondering if there is somehow to check the playback of a flash video though the terminal . Any insight into this would be awesome as I haven't found much on the web. Also note ideally the tech. will work on all video type's including html5. update So it's occured to me that through the you tube api, I could check the status of the video's coming from youtube (which is a start). But I would love to know if there's something else that is not player specific but rather just calls the video to play similar to how a user would.

    Read the article

  • Using PHP to determine if a remote file has been replaced?

    - by Rob
    I have a MySQL database with some URLs in it. One URL per row. Each URL has my script on it. What I am wanting to do, is check if the file is still there via a PHP script. Not check if it 404'd, but rather check if it has been modified or replaced. Is this possible? If so, how would it be accomplished? I was thinking making the remote file echo some string, and having the local file check the page for that string, but that seems a little inefficient and sloppy.

    Read the article

< Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >