Search Results

Search found 33204 results on 1329 pages for 'get the id'.

Page 15/1329 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Rails ActiveRecord friendly code from a Complex Join, Sum, and Group query

    - by Chad M
    PROBLEM Hello, I am having no luck trying to break down this SQL statement into ActiveRecord/Rails friendly code and I'd like to learn how I can avoid a find_by_sql statement in this situation. Scenario I have users that create audits when they perform an action. Each audit is of a specific audit_activity. Each audit_activity is worth a certain number of points, based on score_weight. I need to find the total scores of each user, based on their total accumulated audit_activity score_weights. Eventually I'll need to rank them which means adding a sort to this as well. My Code Here is my sql and simplified versions of the tables in question. Any thoughts? SQL with full column names (for clarity) SELECT users.id, u.email, SUM(audit_activity.score_weight) FROM users JOIN audits ON users.id = audits.user_id JOIN audit_activities ON audit_activities.id = audits.audit_activity_id GROUP BY users.id; Models: User, Audit, AuditActivity User fields: id, email class User < ActiveRecord::Base include Clearance::User has_many :audits end Audit fields: id, user_id, audit_activity_id class Audit < ActiveRecord::Base belongs_to :user belongs_to :audit_activity end AuditActivity fields: id, score_weight class AuditActivity < ActiveRecord::Base has_many :audits end Example Data Here is a set of SQL statements so you can play with similar data I'm working with and see what comes up when the concerned query is run. You should just be able to copy/paste the whole thing into a database query browser. CREATE TABLE users( id INTEGER NOT NULL, email TEXT (25), PRIMARY KEY (id) ); CREATE TABLE audits( id INTEGER NOT NULL, user_id INTEGER, audit_activity_id INTEGER, PRIMARY KEY (id) ); CREATE TABLE audit_activities( id INTEGER NOT NULL, score_weight INTEGER, PRIMARY KEY (id) ); INSERT INTO users(id, email) VALUES(1, "[email protected]"); INSERT INTO users(id, email) VALUES(2, "[email protected]"); INSERT INTO users(id, email) VALUES(3, "[email protected]"); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(1, 1, 1); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(2, 1, 2); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(3, 1, 1); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(4, 1, 3); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(5, 1, 1); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(6, 1, 4); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(7, 2, 4); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(8, 2, 4); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(9, 2, 4); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(10, 3, 3); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(11, 3, 2); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(12, 3, 2); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(13, 3, 2); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(14, 3, 3); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(15, 3, 1); INSERT INTO audits(id, user_id, audit_activity_id) VALUES(16, 3, 1); INSERT INTO audit_activities(id, score_weight) VALUES(1, 1); INSERT INTO audit_activities(id, score_weight) VALUES(2, 2); INSERT INTO audit_activities(id, score_weight) VALUES(3, 7); INSERT INTO audit_activities(id, score_weight) VALUES(4, 11); The Query Again, here is the query. SELECT u.id, u.email, SUM(aa.score_weight) FROM users u JOIN audits a ON u.id = a.user_id JOIN audit_activities aa ON aa.id = a.audit_activity_id GROUP BY u.id; Many Thanks, Chad

    Read the article

  • Different Linux message queues have the same id?

    - by Halo
    I open a mesage queue in a .c file, and upon success it says the message queue id is 3. While that program is still running, in another terminal I start another program (of another .c file), that creates a new message queue with a different mqd_t. But its id also appears as 3. Is this a problem? server file goes like this: void server(char* req_mq) { struct mq_attr attr; mqd_t mqdes; struct request* msgptr; int n; char *bufptr; int buflen; pid_t apid; //attr.mq_maxmsg = 300; //attr.mq_msgsize = 1024; mqdes = mq_open(req_mq, O_RDWR | O_CREAT, 0666, NULL); if (mqdes == -1) { perror("can not create msg queue\n"); exit(1); } printf("server mq created, mq id = %d\n", (int) mqdes); and the client goes like: void client(char* req_mq, int min, int max, char* dir_path_name, char* outfile) { pid_t pid; /* get the process id */ if ((pid = getpid()) < 0) { perror("unable to get client pid"); } mqd_t mqd, dq; char pfx[50] = DQ_PRFX; char suffix[50]; // sprintf(suffix, "%d", pid); strcat(pfx, suffix); dq = mq_open(pfx, O_RDWR | O_CREAT, 0666, NULL); if (dq == -1) { perror("can not open data queue\n"); exit(1); } printf("data queue created, mq id = %d\n", (int) dq); mqd = mq_open(req_mq, O_RDWR); if (mqd == -1) { perror("can not open msg queue\n"); exit(1); } mqdes and dq seem to share the same id 3.

    Read the article

  • PHP Single Sign On (SSO) generating new session id

    - by bigstylee
    I am trying to create a single sign on process. The method I have implemented makes use of storing session data in a database. When a new user comes to the website (www.example2.com) a table of authentication is checked. As this is their first visit to the website, there will be no match. The browser is redicted to the authentication server www.example1.com/authenticate.php?session_id=ABC123 where ABC123 represents the session id created on www.example2.com. THe session id which is then generated on www.example1.com is stored along side the session id using the parameter set in the URL. The user is then redirected back to the www.example2.com and a match of session ids should be found. This WAS working fine in FireFox but when I tried it in Chrome I noticed that the session id being generated when the browser is redirected back to www.example2.com is a new session id. As a result an infinite loop is created. This behaviour has not manifested itself in FireFox aswell. What is causing the new session id to be generated? More importantly, what can I do to stop it? Thanks in advance! EDIT I had a logically error that was causing an infinite loop. This now works fine again in FireFox but the infinite loop is still occuring in Chrome and Internet Explorer.

    Read the article

  • .save puts NULL in id field in Rails

    - by mathee
    Here's the model file: class ProfileTag < ActiveRecord::Base def self.create_or_update(options = {}) id = options.delete(:id) record = find_by_id(id) || new record.id = id record.attributes = options puts "record.profile_id is" puts record.profile_id record.save! record end end This gives me the correct print out in my log. But it also says that there's a call to UPDATE that sets profile_id to NULL. Here's some of the output in the log file: Processing ProfilesController#update (for 127.0.0.1 at 2010-05-28 18:20:54) [PUT] Parameter: {"commit"=>"Save", ...} ?[4;36;1mProfileTag Create (0.0ms)?[0m ?[0;1mINSERT INTO `profile_tags` (`reputation_value`, `updated_at`, `tag_id`, `id`, `profile_id`, `created_at`) VALUES(0, '2010-05-29 01:20:54', 1, NULL, 4, '2010-05-29 01:20:54')?[0m ?[4;35;1mSQL (2.0ms)?[0m ?[0mCOMMIT?[0m ?[4;36;1mSQL (0.0ms)?[0m ?[0;1mBEGIN?[0m ?[4;35;1mSQL (0.0ms)?[0m ?[0mCOMMIT?[0m ?[4;36;1mProfileTag Load (0.0ms)?[0m ?[0;1mSELECT * FROM `profile_tags` WHERE (`profile_tags`.profile_id = 4) ?[0m ?[4;35;1mSQL (1.0ms)?[0m ?[0mBEGIN?[0m ?[4;36;1mProfileTag Update (0.0ms)?[0m ?[0;1mUPDATE `profile_tags` SET profile_id = NULL WHERE (profile_id = 4 AND id IN (35)) ?[0m I'm not sure I understand why the INSERT puts the value into profile_id properly, but then it sets it to NULL on an UPDATE. If you need more specifics, please let me know. I'm thinking that the save functionality does many things other than INSERTs into the database, but I don't know what I need to specify so that it will properly set profile_id.

    Read the article

  • Fetching just the Key/id from a ReferenceProperty in App Engine

    - by ozone
    Hi SO, I could use a little help in AppEngine land... Using the [Python] API I create relationships like this example from the docs: class Author(db.Model): name = db.StringProperty() class Story(db.Model): author = db.ReferenceProperty(Author) story = db.get(story_key) author_name = story.author.name As I understand it, that example will make two datastore queries. One to fetch the Story and then one to deference the Author inorder to access the name. But I want to be able to fetch the id, so do something like: story = db.get(story_key) author_id = story.author.key().id() I want to just get the id from the reference. I do not want to have to deference (therefore query the datastore) the ReferenceProperty value. From reading the documentation it says that the value of a ReferenceProperty is a Key Which leads me to think that I could just call .id() on the reference's value. But it also says: The ReferenceProperty model provides features for Key property values such as automatic dereferencing. I can't find anything that explains when this referencing takes place? Is it safe to call .id() on the ReferenceProperty's value? Can it be assumed that calling .id() will not cause a datastore lookup?

    Read the article

  • How to use ID selector after jQuery html()

    - by user555617
    It's amazing to try to understand why the function alert("hello") is not generated after clicking more than once... There is some method to do this function is executed? Note that doesn't work after update using html() involving id "press" in button. Any idea? See: http://jsbin.com/atuqu3 JavaScript: $(document).ready(function (){ $("#press").click(function() { $("#relation-states").html('<select id="state" name="state"> <option value="Texas">Texas</option> </select><button id="press" type="button" title="" aria-haspopup="true" style="width: 175px;"><span>Select an item</span></button>');; alert("hello"); }); }); HTML: <div id="relation-states"> <select id="state" name="state"> <option value="New York">New York</option> </select> <button id="press" type="button" title="" aria-haspopup="true" style="width: 175px;"><span>Select an item</span></button> </div>

    Read the article

  • Getting the last User ID in Zend Framework

    - by Ryan Murphy
    Using MySQL query browser, I manually made a table called users and input some date in the fields. I set the primary key to id and set it to auto increment. There are 3 rows, the highest id is 3. I then made the following class in the method directory to call upon the data in the table etc. class Application_Model_DbTable_User extends Zend_Db_Table_Abstract { protected $_name = 'user'; public function getLatestUserId() { $id = $this->getAdapter()->lastInsertId(); return $id; } } In the controller I do the following which gets the value generated by the method and lets the view access it: $usersDbModel = new Application_Model_DbTable_User(); $lastUserId = $usersDbModel->getLatestUserId(); $this->view->lastUserId = $lastUserId; In the view I then echo it to display it to the user: echo $this->lastUserId; However, even though my last id in the users table is 3. It displays 0. I have also tried: public function getLatestUserId() { $sql = 'SELECT max(id) FROM user'; $query = $this->query($sql); $result = $query->fetchAll(); return $result; } But this just throws out a server error. What have I done wrong? Am I missing something? Is there another way of doing this?

    Read the article

  • MySQL move data from one table to another, matching ID's

    - by Reveller
    I have (a.o.) two MySQL tables with (a.o.) the following columns: tweets: ------------------------------------- id text from_user_id from_user ------------------------------------- 1 Cool tweet! 13295354 tradeny 2 Tweeeeeeeet 43232544 bolleke 3 Yet another 13295354 tradeny 4 Something.. 53546443 janusz4 users: ------------------------------------- id from_user num_tweets from_user_id ------------------------------------- 1 tradeny 2235 2 bolleke 432 3 janusz4 5354 I now want to normalize the tweets table, replacing tweets.from_user with an integer that matches users.id. Secondly, I want to fill in the corresponding users.from_user_id, Finally, I want to delete tweets.from_user_id so that the end result would look like: tweets: ------------------------ id text from_user ------------------------ 1 Cool tweet! 1 2 Tweeeeeeeet 2 3 Yet another 1 4 Something.. 3 users: ------------------------------------- id from_user num_tweets from_user_id ------------------------------------- 1 tradeny 2235 13295354 2 bolleke 432 43232544 3 janusz4 5354 53546443 My question is whether one could help me form the proper queries for this. I have only come so far: UPDATE tweets SET from_user = (SELECT id FROM users WHERE from_user = tweets.from_user) WHERE... UPDATE users SET from_user_id = (SELECT from_user_id FROM tweets WHERE from_user = tweets.from_user) WHERE... ALTER TABLE tweets DROP from_user_id Any help would be greatly appreciated :-)

    Read the article

  • how can i check ID of a clicked element js

    - by necker
    how can i check if an ID of a clicked element is lets say 'target'. what i am trying to do is actually show and hide comment form on clicking in the text field and hide it when the user clicks out of the form. the problem is that if the user clicks Submit button the form hides and nothing is sent over. so i'll have to check if the submit buttons id matches the clicked element and not hide it in this case. i am using ruby on rails remote_form_for and onblur and onfocus events now. this is my bigger form that i am showing. <div id="bigArea" style="display:none"> <% remote_form_for @horses do |f|%> <%= f.text_area :description, {:onBlur=>"{$(bigArea').hide();$('smallField').show();}"} %> <%= f.submit "Submit"%> <% end %> </div> and this is the smaller form field that hides everytime you click in it. <div id="smallField"> <%= text_field_tag 'sth',"Click to comment, {:onFocus=>"$('bigArea').show();$('smallField').hide();"} %> </div> My question is how can i disallow the form to hide when a user clicks submit button? i suppose i should check which element's id has been clicked. and if it's submit button's ID i should not hide the form. Or maybe there is some other way to do all this? i would greatly appreciate any answers!

    Read the article

  • asp.net mvc getting id of button clicked

    - by mazhar kaunain baig
    <div id="4591" > <input type="text" id="Title1" name="Title1" value="a" /> <input type="submit" name="button" value="Save" /> </div> <div id="4592" > <input type="text" id="Title2" name="Title2" value="a" /> <input type="submit" name="button" value="Save" /> </div> <div id="4593" > <input type="text" id="Title3" name="Title3" value="a" /> <input type="submit" name="button" value="Save" /> </div> This is the copy paste version of the html source generated by the browser which is making it clear that i am generating the dynamic fields on the page. name in the textbox is the field in the database. After pressing the one of the save buttons how would i send the particular textbox name and value to the controller action to be updated.

    Read the article

  • Creating a function to grab data from an Oracle database (array by ID)

    - by Nick
    I'm trying to create a function that will simply allow me to pass an SQL statement into it, and it will generate an array based on a unique ID I pass it: function oracleGetGata($query, $id="id") { global $conn; $sql = OCI_Parse($conn, $query); OCI_Execute($sql); OCI_Fetch_All($sql, $results, null, null, OCI_FETCHSTATEMENT_BY_ROW); return $results; }   For example I'd like this query $array = oracleGetData('select * from table') to return something like: [1] => Array ( [Title] => Title 1 [Description] => Description 1 ) [2] => Array ( [Title] => Title 2 [Description] => Description 2 ) [3] => Array ( [Title] => Title 3 [Description] => Description 3 )   Rather than what it's returning at the moment: [0] => Array ( [ID] => 3 [TITLE] => Title 3 [DESCRIPTION] => Description 3 ) [1] => Array ( [ID] => 1 [TITLE] => Title 1 [DESCRIPTION] => Description 1 ) [2] => Array ( [ID] => 2 [TITLE] => Title 2 [DESCRIPTION] => Description 2 )   I'd really appreciate any help with this, as the function would save me lots of time! Thank you.

    Read the article

  • jQuery - Show id, based on selected items class?

    - by Jon Hadley
    I have a layout roughly as follows: <div id="foo"> <!-- a bunch of content --> </div> <div id="thumbnails"> <div class="thumb-content1"></div> <div class="thumb-content2"></div> <div class="thumb-content3"></div> </div> <div id="content-1"> <!-- some text and pictures, including large-pic1 --> </div> <div id="content-2"> <!-- some text and pictures, including large-pic2 --> </div> <div id="content-3"> <!-- some text and pictures, including large-pic3 --> </div> etc .... On page load I want to show 'foo' and 'thumbnails' and hide the three content divs. As the user clicks each thumbnail, I want to hide foo, and replace it with the matching 'content-x'. I can get my head round jQuery show, hide and replace (although, bonus points if you want to include that in your example!). But how would I extract and construct the appropriate content id, from the thumbnail class, then pass it to the show hide code?

    Read the article

  • Eval ID on radiobutton in Datalist

    - by ravi
    my code gota datalist with radio button and iv made it single selectable onitemdatabound....now im trying to evaluate a hiddenfield on basis of selected radio button my code goes like this aspx code <asp:DataList ID="DataList1" runat="server" RepeatColumns = "4" CssClass="datalist1" RepeatLayout = "Table" OnItemDataBound="SOMENAMEItemBound" CellSpacing="20" onselectedindexchanged="DataList1_SelectedIndexChanged"> <ItemTemplate> <br /> <table cellpadding = "5px" cellspacing = "0" class="dlTable"> <tr> <td align="center"> <a href="<%#Eval("FilePath")%>" target="_blank"><asp:Image ID="Image1" runat="server" CssClass="imu" ImageUrl = '<%# Eval("FilePath")%>' Width = "100px" Height = "100px" style ="cursor:pointer" /> </td> </tr> <tr > <td align="center"> <asp:RadioButton ID="rdb" runat="server" OnCheckedChanged="rdb_click" AutoPostBack="True" /> <asp:HiddenField ID="HiddenField1" runat="server" Value = '<%#Eval("ID")%>' /> </td> </tr> </table> </ItemTemplate> </asp:DataList> code behind protected void SOMENAMEItemBound(object sender, DataListItemEventArgs e) { RadioButton rdb; rdb = (RadioButton)e.Item.FindControl("rdb"); if (rdb != null) rdb.Attributes.Add("onclick", "CheckOnes(this);"); } protected void rdb_click(object sender, EventArgs e) { for (int i = 0; i < DataList1.Items.Count; i++) { RadioButton rdb; rdb = (RadioButton)DataList1.Items[i].FindControl("rdb"); if (rdb != null) { if (rdb.Checked) { HiddenField hf = (HiddenField)DataList1.Items[i].FindControl("HiddenField1"); Response.Write(hf.Value); } } } } the javascript im using... function CheckOnes(spanChk){ var oItem = spanChk.children; var theBox= (spanChk.type=="radio") ? spanChk : spanChk.children.item[0]; xState=theBox.unchecked; elm=theBox.form.elements; for(i=0;i<elm.length;i++) if(elm[i].type=="radio" && elm[i].id!=theBox.id) { elm[i].checked=xState; } } iam getting an error like this Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near 'pload Demonstration|'. is there any other way to do this or can nyone plz help to get rid of this problem

    Read the article

  • Active Directory Time Synchronisation - Time-Service Event ID 50

    - by George
    I have an Active Directory domain with two DCs. The first DC in the forest/domain is Server 2012, the second is 2008 R2. The first DC holds the PDC Emulator role. I sporadically receive a warning from the Time-Service source, event ID 50: The time service detected a time difference of greater than %1 milliseconds for %2 seconds. The time difference might be caused by synchronization with low-accuracy time sources or by suboptimal network conditions. The time service is no longer synchronized and cannot provide the time to other clients or update the system clock. When a valid time stamp is received from a time service provider, the time service will correct itself. Time sync in the domain is configured with the second DC to synchronise using the /syncfromflags:DOMHIER flag. The first DC is configured to sync time using a /syncfromflags:MANUAL /reliable:YES, from a peerlist consisting of a number of UK based stratum 2 servers, such as ntp2d.mcc.ac.uk. I'm confused why I receive this event warning. It implies that my PDC emulator cannot synchronise time with a supposedly reliable external time source, and it quotes a time difference of 5 seconds for 900 seconds. It's worth also mentioning that I used to use a UK pool from ntp.org but I would receive the warning much more often. Since updating to a number of UK based academic time servers, it seems to be more reliable. Can someone with more experience shed some light on this - perhaps it is purely transient? Should I disregard the warning? Is my configuration sound? EDIT: I should add that the DCs are virtual, and installed on two separate VMware ESXi/vSphere physical hosts. I can also confirm that as per MDMarra's comment and best practice, VMware timesync is disabled, since: c:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe timesync status returns Disabled. EDIT 2 Some strange new issue has cropped up. I've noticed a pattern. Originally, the event ID 50 warnings would occur at about 1230pm each day. This is interesting since our veeam backup happens at 12 midday. Since I made the changes discussed here, I now receive an event ID 51 instead of 50. The new warning says that: The time sample received from peer server.ac.uk differs from the local time by -40 seconds (Or approximately 40 seconds). This has happened two days in a row. Now I'm even more confused. Obviously the time never updates until I manually intervene. The issue seems to be related to virtualisation and veeam. Something may be occuring when veeam is backing up the PDCe. Any suggestions? UPDATE & SUMMARY msemack's excellent list of resources below (the accepted answer) provided enough information to correctly configure the time service in the domain. This should be the first port of call for any future people looking to verify their configuration. The final "40 second jump" issue I have resolved (there are no more warnings) through adjusting the VMware time sync settings as noted in the veeam knowledge base article here: http://www.veeam.com/kb1202 In any case, should any future reader use ESXi, veeam or not, the resources here are an excellent source of information on the time sync topic and msemack's answer is particularly invaluable.

    Read the article

  • strange output in ubuntu terminal when running a lex program

    - by Max
    Hi. I'm running a lexical analyzer using lex, and I've got it mostly correct, but my terminal gives strange output once I take out an ECHO statement I was using to help debug the code. With that statement, my output looks like this: max@Max-Ubuntu:~/Desktop/Compiler Project/project2$ ./a.out <../cmmFiles/expression.cmm VOIDID(){ INTID,ID,ID; BOOLID,ID,ID; ID(ID); ID(ID); ID(ID); ID(ID); ID=-ID-NUM+ID/NUM*(-NUM+ID*IDNUM); ID(ID); ID=ID>ID||ID>=ID; IF(ID)ID(NUM);ELSEID(NUM); ID=ID<ID&&ID<=ID; IF(ID==TRUE)ID(NUM);ELSEID(NUM); ID=ID&&!ID||!ID&&ID; IF(ID!=FALSE)ID(NUM);ELSEID(NUM); } While hard to read, that output is correct. Once I take out the ECHO statement, I instead get this: max@Max-Ubuntu:~/Desktop/Compiler Project/project2$ ./a.out <../cmmFiles/expression.cmm }F(ID!=FALSE)ID(NUM);ELSEID(NUM);; It looks like it's only outputting the final line, except with an extraneous } near the beginning, what looks like half an IF token immediately after, and an extraneous ; at the end. Is this some quirk of my terminal, or does removing that ECHO cause my lexer to screw up that badly? I'm hesitant to keep working until I know for sure what's going on here. Thanks for any answers. Here's my lexer: %{ /* definitions of manifest constants -reserved words- BOOL, ELSE, IF, TRUE, WHILE, DO, FALSE, INT, VOID -Punctuation and operators- LPAREN, RPAREN, LBRACK, RBRACK, LBRACE, RBRACE, SEMI, COMMA, PLUS, MINUS, TIMES, DIV, MOD, AND, OR, NOT, IS, ADDR, EQ, NE, LT, GT, LE, GE -Other tokens- NUMBER, ID, PUNCT, OP */ #include <stdio.h> #include <stdlib.h> //#include "y.tab.h" //int line = 1, numAttr; //char *strAttr; %} /* regular definitions */ delim [ \t] ws {delim}+ start "/*" one [^*] two "*" three [^*/] end "/" comment {start}({one}*{two}+{three})*{one}*{two}+{end} letter [A-Za-z] digit [0-9] id ({letter}|_)({letter}|{digit}|_)* number {digit}+ %% {ws} { /*no action and no return */} {comment} { /*no action and no return */} [\n] {ECHO; /*no action */} // <-- this is the ECHO in question. bool { printf("BOOL");} else { printf("ELSE");} if { printf("IF");} true { printf("TRUE");} while { printf("WHILE");} do { printf("DO");} false { printf("FALSE");} int { printf("INT");} void { printf("VOID");} {id} { printf("ID");} {number} { printf("NUM");} "(" { printf("(");} ")" { printf(")");} "[" { printf("[");} "]" { printf("]");} "{" { printf("{");} "}" { printf("}");} ";" { printf(";");} "," { printf(",");} "+" { printf("+");} "-" { printf("-");} "*" { printf("*");} "/" { printf("/");} "%" { printf("%");} "&" { printf("&");} "&&" { printf("&&");} "||" { printf("||");} "!" { printf("!");} "!=" { printf("!=");} "=" { printf("=");} "==" { printf("==");} "<" { printf("<");} "<=" { printf("<=");} ">" { printf(">");} ">=" { printf(">=");} %% int main() { yylex(); printf("\n"); } int yywrap(void) { return 1; } here's the file it's analyzing: /* this program * illustrates evaluation of * arithmetic and boolean * expressions */ void main( ) { int m,n,p; bool a,b,c; scan(m); print(m); scan(n); print(n); p=-m-3+n/2*(-5+m*n%4); print(p); a=m>n || n>=p; if (a) print(1); else print(0); b=m<n && n<=p; if (b==true) print(1); else print(0); c=a && !b || !a && b; if (c!=false) print(1); else print(0); }

    Read the article

  • getting mysql_insert_id() while using ON DUPLICATE KEY UPDATE with PHP

    - by julio
    Hi-- I've found a few answers for this using mySQL alone, but I was hoping someone could show me a way to get the ID of the last inserted or updated row of a mysql DB when using PHP to handle the inserts/updates. Currently I have something like this, where column3 is a unique key, and there's also an id column that's an autoincremented primary key: $query ="INSERT INTO TABLE (column1, column2, column3) VALUES (value1, value2, value3) ON DUPLICATE KEY UPDATE SET column1=value1, column2=value2, column3=value3"; mysql_query($query); $my_id = mysql_insert_id(); $my_id is correct on INSERT, but incorrect when it's updating a row (ON DUPLICATE KEY UPDATE). I have seen several posts with people advising that you use something like INSERT INTO table (a) VALUES (0) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id) to get a valid ID value when the ON DUPLICATE KEY is invoked-- but will this return that valid ID to the PHP "mysql_insert_id()" function? Thanks for any advice.

    Read the article

  • How can i have custom fields on the posts page in wordpress?

    - by Luccas
    First I've created a home.php page to replace index.php and can add some custom fields on this new one and to have in it lastest 3 posts. On home.php page I put: <?php echo get_post_meta($post->ID, 'test', true); ?>"/> but it doesn't works cause it tries get the post id and not the id of the page. If i put 18 (id of the page) directly it works, but i want it dinamicaly: <?php echo get_post_meta(18, 'test', true); ?>"/> And this condition is not satisfied for test: if($post->post_type == 'page'){ echo 'This item is a page and the ID is: '.$post->ID; }

    Read the article

  • ViewFliper in layout

    - by Surabhi Kale
    i am doing one application in android but i have one problem in layout file i am doing by viewFliper here is code <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/Quesiontext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginTop="44dp" android:text="@string/Question" android:textSize="18sp" /> <RadioGroup android:id="@+id/radioGroupOptions" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/Quesiontext" android:layout_marginTop="30dp" > <RadioButton android:id="@+id/optionOne" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:text="@string/option1" /> <RadioButton android:id="@+id/optionTwo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/option2" /> <RadioButton android:id="@+id/optionthree" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/option3" /> <RadioButton android:id="@+id/optionFour" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/option4" /> </RadioGroup> <TextView android:id="@+id/corrertView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@+id/radioGroupOptions" android:layout_marginRight="48dp" android:text="@string/correct" /> <Button android:id="@+id/btnNext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/corrertView" android:layout_below="@+id/corrertView" android:layout_marginTop="42dp" android:text="@string/Next" android:textSize="16sp" /> <Button android:id="@+id/Btnpervious" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/btnNext" android:layout_alignBottom="@+id/btnNext" android:layout_alignParentLeft="true" android:text="@string/Pervious" android:textSize="16sp" /> <RelativeLayout android:id="@id/layout"//error android:layout_width="match_parent" android:layout_height="match_parent"> <ViewFlipper android:id="@+id/ViewFlipper01" android:layout_width="wrap_content" android:layout_height="wrap_content" > </RelativeLayout> </RelativeLayout> i didnt get it that how i put another button into ViewFliper ..its confusion and generating error...

    Read the article

  • SQL Server INSERT ... SELECT Statement won't parse

    - by Jim Barnett
    I am getting the following error message with SQL Server 2005 Msg 120, Level 15, State 1, Procedure usp_AttributeActivitiesForDateRange, Line 18 The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns. I have copy and pasted the select list and insert list into excel and verified there are the same number of items in each list. Both tables an additional primary key field with is not listed in either the insert statement or select list. I am not sure if that is relevant, but suspicious it may be. Here is the source for my stored procedure: CREATE PROCEDURE [dbo].[usp_AttributeActivitiesForDateRange] ( @dtmFrom DATETIME, @dtmTo DATETIME ) AS BEGIN SET NOCOUNT ON; DECLARE @dtmToWithTime DATETIME SET @dtmToWithTime = DATEADD(hh, 23, DATEADD(mi, 59, DATEADD(s, 59, @dtmTo))); -- Get uncontested DC activities INSERT INTO AttributedDoubleClickActivities ([Time], [User-ID], [IP], [Advertiser-ID], [Buy-ID], [Ad-ID], [Ad-Jumpto], [Creative-ID], [Creative-Version], [Creative-Size-ID], [Site-ID], [Page-ID], [Country-ID], [State Province], [Areacode], [OS-ID], [Domain-ID], [Keyword], [Local-User-ID], [Activity-Type], [Activity-Sub-Type], [Quantity], [Revenue], [Transaction-ID], [Other-Data], Ordinal, [Click-Time], [Event-ID]) SELECT [Time], [User-ID], [IP], [Advertiser-ID], [Buy-ID], [Ad-ID], [Ad-Jumpto], [Creative-ID], [Creative-Version], [Creative-Size-ID], [Site-ID], [Page-ID], [Country-ID], [State Province], [Areacode], [OS-ID], [Domain-ID], [Keyword], [Local-User-ID] [Activity-Type], [Activity-Sub-Type], [Quantity], [Revenue], [Transaction-ID], [Other-Data], REPLACE(Ordinal, '?', '') AS Ordinal, [Click-Time], [Event-ID] FROM Activity_Reports WHERE [Time] BETWEEN @dtmFrom AND @dtmTo AND REPLACE(Ordinal, '?', '') IN (SELECT REPLACE(Ordinal, '?', '') FROM Activity_Reports WHERE [Time] BETWEEN @dtmFrom AND @dtmTo EXCEPT SELECT CONVERT(VARCHAR, TripID) FROM VisualSciencesActivities WHERE [Time] BETWEEN @dtmFrom AND @dtmTo); END GO

    Read the article

  • SRMSVC event ID 8197

    - by Godeke
    I have a Windows 2003 R2 machine that is giving an Event ID 8197 about once an hour and ten minutes. The full error is attached below. The machine is primary used to host IIS webpages and SMTP. There is no known scheduled tasks on the machine. I have read a lot of Google Search and Microsoft docs, but none of the suggestions found there have any impact. What I am curious is if there is any way to convert the SRMVOLMC81 and SRMVOLMC57 into mount point data so I could at least know where the error is sourcing from (there are no related errors in the logs, just the 8197 every hour and ten). Event Type: Error Event Source: SRMSVC Event Category: None Event ID: 8197 Date: 2/7/2011 Time: 11:32:21 AM User: N/A Computer: SERVER001 Description: File Server Resource Manager Service error: Unexpected error. Error-specific details: Error: GetVolumeNameForVolumeMountPoint, 0x80070001, Incorrect function. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. Data: 0000: 53 52 4d 56 4f 4c 4d 43 SRMVOLMC 0008: 38 31 00 00 00 00 00 00 81...... 0010: 53 52 4d 56 4f 4c 4d 43 SRMVOLMC 0018: 35 37 00 00 00 00 00 00 57......

    Read the article

  • Adding a transaction ID to ruby-on-rails logs

    - by Blue Warrior NFB
    We have a RoR app (rails version 3.2.15 right now). As it has been getting busier, the log-files it's producing are becoming less and less useful for troubleshooting. When they come in like this, it's not a problem: Started GET "/accounts/28088166/kittens/22894/rendered_png?file_id=5d3eaec77954a489b5ddd75143091767&kitten_store_id=9970569bbacf7b6dbeb4eb9295960d69&size=large" for 172.16.202.30 at 2013-11-12 13:45:00 +0000 Processing by KittenController#rendered_png as HTML Parameters: {"file_id"="5d3eaec77954a489b5ddd75143091767", "kitten_store_id"="9970569bbacf7b6dbeb4eb9295960d69", "size"="large", "kitten_cam_id"="280941", "id"="kjlak357aw479607t"} Rendered text template (0.0ms) Sent data (1.8ms) Completed 200 OK in 1037.4ms (Views: 1.4ms | ActiveRecord: 98.4ms) Short request, quickly assembled, all the relevant log-lines are in one block. However, not all of our code renders in 1037ms. There are a few calls that can exceed several seconds, and during that time several of these quicker ones can come in. When that happens, its very, very hard to identify which log-lines belong to which GET. Sent data (4.1ms) Completed 200 OK in 767.4ms (Views: 3.2ms | ActiveRecord: 72.2ms) Completed 200 OK in 2338.0ms (Views: 0.2ms | ActiveRecord: 0.0ms) Ooookaaaay... which goes to what? Is it possible to add something like a transaction-ID to these log-lines? The log-spam would be interspersed, but at least grep-magic would give me the unified entries that I need.

    Read the article

  • Remote Desktop event ID 20499. No noticeable issues

    - by Marc05
    I get a warning event with ID 20499 for TerminalServices-RemoteConnectionManager.The error is: Remote Desktop Services has taken too long to load the user configuration from server \server.domain.home for user administrator. Yet, I don't see any issues (I'm guessing because that user is on the machine local). Why am I getting this warning? I'm on Windows Server 2012 R2 connecting from a Windows 8.1.

    Read the article

  • SBS 2003 Event ID 3005 (ActiveSync Related)

    - by lance-gallant
    I've recently noticed the following Error in my Server logs. Happens whenever Mobile device user attempts to syncrhonise using OMA. The error is logged on the server, but the user is able to sync, albeit slowly. Event Type: Error Event Source: Server ActiveSync Event Category: None Event ID: 3005 Date: 16/03/2010 Time: 01:22:20 PM User: xxxxxx Computer: xxxxxx Description: Unexpected Exchange mailbox Server error: Server: xxxxxx User: xxxxxx HTTP status code: [409]. Verify that the Exchange mailbox Server is working correctly.

    Read the article

  • VLAN ID 4095 for guest VLAN tagging

    - by user121282
    Just want to know if it's true that if you use the VLAN ID 4095 for guest VLAN tagging, then vMotion will not work correctly as there is nowhere to pass back the reverse arp to? So, the problem we have noticed is when we have vmotioned VM's that are tagged on our trunk network, you cannot ping them from anywhere between 30-300 seconds. The hosts don't know which VLAN the guest is on. Is this right and also the correct behaviour? Thanks

    Read the article

  • ID protect vs Nominet domain privacy

    - by Antony Scott
    I currently use 1and1 as my domain registrar but am considering using another company in order to get a 10 year registration. I've noticed a couple of companys are charging for privacy, but Ive done it myself with my domain via the Nominet website. Is there a difference? The only one I can see is that my name is listed in the WHOIS information, whereas with these ID protect services my name is withheld.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >