Posts

mysql - SQL injection on fixed value? -

i'm aware if you're inserting variable, use mysqli_real_escape_string. but, if i'm inserting fixed value not variable, need use function? for example, syntax below. insert name variable, , value '1' status column. safe avoid sql injection column status? since not variable. "insert customer(name, status) values ('".mysqli_real_escape_string($conn, $name) ."', '1')"; when using mysqli, safest use prepared statements: $stmt=$mysqli->prepare("insert customer(name, status) values (?, '1')"; $stmt->bind_param("s", $name); (see http://php.net/manual/en/mysqli.quickstart.prepared-statements.php more detailed , working code). in can leave static values is, nobody can replace those. can alter table: alter table customer alter column status default '1'; then not have set longer.

javascript - Access a var defined inside a closure from outside (i.e. the scope where the closure was defined) -

for background, playing through untrusted , javascript-based programming game core mechanic editing code modify game world progress forward. have solved levels "intended" way modifying variables given in local scope using documented in-game api. however, wondering if there "unintended" ways modify game state/game definition fishing around. a lot of game has code follows (evaluated in window scope): function foo() { var bar = 1234; } i understand can access foo scope referring window.foo . there way can access bar inside foo though not explicitly exposed? to clarify, above code evaluated me (in window scope, believe, can @ least reference foo ). can not change evaluated. (i suppose redefine foo if wanted, , bypass lot of restrictions, that's tangential current direction of questioning.) rather, goal is, given has been evaluated, modify in place (such setting new value bar ). thanks in advance! the short answer no . it's not ...

How to delete an entire row if it is all 0's in R -

if have data frame so 4 6 6 0 4 5 0 0 6 5 0 4 4 4 but lot bigger, command can write delete row 0's, such row 4 in example. in end this 4 6 6 0 4 5 6 5 0 4 4 4 thanks! something this? df[apply(df[, sapply(df, is.numeric)], 1, function(x) !all(x==0)), ] or df[rowsums(abs(df[, sapply(df, is.numeric)])) != 0, ] example: > df <- data.frame(x=c(1, 2, 0), y=c(0, 1, 0), z=letters[1:3]) > df x y z 1 1 0 2 2 1 b 3 0 0 c > df[rowsums(abs(df[, sapply(df, is.numeric)])) != 0, ] x y z 1 1 0 2 2 1 b

c# - Getting all the items from the listbox winform -

good day! having troubles on getting items, selected or not, listbox. whenever click send button, items ones selected (this current results of code below: http://imgur.com/ja94bjm ). want items textbox not selected ones , not repeating. private void cmd_send_click_1(object sender, eventargs e) { (int = 0; < listbox1.items.count; i++) { try { string pno = textbox4.text.tostring(); string path = textbox5.text.tostring(); string name = textbox6.text.tostring(); string user = textbox7.text.tostring(); output.text += "\n sent data : " + pno + " " + user + " " + name + " " + path; } catch (exception ex) { wait.abort(); output.text += "error..... " + ex.stacktrace; } networkstream ns = tcpclnt.getstream(); string data = ""; data = ...

ajax - json data not set in parent window after clicking a link from child window in java -

i using struts1 in java , database oracle 10g.i want set value in parent window in ajax when clicking link child window.here,json data retrieved not set in field.any solution???please me............ here jsp code------------------- function doclick(v1,v2){ var f = document.importletterofcreditbookingform; var v3=window.opener.document.importletterofcreditbookingform.lclimittypecode.value; var v4=window.opener.document.importletterofcreditbookingform.lcaccounttypecode.value; var v5=window.opener.document.importletterofcreditbookingform.lcbookingnumber.value; window.opener.document.importletterofcreditbookingform.customercode.value = v1; window.opener.document.importletterofcreditbookingform.customername.value = v2; /*f.action="/mybank/enterlcdetailslistofimportletterofcreditbooking.do"; f.submit();*/ $(document).on('click', function (){ $.ajax({ type:'get', url:'/mybank/enterlc...

c# - Using Guid as an optional parameter gives 'parameter requires a value of type 'System.Nullable' -

i had linking model viewmodel in controller - seems work. here code: public actionresult techsearchknowledgebase([optional]guid? createdbyid, [optional]guid? categoryid, [optional]guid? typeid) { var model = db.knowledgebases.asqueryable(); if (createdbyid != guid.empty) { model = model.where(k => k.createdbyid == createdbyid); viewbag.createdby = db.users.where(c => c.userid == createdbyid).first().fullname; } if (categoryid != guid.empty) { model = model.where(k => k.categoryid == categoryid); viewbag.category = db.categories.where(c => c.categoryid == categoryid).first().categoryname; } if (typeid != guid.empty) { model = model.where(k => k.typeid == typeid); viewbag.category = db.roles.where(c => c.roleid == typeid).first().roledescription; ...

angularjs - How to set the `ng-include` path by dynamically? -

i have content 8 blocks in page. when user clicks on each, opening pop-up , showing same content there. have 8 popup contents separately. when each of block clicked making view true . according current view, change pop-up (include) content changed. not working. here pop-up : html: <div class='ng-modal' ng-if="modal.isopen"> <div class='ng-modal-overlay' ng-click='modal.hide()'></div> <div class='ng-modal-dialog' ng-style='dialogstyle'> <div class='ng-modal-dialog-content'> <ng-include ng-if="modal.board1" src="'../views/projectsummary/modals/{{currentview}}.html'"></ng-include> {{currentview}} //it works! </div> </div> </div> in controller setting : $scope.currentview = "board1"; so, html let load : '../views/projectsummary/modals/board1.html' click here...