Posts

Add date to MySQL using PHP -

i trying add current date mysql table using php. have following code: $date = date('y-m-d'); mysql_query("insert book_order values($date)") or die (mysql_error()); mysql returns error: incorrect date value: '1996' column 'date_order' @ row 1 date_order attribute type date . i've tried echo $date value , prints out 2013-05-12 why can't add date table , strange 1996 ? if can send local date use: mysql_query("insert book_order values(now())"); the problem because sql have typo - $date variable must quoted: mysql_query("insert book_order values('$date')") or die (mysql_error()); in addition, if not work edit question , paste result sql explain book_order

cq5 dialog is not changing its width after increasing the size -

i have dialog in cq5 using xtype tabpanel, planning change default dimensions of dialog using these instructions still see default size of dialog though increased width of xtype panel. i got working after change xtype dialog this known issue, , has been present since @ least cq 5.3. workaround i'm aware of said, change xtype dialog, set height , width properties on dialog node, , add tabpanel node child node of dialog.

MongoDB java update a doument by a function with fields -

i using mongodb, java, have following document structure : { _id : ... total_items : 34 avarage_cost : 54 } now have item cost, , want update collection total increase 1 , avarage cost right, best way so? i thought doing : int cost = ... ; basicdbobject updatequery = new basicdbobject(); updatequery.put("$inc", basicdbobjectbuilder.start().add("total_items ", 1).get()); updatequery.put("$function", "function(){this.avarage_cost = ((this.total_items-1)*this.avarage_cost + "+cost+"/) / this.total_items;}"); is good/working solution ? best way ? for cannot run javascript code on update queries. there open issue on jira. check issue here . you can solve problem follows : get current object. if null calculate average_cost & total_items , insert db. if not null, current total_items & average_cost field. calculate new total_items & average_cost values. update fields using $set ...

ios - CALayer with transparent hole in it -

Image
i have simple view (left side of picture) , need create kind of overlay (right side of picture) view. overlay should have opacity, view bellow still partly visible. importantly overlay should have circular hole in middle of doesn't overlay center of view (see picture bellow). i can create circle : int radius = 20; //whatever cashapelayer *circle = [cashapelayer layer]; circle.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0,radius,radius) cornerradius:radius].cgpath; circle.position = cgpointmake(cgrectgetmidx(view.frame)-radius, cgrectgetmidy(view.frame)-radius); circle.fillcolor = [uicolor clearcolor].cgcolor; and "full" rectangular overlay : cashapelayer *shadow = [cashapelayer layer]; shadow.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0, view.bounds.size.width, view.bounds.size.height) cornerradius:0].cgpath; shadow.position = cgpointmake(0, 0); shadow.fillcolor = [uicolor graycolor].cgcolor; sh...

sql server - fully update a temporary table sql -

i have problem: trying update temporary table (in stored procedure) in sql server 2012, updates first entry matches description. here code: create table #t (store_name varchar(30), product_name varchar(30), price int, valab_since date, valab_until date, best_offer varchar(3)) --some code populates table update #t set best_offer = 'yes' price = (select min(price) cataloage c inner join produse p on c.codp = p.codp p.denumire = #t.store_name) update #t set best_offer = 'no' price > (select min(price) cataloage c inner join produse p on c.codp = p.codp p.denumire = #t.product_name) select * #t cataloage , produse tables use to cover records, first set them "no", run separate query update ones min price store. update #t set best_offer = 'no'; ;wit...

301 redirect phpbb forum and all subpages -

hello redirect website/forum/ , subpages (e.g.: /forum/viewtopic.php?f=2&t=453) index page. i have tried few different methods not work. i tried redirectmatch 301 ^/forum/.*$ http://myhomepage.com leaves part of forum page in url. i tried: rewriteengine on rewritebase / rewriterule ^/forum/.*$ http://myhomepage.com [l,r=301] but did nothing. any appreciated. for apache's httpd.conf , try using rewriterule ^/forum/(.*)$ http://myhomepage.com/ [r,nc] the (.*) should catch comes after /forum/ . r means redirect, , nc means case insensitive.

unix - How to use fgets() instead of fscanf() on stdin in C? -

i want use fgets instead of fscanf stdin , send child process via pipe. code below works sorting lines in file replacing fscanf(stdin, "%s", word) with fgets(word, 5000, stdin) gives me warning warning: comparison between pointer , integer [enabled default] otherwise program seems work. ideas why getting warning? int main(int argc, char *argv[]) { pid_t sortpid; int status; file *writetochild; char word[5000]; int count = 1; int sortfds[2]; pipe(sortfds); switch (sortpid = fork()) { case 0: //this child process close(sortfds[1]); //close write end of pipe dup(sortfds[0]); close(sortfds[0]); execl("/usr/bin/sort", "sort", (char *) 0); perror("execl of sort failed"); exit(exit_failure); case -1: //failure fork case perror("could not create child"); exit(exit_failure); default: //this parent process close(sortfds[0]); //close read end of...