Jump to content

Korferer

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by Korferer

  1. Hi.. I really need help. I'm completely stuck and waaaay out of my depth here. I don't even know where to begin. I am desperate to learn how to use existing API services - but I find the whole concept completely overwhelming. I can't even get something from a Google search because everything on this subject just goes over my head. I have created an account with tvrage.com and got an API key. With that, I can get a list, in XML, of all the current TV shows in the UK and the US. It starts like this; <currentshows> <country name="US"> <show> <showid>69</showid> <showname>Who Wants to Be a Millionaire (US)</showname> <showlink>http://tvrage.com/Who_Wants_to_Be_a_Millionaire_US</showlink> </show> <show> <showid>237</showid> <showname>Jack Van Impe</showname> <showlink>http://tvrage.com/jack-van-impe</showlink> </show> <show> <showid>286</showid> <showname>Figure It Out</showname> <showlink>http://tvrage.com/figure-it-out</showlink> </show> <show> <showid>548</showid> <showname>TNA Pay-Per-View</showname> <showlink>http://tvrage.com/TNA_Pay-Per-View</showlink> </show> <show> <showid>576</showid> <showname>WWE After Burn</showname> <showlink>http://tvrage.com/wwe-after-burn</showlink> </show> All I want, is to list this out on MY website... I am a complete beginner. I imagine I have to copy and paste the URL in to my code, right? A javascript link? But then, what after that? I have barely touched javascript or jquery as a developer. Can someone just give me some guidance on this please? It's really starting to stress me out :-(
  2. So... I build web applications, but all my applications are on an internal server, for internal customers (colleagues, really) so they can shift data around etc. The point is, I never get to put stuff out on the internet. Therefore, things like OAuth (as I understand it) isn't really something I would ever need. My colleagues don't need to be logged in to Facebook in order to use my applications! Or need a shopping cart! I have my own development environment outside of work, I have got composer installed and am currently building something using Laravel 5. I am looking to expand my knowledge of open source. I am sure that Packagist has it's uses... But I'm struggling to see any that would benefit me. All I see when I look through it is symfony dependancy after symfony dependancy and a bit OAuth. Is it really that great? What have you used Packagist for that might be of use in a "data processing" type application? I'm not complaining and I mean no offence to people who use packagist a lot. I am basically just trying to keep up with coding for the internet.. and not just focusing on easy internal applications.
  3. Update; I have installed Vagrant now. And I am running git from my Mac it's working totally fine. This is certainly the way forward!
  4. So basically, I have got VirtulBox set up and running on my personal mac. It's for my own learning/development really. I have installed git, gitolite and gitweb on my virtual server (Guest VM is Ubuntu) and I am getting used to the basics of git. I have a github account and I want to take my git learning to the next level and put my project on to github. I am looking in to this but VirtualBox is saying that I should install GitHub Enterprise which doesn't feel right to me. This is just one guy's development.. Instead I created a new repository on github and ran this; git remote add origin https://github.com....etc/ I got an error, fatal: unable to access 'https://github.com/[username]/[project]': Could not resolve host: github.com Is it because I am doing it from a virtual environment? Would it be easier for me to set up git on my OXS instead and push/pull from the local dev folder? I'd rather not do it that way.. Advice?
  5. I would be amazed if they had any degree. Generally, people who get promoted (or even sideways move) in this organisation, at the "entry level" programmer position would not have a degree! And if they did have a degree, then they are probably more interested in becoming Stats, or Finance as it's super easy to get promoted. But, that is a really good suggestion, so thanks! I hear what you're saying, and funnily enough, a lot of people in my team are still on flip-phones as they are "concerned" with online security! haha. What about general electrician skills? If they can re-wire a plug/lamp, would you consider that a transferable skill? This is not going to be fun - at all!
  6. This isn't really a "programming question", I'd just like some advice really. I have been asked to write a paper by my boss on how we can go about recruiting for our developer roles people who (most likely) are not developers and will not have had any development experience of any kind. The reason for this, is that we have an external recruitment ban within our organisation (which sucks, but there is nothing I can do about it). We have about 20 developer jobs within our team. I work for a government organisation that has thousands of jobs for various purposes such as Finance, Statistics, Contracts - I'm not really sure what else, it's such a massive organisation - but nearly all the IT is outsourced to contractors apart from our little team. Any recruitment we do, they must already be a civil servant. So if they happen to love a bit of web development in their spare time then fantastic, but realistically, they probably won't. So how do you identify if they "have what it takes" to become a developer? Are there any official aptitude tests they can take that will show they are of the right mindset - ha - is there even a right mindset?! Other areas of our organisation use MS Excel a lot. Maybe there is some way of testing their VBA ability which would determine if they'd make a kick-ass programer or not?? I am open to all ideas here!!!
  7. Thanks for your views.. I think I was approaching the application all wrong. As suggested, I thought about what administrator actions are required and then I went ahead and created a few RESTful routes using this fantastic tutorial I found. I am actually making some good progress on this now
  8. Hi, This code works (and correctly shows just one result in my view); $people = DB::table('people')->where('id', '=', $person_id)->get(); But this one doesn't; $people = DB::table('people')->where('id', $person_id)->first(); And produces the error; Trying to get property of non-object (View: /media/sf_sandbox/health/app/views/agreement/display.blade.php) The `people` table just has a few fields of information on the individual with a primary key called `id`. I followed the Laravel guide on select statements. I don't understand what the error is trying to tell me and I don't get why that second statement is wrong. What's so wrong about it? I just want to understand Laravel/Objects better.... Thanks
  9. I am really struggling with the logic aspect of my application. I can't picture the structure and get it clear in my mind. As a result, I can't code anything because I'm second-guessing myself at every turn. My application is pretty simple in reality. It's an application that keeps a record of all the different 'contracts'/'agreements' that my colleagues have signed. Some will have signed three or four depending on what systems they are working on. The application will run a cron, daily, and send out an email to anyone who's contract/agreement is about to expire with an invite for them to renew it. I have already built an application that has a login system and authentication (using Laravel). It was my first Laravel effort and I did it using a tutorial from YouTube. I figured I could use the one login from that to act as the administrator for this whole application. Once the administrator is in, they will be presented with a panel to do various things. This is the part I am stuck on. What do you all think of my "logic"? Here are the basic routes (forgetting the auth stuff which is already done); /contracts - to see a list of all the contact templates out there. /contracts/{contract-id} - to view the specific contract template /contracts/create - GET and POST to be able to add new contract templates for other systems /people - view all my colleagues on one page /people/{person-id} - view a specific colleague and all the contracts they have signed /people/create - GET and POST for this too to be able to add new colleagues to the system /people/{person-id}/create-new-contract - so this would add a record in to a third table which joins info from the people table and the contracts table to make a list of unique contract agreements for each person and their expiry date. GET and POST for this as well I suppose. Even as I'm writing this, I don't know if this will be needed because I might have an emailing class that might do this job better? Hence the writing of this post! /agreements/renew/{renew-code} - This will create a new record in the table and amend the old one to show that the previous agreement has expired and that a new one for the next 365 days is in place.As you can probably tell.. I am struggling a bit. Is there any advice you can give me to help me mentally map out my application before I start coding? I just want to get it right..
  10. That reply doesn't really make a lot of sense. You kind of contradict yourself. Basically, I'm working on a server that is not connected to the internet. It's an intranet. I can't just go and apt-get or composer install a whole bunch of dependencies. So should I be using Laravel at all? What frameworks out there are only just a set of php files? For example.... CodeIgniter. Say what you will about CI, but it is a solution for this kind of environment. I'm looking at CakePHP but it seems pretty much EXACTLY the same as CI
  11. Hi. My sys admin guy has informed me that installing composer is unlikely. They're a bit jumpy about security around here. I tried to download and run Laravel on it's own but I'm getting errors when I go to http://example.com/test/laravel/public/ Warning: require(/var/www/html/test/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/test/laravel/bootstrap/autoload.php on line 17 Fatal error: require(): Failed opening required '/var/www/html/test/laravel/bootstrap/../vendor/autoload.php' (include_path='.:/php/includes:/var/www/html/php/includes:/jpa/release/jpa/includes:/usr/share/pear:/usr/share/php/phpmailer:/apache/htdocs/applications/surveys/Includes:/var/lib/ZF1/library') in /var/www/html/test/laravel/bootstrap/autoload.php on line 17 I'm very new to Laravel and I am basically assuming that the reason for these errors is because i haven't installed all the various dependancies. And that you can only install all the dependancies through Composer. Is this the case? I downloaded the Laravel framework from GitHub Unfortunately.. My only real experience of PHP Frameworks is CodeIgniter. So I've never expoled/used "packages" or "dependancies" and don't really know where they are, or where they go, or what they do! I managed to get Laravel up and running on my personal computer (using Composer).... But, as I've said, I might not be able to do this on my day job server. Any tips? ----- Update ----- Is there a chance I am just misunderstanding the word "Dependancies"? It's not a word I often use. Does it just mean "The PHP files that make up the Laravel Framework"?
  12. Thanks. Your response inspired me to try and get Laravel working on my mac. I couldn't get VirtualBox off the ground - still got a way to go in to understandning how that all works. But I did manage to get Laravel up and running on MAMP. Small steps.
  13. Hi.. I've hit a wall that I cannot seem to overcome - and I don't know what to do about it because I can't even really accurately describe the problem (but I'll try). It seems to me that the only way to progress beyond a certain point, requires you to have a deeper understanding of operating systems and servers and hypervisors etc. Stuff that goes wayyy beyond doing a bit of PHP and Javascript. It's frustrating because I'm at that place and I can't get my head around it all. It's too vast! I really want to stop using MAMP and progress on to things like VirtualBox and Vagrant. The primary reason for doing this is that I am really keen to use a PHP Framework called Laravel. But all the documentation I see tells me that I need to use something called composer to install it. Composer is a dependancy manager (I'm not sure what dependancies are, really) but in order to do that I need a virtual server because I don't think I want all this on my physical machine. In order to get a virtual server I think I need a virtual operating system. I think. So I have tried to install VirtualBox and I just want to sling my laptop out of the f***ing window to be perfectly honest. It's not working. And even if it did work I wouldn't be able to tell. So.. I'm clearly just venting here. There is no question. If there was a question it would be.... How can I just learn enough to get by?
  14. My code; $sql = "SELECT SUM(IF(`submitdate` IS NULL , 1 , 0 )) as 'Survey Started But Not Completed' FROM `survey_$surveyid`"; $statement = $dbh->prepare($sql); $statement->execute(); $result = $statement->fetch(PDO::FETCH_OBJ); //pass that data to an object Is returning; stdClass Object ( [Survey Started But Not Completed] => )  I need to set this to a vaule that I can actually print out on the screen... Like a "0" for example. At the moment it is just a NULL. How do I do this?? These don't work; $result = 0; $result = array(['Survey Started But Not Completed'] => "0");
  15. Ha. I would attempt that but it's an open source application - LimeSurvey. And I just have to work with it. I have gone for the Ch0cu3r method except for $dbh->errorCode == '42S02' just doesn't work. Even if I try to print that it just prints nothing. I am also running $survey_id through a function to check if the table exists or not first. function tableExists($pdo, $table) { // Try a select statement against the table // Run it in try/catch in case PDO is in ERRMODE_EXCEPTION. try { $result = $pdo->query("SELECT 1 FROM $table LIMIT 1"); } catch (Exception $e) { // We got an exception == table not found return FALSE; } // Result is either boolean FALSE (no table found) or PDOStatement Object (table found) return $result !== FALSE; } Not very glamorous but it'll do.
  16. Here is my code so far (I say it's PDO but it pretty much isn't. What is the object here? The database connection? LOL!); $sql = " SELECT SUM(IF(`sent` != 'N' , 1 , 0 )) as 'Emails Sent', SUM(IF(`completed` NOT IN('N','paper') , 1 , 0 )) as 'Completed Electronically', SUM(IF(`completed` = 'paper' , 1 , 0 )) as 'Completed Manually', SUM(IF(`completed` != 'N' , 1 , 0 )) as 'Total Number Completed', SUM(IF(`remindercount` = '1' , 1 , 0 )) as 'Reminder Sent Once', SUM(IF(`remindercount` = '2' , 1 , 0 )) as 'Reminder Sent Twice', SUM(IF(`remindercount` = '3' , 1 , 0 )) as 'Reminder Sent Thrice' FROM `tokens_$survey_id` "; $statement = $dbh->prepare($sql); $statement->execute(); $result = $statement->fetch(PDO::FETCH_OBJ); foreach($result as $key => $value) { echo "<tr> <td>$key</td> <td>$value</td> </tr>"; } This is all well and good if the tokens_$survey_id table is actually there. Sometimes, for a genuine reason, there won't be a tokens table for that particular survey. How do I account for this? At the moment I get an error.. Warning: Invalid argument supplied for foreach() in /var/www/html/index.php on line 149 I tried this but I am not satisfied this is correct; if(!$result) { die(); } I don't want the code to die! If I take out the die() statement then this if is ignored for some reason I don't understand.
  17. No. I have many knowledge gaps on even the simple stuff. So if I had a website, and I wanted to include THIS page on my homepage, I couldn't just go... <?php include "http://forums.phpfreaks.com/topic/289408-php-apis/"; ?> ...in my index.php and expect to see our conversation from PHP Freaks? I think I knew that a long time ago but have since forgotten. If that's right then APIs are starting to make a bit more sense to me now. FYI - I tried to run that code above and I got errors back (when I turned error reporting on) Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /Applications/MAMP/htdocs/index.php on line 43 Warning: include(http://forums.phpfreaks.com/topic/289408-php-apis/): failed to open stream: no suitable wrapper could be found in /Applications/MAMP/htdocs/index.php on line 43 Warning: include(): Failed opening 'http://forums.phpfreaks.com/topic/289408-php-apis/' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.10/lib/php') in /Applications/MAMP/htdocs/index.php on line 43 After I put out this post yesterday I did stumble upon the twitter api. Is that what most APIs are like when they are built? That's half the reason behind my original post..... Just outright confusion. I thought an API didn't have a front-end. I didn't understand the first thing about them!
  18. I really don't understand the point of an API. I am totally lost on this one. I have never in my life used JSON and barely touched Javascript so I'm already quite behind the curve but this was my understanding of the "purpose" of an API; You have some data in a database that others might find useful so you write a script that allows people to go in and pull data from it. So why aren't these APIs just built using PHP? If I have a database table of first names, last names and email-addresses, and for some reason I want other people on the internet to be able to get at that, then why don't I just write a one-page script that list them all out? Then all the user has to do is "include" it in their code, right? That's probably really over-simplistic, and I am surely missing the point. There must be a point, but I cannot find a single source anywhere with an actual decent explanation of this. What am I missing? You never know, perhaps you're all about to tell me that most APIs are built using PHP and what I've described is pretty much it. But everything I research leads to a dead end because they all refer to one another; Example 1 - "Oh JSON is freaking awesome. I use it because it's awesome. It's awesome for work working with APIs". Example 2 - "Oh, APIs, yeah, you totally have to have APIs. All you have to do is use JSON. It's awesome". Not direct quotes, but close enough! Seriously, help me out. I have a lot of public data on my server and I am positive that someone can make good use of it. But how?
  19. I read this article. About two thirds down it mentions that you can turn off autocomplete on the entire form if you put it in the form tag. The post is from 2011 though so I was wondering if it is still valid? Does anyone know if this is still correct? So, can I use something like; <form action="example.php" autocomplete="off"> First name:<input type="text" name="fname"> Last name: <input type="text" name="lname"> E-mail: <input type="email" name="email"> <input type="submit"> </form> Or do I need something like; <form action="example.php"> First name:<input type="text" name="fname" autocomplete="off"> Last name: <input type="text" name="lname" autocomplete="off"> E-mail: <input type="email" name="email" autocomplete="off"> <input type="submit"> </form> To be sure...
  20. I get that it's a bit simple. I don't plan to actually use this for anything. I am just trying to practice OOP at the moment. I'm starting to get the point though that Classes are for BIG things. Like a Database class, or a User class, or a Validation class. And not small things like my Greeting class above. I wanted a way to pass a set hour to the getGreetingPhrase, in a variable. But I didn't want to adjust the code in the method. That would give me the option of not always having to use the current hour. Ok, that makes sense.
  21. Ch0cu3r - Thanks for the PDOStmt::rowCount sugestion. I will look in to that. And actually, Jacques1 makes a really good point. Ideally, no one would be running this application if they didn't have rows to actually add to the table. However, I really should be aiming to make something more "versatile", therefore a "touch" sounds like a good solution too. And you're right Jacques1 - I have NO IDEA how exceptions work. Ha! I have since read a little bit about them and to be honest it still confuses me. I also have no idea what I'm doing using the prepare statment. I knew right from the start it wasn't a great idea because I had nothing to "prepare" really. It was already prepared. But I struggled initially with using just exec(); That was the reason behind my original post. So when I change to contents of my run_from_file() method to; $sql = file_get_contents($location); exec($sql); My code just says it was successful but my database hasn't actually changed when I run this. I assume that's because the exec statement isn't joined to any kind of PDO database connection.... Don't know how to do that yet either.
  22. Hi. I haven't done a lot of OOP. Hardly any really. I've had a go at writing a very small class that outputs a greeting depending on what time of day it is. What do the OOP experts here make of it? What do you like, what do you hate? Is there anything I could do to make it more useful? Here is the code; class Greeting { // the __construct didn't do what I originally wanted. Denfine the hour outside the method (I don't know why this is a good/bad idea) /* public function __construct() { $hour_of_day = date('G'); } */ public function callGreetingPhrase() { return $this->getGreetingPhrase(); } // the setter doesn't seem to have a purpose here. I tried using it so that I could pass in a value of my choosing (for testing purposes) can't get it to work though /* public function setGreetingPhrase($value) { $this->hour_of_day = $value; } */ private function getGreetingPhrase() { $hour_of_day = date('G'); if($hour_of_day < 12 ) { // if it's before 12pm $greeting_phrase = "good morning"; } elseif($hour_of_day >= 12 && $hour_of_day < 18 ) { // if it's after 12pm but before 6pm $greeting_phrase = "good afternoon"; } else { // what is left over - after 6pm until midnight $greeting_phrase = "good evening"; } return $greeting_phrase; } } $greeting = new Greeting; echo $greeting->callGreetingPhrase(); It annoyed me that I could 't figure out how to use the __constructor here to store the hour. But should that have bothered me? Can someone maybe explain a bit about the setter that I tried to use setGreetingPhrase. I only put it in because I've seen other Classes with one. Could I use a setter method here for anything useful? Any feedback appreciated!
  23. I'm not sure. That's part of the problem as I'm new to OOP in general. Almost all the stuff in that Class is someone elses code which I can broadly understand. In any case, I do believe I have solved this isse! In the DB Classes file; // THE METHOD TO EXECUTE A FILE public function run_from_file($location) { try{ $sql = file_get_contents($location); $sth = $this->_pdo->prepare($sql); $sth->execute(); } catch(Exception $e){ echo $e->getMessage(); } } I didn't realise that prepare() and execute() are built in functions and would work here. I guess my next problem is, how am I absolutely sure that my table has been updated? I guess I'll have to compare the count of rows before and after this method and see if there is a difference.... That doesn't sound fun.
  24. I have written a Validation class that checks to see if a file being uploaded to the server meets certain conditions. That works a treat. The next step is to actually upload it to the server and I have an Upload class that can do that. Again, that works perfectly fine. Once the file uploads, I am passing the $location of that of that file to my DB class. The DB class is full of methods that prepare and then execute strings that are SQL queries that are required in other areas of my application. Nothing I have at the moment is suitable for just running an SQL file so I don't know what to do now.. My procedural code, that works, looks like this; $dbh2 = new PDO("mysql:host=localhost;dbname=DB360transfer", $login_user, $login_password); $sql = file_get_contents($path.$new_file_name); $qr = $dbh2->exec($sql); I'm not sure how to replicate this up in a PDO/OOP application. My DB Class script is attached. The run_from_file code starts on line 98. I've left in the other stuff as I suspect the answer has something to do with using the $this or the self:: - but really I have no idea. So my question is, what is the correct syntax for executing a file in OOP? DB.php
  25. Hi. I'm not exactly new to PHP but I am brand new to this community. I have been PHP aware for about 5 years but in all that time the amount of coding I have actually done has been rather pathetic. I work for a company that is quite... insular, and secluded (their choice, not mine) from the wider developer community. As a result I only discovered PHP Frameworks about a year ago and feel quite behind the times. I am used to writing procedural PHP and not much else. I am here to hopefully broaden my horizons and get a better understanding of Frameworks, OOP, SQLi or PDO or database "unspecific" applications. When I first discovered PHP Frameworks about a year ago, my friend suggested I get started using CodeIgniter (that seems to be a lot of newbies' first choice!). I loved it, but after reading various rantings and ravings on the internet I decided that I should probably move on to something more "professional". That's when I came up against SF2 and almost cried myself to sleep every night. It made no sense to me. It still makes no sense to me. I gave up. After that I tried Laravel but couldn't even get going thanks to something called "Composer" which I still don't understand. I thought to myself, "I don't want to learn about dependencies at this stage, I just want to code". I gave up. Then another friend suggested I use PHP Slim. Another Framework. I tried to work with it but it seemed heavily dependant on knowing OOP, and I didn't have the first clue what I was doing. I gave up (are you sensing a pattern here?) So after that, I decided to try and learn the basics of OOP and how/why it was better than procedural and I have to say - I don't think it is. And I kind of hate it. I find it really confusing and not one person I have asked is able to tell me why OOP is better than procedural. They say "it just is". Sigh.... Then I decided to join PHP Freaks so I could vent my frustrations!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.