Posts

php - Error in SQL syntax when I try a query -

i've big (and stupid) problem simple sql insert query (mysqli), i've used format without errors, didn't work.. please me find problem.. //get admin form details $a_user = $_post["a_user"]; $a_pass = $_post["a_pass"]; $a_pin = $_post["a_pin"]; if($a_user == "$admin_username" && $a_pass == "$admin_password" && $a_pin == "$admin_pin"): $keygen = md5(microtime().rand()); $mysqli->query("insert keys (keygen) values ('$keygen')") or die(mysqli_error($mysqli)); $mysqli->close; else: header("location: ?page=admin&error=1"); endif; here error: error: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'keys (keygen) values ('85faa7f618e433819d7e5ca57076377c')' @ line 1 keys mysql reserved word http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html either wrap in bac...

ios - CBManager state always unknown -

i trying check if bluetooth of device on or off. code i've written far cbcentralmanager *cbmanager = [[cbcentralmanager alloc] initwithdelegate:self queue:nil options: [nsdictionary dictionarywithobject:[nsnumber numberwithint:0] forkey:cbcentralmanageroptionshowpoweralertkey]]; [cbmanager scanforperipheralswithservices:nil options: [nsdictionary dictionarywithobject:[nsnumber numberwithint:0] forkey:cbcentralmanageroptionshowpoweralertkey]]; if (cbmanager.state==cbcentralmanagerstatepoweredoff) { //do stuff } - (void)centralmanagerdidupdatestate:(cbcentralmanager *)central { nsstring *statestring = nil; s...

xcode - How to let the controller handle a gesture added in the view? iOS -

i got card draw custom view. want add swipe gesture every card flip , being chosen. since every card view needs gesture, choose add gesture in method initwithframe: of view. however,i want leave controller handle gesture when recognized because choosing card method in controller. here code: [self addgesturerecognizer:[[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(swipe:)]]; actually need target my controller , want call method named swipe in controller. target self leave handling of gesture view itself. maybe can't controller replace target.can tell correct way solve problem? your view should not know controller is. (this increase coupling , decrease cohesion, bad.) a common solution problem view declare delegate protocol. view controller can set view's delegate. view's swipe: method call delegate method. for example code, see this question .

mysql - sql update statement for two tables -

i using mysql 5.5 , have 2 tables, inventory_items , menu_items. both have bin_number string , location_id integer. menu_items invetory_item_id | location_id | bin_number inventory_items id | location_id | bin_number i'd update menu_items inventory_item_id id of inventory_items table equal on bin_number , location_id. go through each this: update menu_items set inventory_item_id=(select id inventory_items bin_number='7060' , location_id=37) bin_number='7060' , location_id=37; is there way update menu_items bin_number , location_id same between menu_items , inventory_items? thx you can use join in update : update menu_items mi join inventory_items ii on mi.bin_number=ii.bin_number , mi.location_id=ii.location_id set mi.inventory_item_id = ii.id

java - I am getting Null Pointer Exception in GridView Android -

i getting null pointer exception in fragment using gridview . code is public class homefragment extends fragment { gridview grid; string[] web = { "bata", "service", "puma", "hush" }; int[] imageid = { r.drawable.shoesmall, r.drawable.shoe1, r.drawable.shoe3, r.drawable.shoe4 }; public homefragment(){} @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_home, container, false); // viewgroup root = (viewgroup) inflater.inflate(r.layout.fragment_home, container); customgrid adapter = new customgrid(getactivity().getapplicationcontext(), web, imageid); grid = (gridview) getview().findviewbyid(r.id.gridview); grid.setadapter(adapter); grid.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public...

coldfusion - Why does HttpHeader X-Original-URL not exist on some pages? -

my site using url rewrite make seo friendly urls. makes self-posting form same page little tricky. however in coldfusion form's action attribute: <form name="formsortby" method="post" enctype="multipart/form-data" action="#structfind(gethttprequestdata().headers, 'x-original-url')#"> </form> the important part here #structfind(gethttprequestdata().headers, 'x-original-url')# gets me url of page. however x-original-url key doesn't exist on pages error coldfusion saying: cannot find x-original-url key in structure. specified key, x-original-url, not exist in structure. this happening when click go homepage of section in. x-original-url exists if go http://www.sitename.com/products/gaming won't exist if go http://www.sitename.com/products is there anyway around or make work need to? sounds there issue between rewrite rules , cf. but, there easy fix - can form post not specif...

ruby - getting started with rails guide: how do you create the files -

i using getting started rails guide , stuck @ point. creating new html.erb file within app/views/articles. how create new file. u in command prompt or script editor? any way really. can in command prompt if more comfortable or can create in script editor.