Posts

php - How to create select option from database? -

i'm working on form has 4 different select elements 2 tables of database. haven't done , don't know how it. i have table called "students" need "name" , "class" , table called "books" need "writer" "title" ... 1 select element , has more 2 option values. i've tried 1 sql query , 1 select shows 1 option on site, wether has 6 values in database. my code: $sql = "select class students"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $select_class = "<option value={$row['class']}>{$row['class']}</option>"; } <select id="class" name="class"> <?php print $select_class; ?> </select> how correct? you overwriting $select_class on each while() loop. need concatenate $select_class . change $select_class .= $select_class = ""; while ($row = mysql_fetch_asso...

date - PHP Daylight savings bug? -

i ran strange bug has occurs in php running in pacific time (and others). had code first day of week (sunday) given arbitrary date (in unix timestamp) in week: $day = date('w', $date); $start_of_week = date('y-m-d', $date - ($day * 60*60*24)); echo $start_of_week; prints 2014-03-08 this works every single date i've tried, except in week of march 9th, 2014, happens week of daylight savings time in us. those, $start_of_week '2014-03-08', saturday. when run code timezone set gmt, correct output ('2014-03-09'). additionally, when change code following in pst, correct output: $day = date('w', $date); $start_of_week = date('y-m-d', strtotime("-$day day", $date)); echo $start_of_week; prints 2014-03-09 so...wtf? why there difference between strtotime("-1 day", $date) , $date - 60*60*24 ? seems it's jumping between different timezones. codepad example

postgresql - Error with jdbc-river -

i'm trying load data elasticsearch jdbc-river, , i'm getting error. can tell me what's going on? org.elasticsearch.index.mapper.mapperparsingexception: object mapping [foo] tried parse object, got eof, has concrete value been provided it? @ org.elasticsearch.index.mapper.object.objectmapper.parse(objectmapper.java:467) @ org.elasticsearch.index.mapper.documentmapper.parse(documentmapper.java:515) @ org.elasticsearch.index.mapper.documentmapper.parse(documentmapper.java:462) @ org.elasticsearch.index.shard.service.internalindexshard.preparecreate(internalindexshard.java:371) @ org.elasticsearch.action.bulk.transportshardbulkaction.shardindexoperation(transportshardbulkaction.java:400) @ org.elasticsearch.action.bulk.transportshardbulkaction.shardoperationonprimary(transportshardbulkaction.java:153) @ org.elasticsearch.action.support.replication.transportshardreplicationoperationaction$asyncshardoperationaction.performonprimary(transportshar...

c - For how long do the recv() functions buffer in UDP? -

my program contains thread waits udp messages , when message received runs functions before goes listening. worried missing message, question along line of, how long possible read message after has been sent? example, if message sent when thread running functions, still possible read if functions short enough? looking guidelines here, answer in microseconds appreciated. when computer receives udp packet (and there @ least 1 program listening on udp port specified in packet), tcp stack add packet's data fixed-size buffer associated socket , kept in kernel's memory space. packet's data stay in buffer until program calls recv() retrieve it. the gotcha if computer receives udp packet , there isn't enough free space left inside buffer fit new udp packet's data, computer throw udp packet away -- it's allowed that, since udp doesn't make guarantees packet arrive. so amount of time program has call recv() before packets start getting thrown away de...

php - I want HTACCESS to block only direct access to a specific file -

i have file don't want users able navigate on own accord. however, if click link sends them there, it's okay page work. have htaccess file set so. <files "success.php"> order allow,deny deny </files> success.php name of file, , in directory of success.php , have following in htaccess file: rewriterule /?\.htaccess$ - [f,l] rewriterule ^/?admin/paypal/success\.php$ - [f,l] will users still able success.php if they're directed there, because know you're shown 403 error if try navigate there. if case blocked being directed there, there way can fix this? when type url "success.php" in browser's location bar , hit enter, browser sends request success.php. when go website , click on link takes me "success.php", browser sends request success.php. it's same, because click on link on site vs typing in browser, both requested same. when deny access, deny access. need check "referer" header, b...

vb.net - Generate code when correct picturebox is clicked -

i making game kids learn different parts of objects part of 9th grade tech class syllabus. there picture of plane , 6 smaller pictures underneath it. 3 of pictures components of plane, others won't. only when person playing has clicked 3 right components win game. i can't figure out way code program 3 pictures need clicked before program advances. take 7 picturebox saying, suppose main picturebox picturebox1 , underneath ones picturebox2 , picturebox3 , picturebox4 , picturebox5 , picturebox6 , picturebox7 . if correct picturebox 2, 3, 4, then, write following code under click events. private sub form1_load () handles mybase.load textbox1.hide textbox1.text = 0 end sub private sub picturebox2_click () handles picturebox2.click textbox1.text = val(textbox1.text) + 1 end sub private sub picturebox3_click () handles picturebox3.click textbox1.text = val(textbox1.text) + 1 end sub private sub picturebox3_click () handles pictu...

bash - Remove escaping sequences automatically while redirecting -

lots of shell tools such grep , ls can print colorful texts in terminal. , when output redirected regular file, escaping sequences representing colors removed , pure texts written file. how achieve that? use: if [ -t 1 ] to test whether stdout connected terminal. if is, print escape sequences, otherwise print plain text.