nik_jain
Members-
Posts
60 -
Joined
-
Last visited
-
Days Won
1
Everything posted by nik_jain
-
PDO. How to pass quote literal as part of query?
nik_jain replied to nik_jain's topic in PHP Coding Help
This is late. SOrry my question wasn't clear. But I found that in this instance prepared statements cannot be used. The SQLITE syntax required literal that PDO driver could not just pass and there was no way of escaping. Note I could escape the parameter passing it from PHP to PDO . But could not escape it from PDO to sqlite. -
SQLITE has syntax like ' WHERE MATCH ( 'colname : "one two" )' //My pdo sql query $sql .= MATCH 'colname : "?" )'; $pdo->bindValue(1,$text);` But Pdo placeholders can't have quotes around them. So this does not work. I tried a million variations of the placeholder syntax "?" "" ? "" """ ? """ \" ? \" . But nothing works. Errors I get : General error: 1 near "?" | 25 column index out of range . Also for this query : MATCH ( names: ? AND categoryids: ? ) , the error is: `General error: 1 unrecognized token: ":"` Would really love some help here.. Thanks
-
Use a DOM parser like querypath to parse the XML http://www.ibm.com/developerworks/library/os-php-querypath/
-
Not tested, but in the last three lines in coded section $d should ( could ) be $fulo . for($fulo=$d;$fulo>0;$fulo--){ if($_POST['outcome'.$fulo] !==""){ $out=$_POST['outcome'.$fulo];break; }else{continue;} } $act=$_POST['activity'.$d]; $ind=$_POST['indicator'.$d]; $tar=$_POST['target'.$d]; and the else{continue;) is most probably not needed.
-
Nope, I was kind of wrong about this one... lets hope I am able to get symfony..
-
Agreed. I was quite hesitant to call it a framework, hence the word structure (some code that I can reuse) . It was obviously never meant for use by anyone other than me.. Well in my defense is the complete code of the site, not the actual 'structure' . Although I admit it doesn't even have a any kind of DB class Thanks a lot for your response. I have tried symphony in the past, will give it another shot. Though through another forum I discovered that its quite easy to get rid of blade in laravel, so I might give it a shot too! Thanks again
-
I am PHP developer developing for the past 3-4 years, but except for CI I had always kind of struggled with any type of framework.. So I ended up not using most and just rolling my own frameworkish 'structure' . That ended up as a FANTASTIC learning experience, as I really got to understand what and how a real framework does/works. My complete source of the site wowpictures.link (which was made as a learning thing) is here: https://bitbucket.org/nikhil_jain/complete-wowpictures.link-source/src . Can someone take a quick look please . and offer suggestions / improvements / completely wrong things I did ? Secondly now I am hunting for a real framework, but I just find them too restriucitve / imposing. For instance yii seems too tied up with bootstrap, laravel like blade too much. Yii also seems to have a very specific class / method naming structure, that I find a chore to remember..etc etc. So what should I do? Learn any proper framework OR try to improve my own thingy ? I am strongly leaning towards th former option, but can't find a framework that doesn't forces random stuff no me .... Thanks
-
two things. - Variables don't work inside single quoted strings - Since we are alreeady inside <?php tags the <?php echo $directory; ?> part doesn't require <?php and ?> . Also since we just want to join (concatenate) text , the echo is also not required. So Change $output = shell_exec('tar -czvf {$directory} <?php echo $directory; ?>'); to $output = shell_exec("tar -czvf {$directory}.tar.gz {$directory} " ) ;
-
Learning about Multithreading in PHP (pthreads) ?
nik_jain replied to nik_jain's topic in PHP Coding Help
Thanks for attempting to help, but .... let me try and explain my question a bit more clearly. I am looking to learn pThreads as described here: https://gist.github.com/krakjoe/6437782 The above article talks a lot about synchronization / mutex / waiting / sharing / context and other unknown concepts.. These are the concepts and generally learning pthreads is the help I am looking for. Taking a real world example: class WebRequest extends Thread { public function run() { for_doc() ; echo 'Running Thread : ' . $this->getCurrentThreadId() ."\n"; } } Here the for_doc() is a factory function that creates a Object of type A class, but all calls to $this return null ( I know I didn't explain the issue well, ut I am just trying to give an idea about what confuses me about multithreading) -
Hello Where should I go If I know nothing about multi-threading and want to learn about pthreads . Googling for multithreading tutorials only shows non-PHP, language specific tutorials.. PS: I would really prefer a video lecture or tutorial
-
Thanks. I have thought of this before, but having heard several times that coming up with your own cms is a bad idea, and not knowing how to build my own CMS I didn't follow through with it. Nah, both of these change for too rapidly for my slow mind. I also had a talk with a cousin of mine, he suggested that whatever framework I choose, I should spend a LOT of time with it, so I guess I'll try spending a couple of months with yii and see how it goes..
-
Thank you! actually I struggle in the same manner with frameworks as well . Recently I tried learning zend and yii 2 Site Features: 1. Basic Search 2. Post page 3. 'browse/filter' page . Basically narrow down posts using category / date etc. Regular stuff.. Wordpress way: create post, post_type using csv row, import and use existing search, comments functionality. Core PHP way: Create database structure -> import csv implement every goddamn feature myself. be it comments to post, post_page , search functionality etc. The issue with frameworks/CMS: the trouble starts when implementing something not in the book/docs means googling too much... Say in wordpress I had to implement a form that anybody could post to, this proved tiresome. Not difficult, but trying to figure out how to implement required googling..
-
One option might be to add a boolean column - 'is_guest' ? Set default value to false and work from there..
-
Basically everytime I try to code a site in an existing CMS I find out that I spend 99% time trying to google out how the CMS works, how a particular thing is done and less time coding. I end up not using any CMS at all and just code my site in Core php. Now I have an idea for a site that whose development I think will really be speeded up if I use an exisiting CMS, instead of trying to implement every goddamn feature myself. I feel I am doing something wrong in the way I try to learn a CMS. or maybe I am just not using the right CMS. I have tried reading books / video tutorials / online tutorials etc Can anyone relate? Any tips / suggestions to offer ? I am most familiar with wordpress btw Thanks
-
POST variables are returned as String afaik, so they needs to be converted into integer for integer comparison So this should do the job: if ((int)$value >= 0.0 && (int)$value <= 10.0) {
-
I don't understand you, but a couple of pointers... 1. curl can return the error, if any for the current request. check it if it helps: http://php.net/manual/en/function.curl-error.php . Similarly there is curl_info 2. The values being passed to POSTFIELDS should be urlencode'ed 3. Referer doesn't seem right
-
$someArray = json_decode($_POST['containerPositions'], true); The true parameter causes an associative array to be returned. If you need an ofject set it false http://php.net/manual/en/function.json-decode.php
-
If you are not handy with Javascript it will require some learning... Basically you set code to send requests with javascript(ajax) every 1 second or so The requests (simple GET queries ) are sent to the server, site.com/ajaxHandler.php?check=1 Where the script ajaxhandler will check for whatever thing you need to check and echo out a response, which the javascript code will see and perform an action based on that. For syntax , just google.. 'ajax beginner' or something like that
-
Easy help with prewritten mobiledetect script
nik_jain replied to superDR01D's topic in PHP Coding Help
Yup Basically we are replacing index.html with index.php (index.php should be called automatically). HTML files cannot normally call php files. So rename index.html to index.php and add the code there. Its like this: Apache recieves request for site.com > it looks for specified files (generally index.html / index.php etc) If index.html it sends as is. index.php it processes it through PHP , which creates html text and sends it to apache , which sends it to the browser. HOWEVER you will also have to rename all instances of index.html in your other files to index.php, otherwise dead links... btw if you are interested to go deeper into PHP I strongly recommend a book/video tutorial series to grasp the basics. -
The aim is to be able to release 'something' a small library / Class etc to show off my programming skills and to practise some of those design patterns . But I am struggling to come up with ideas for anything. The few ideas that came to mind: 1. Some kind of responsive HTML generator that uses GRIDS from purecss.io - This maybe far too frontend'ish. I more of a backend guy 2. Timer Class to time things. Too easy I think.. 3. Any other suggestions please . I code in PHP and JavaScript Thanks
-
I can't reach elements between <span> here <span> ?
nik_jain replied to wafa's topic in Other Libraries
The perfect way of parsing HTML in PHP is via the library 'Querypath' its a wrapper around DOM , so no regex. Also the syntax is very jQuery like.. -
Easy help with prewritten mobiledetect script
nik_jain replied to superDR01D's topic in PHP Coding Help
Nope , its a PHP class that requires to be processed server side using PHP. plain html files are generally passed as is from your server (website) to the client(user with the browser) without passing them through PHP. So to use it: you need to use a PHP file (say inde.php), that has the above code The following line : Tells PHP where to look for Mobile_Detect.php . In this case its the same directory as the inde.php file we created earlier. btw you can rename the inde.html file to inde.php , but that might break things depending on how the rest of your site is... Lastly I think the apache server can be configured to process html files as PHP, but I am pretty sure thats (a) not a good idea (b) not possible on shared hosting... -
Replacing a select drop down with images in php
nik_jain replied to totallytech's topic in PHP Coding Help
http://stackoverflow.com/questions/9508029/dropdown-select-with-images -
I don't think I understand what you require, but the string {age:30-50} is a json encoded string . You can get the value by $string = '{age:30-50}' ; $age_obj= json_decode($string) ; $age = $age_obj->age ; Something like that