Jump to content

Drongo_III

Members
  • Posts

    579
  • Joined

  • Last visited

Everything posted by Drongo_III

  1. Two questions so I can get my tired grey matter around this: 1) I should convert the date values to unix time stamps? 2) in the example usort function on php manual ( copied below) what is $b? Is this a copy of the original array against which the value $a is compared? function cmp($a, $B) { if ($a == $B) { return 0; } return ($a < $B) ? -1 : 1; } $a = array(3, 2, 5, 6, 1); usort($a, "cmp");
  2. Hi Guys Bit confused on the best way to approach this so some advice would be welcome. I have a multidimensional array which is created from a twitter and facebook feed combined into a single array. I want to sort the array by date order but I'm not sure of the best way to do this. I have been looking at array_multisort but I can't see how you get that to work without specifying a precise index. An example of the array I am working with is as follows: print_r($socialMediaArray); Array ( [0] => Array ( [date] => Fri Jan 04 1:35:43 [Message] => Brilliant day last thursday - lets do it again [from] => facebook ) [1] => Array ( [date] => Sat Jan 26 15:40:51 [Message] => how do you like my new fb page? [from] => facebook ) [2] => Array ( [date] => Thu Jan 24 01:38:19 [Message] => Some test message from twitter [from] => twitter ) [3] => Array ( [date] => Mon Jan 21 20:14:33 [Message] => @tester here is a message just for you [from] => twitter ) [4] => Array ( [date] => Sun Dec 16 19:50:33 [Message] => some other message #test [from] => twitter ) )
  3. Try: $list .= implode('; ', $row['email']);
  4. I think you need to post the full code but based on what I can see there you setup the connection on '$this->connection' so when you try to retrieve the result you should write it: $result = $this->connection->query($sql); Also in your index file trying using var_dump($this->connection); to see what you're getting.
  5. I've not read through the miles of code but at a glance if you wanted to get a copy of this email you would change the first line of your php script $owner_email = $_POST["owner_email"] . ", YOUREMAIL@DOMAIN.com"; Or if you don't want the user to see your email address has been added then add yourself as a BCC http://php.net/manual/en/function.mail.php
  6. Could be a silly question but you have formed the connection via mysqli to create an object? i.e. $mysqli = new mysqli("localhost", "user", "password", "database"); And are you sure the sql query is sound?
  7. I went with Barand's suggestion as it seemed more inline with the way I envisoned it working and it worked a treat. I confess I've only used very simple joins and I would like to understand mutilple joins better - I am a bit weak on my sql. So I'm hoping someone can answer a few questions on this... Firstly this line: CASE WHEN jobs.request_other <> 0 THEN req.email ELSE users.email END as email The only thing confusing me is the 'as email' bit at the end. Why do you give it the alias 'email'? It doesn't appear to be used anywhere else in the query so what's the purpose here? Also the req.email part. 'req' at this point in the query has no meaning so am I right in saying that it becomes meaningful when you alias it as 'uses as req' later in the query? And my last question is about how the query gets executed with mutliple joines like this. Is it the case that the Inner join statement will run first and retrieve all email results where and ID matches in both tables. Then the query gets re-run with the Left join statement and overwrites the email results whereever there is an id match resulting from 'jobs.request_other <> 0' in boht tables? Is that right? Many thanks for your patience, Drongo
  8. Thanks Guys Lots of very helpful suggestions there. I will give these a whirl tomorrow in work and see what fits best. I shall report back! Many thanks! Drongo
  9. Hello Very much stuck on this and it's held me up for a good few hours so help is much appreciated - i'll try and keep this brief. Essentially I have two tables - a 'users' table with cols for user id, email, name etc. and a 'jobs' table containing a lot of columns that I won't list but there are two that are relevant to this. The two columns are 'user_id' and 'request_other' - both of these are relational to the users table user id. There are two cols because the application stores data on the person adding the job (in user_id) and the person who requested it (in request_other). This latter field get set to '0' if the person adding the job is also the requester. So here's where I'm stuck. When I query the jobs table to populate some data in a page I need to get the email address, based on the user_id, from the users table. So I query the jobs table and perform an inner join as follows and all works well(stripped out most of the fields for the sake of clarity): SELECT jobs.job_number, jobs.brand, jobs.description, users.email FROM jobs INNER JOIN users on jobs.user_id = users.id WHERE jobs.status !='live' ORDER BY jobs.brand ASC, jobs.date_created DESC Here the join is done on the basis of a match between user_id in both tables. BUT what I really want is to conditionally alter the '...INNER JOIN users on' part of the query to say: "If request_other !=0 then use request_other = users.id ELSE use jobs.user_id = users.id" I dont know if that's possible or not? I've tried adding in cases and If statements but nothing seems to work as I am probably doing it wrong - despite a lot of trying :/ If anyone could suggest a means of achieving what I am after I would be eternally thankful!
  10. Umm out of interest. You are actually running this on a web server right? Not just from your local machine?
  11. Here are a few things to try and help you resolve the issue: 1) ensure error reporting is on - error_reporting(E_ALL); . This might give you a clue as to the issue. 2) Your include uses short tags, i.e. <? SOME PHP CODE ?> instead of full tag structure <?php SOME PHP CODE ?>- So try using full tags as depending your individual configuration short tags may not be enabled. <?include("inc/incfiles/headder.inc.php"); ?>
  12. Hello Wonder if someone can give some advice. I am working on quite a high volume website (800k+ hits per month) which operates on two load balanced servers. I'm creating an image upload page that will enable users to send images and some other details to backoffice staff. The upload facility will typically allow around 4-5 image uploads at once totalling between 2-10mb of images (need to be quite high res). The intention is to allow backoffice staff to access these images for their own business purposes. But the problem i foresee is that because the servers are load balanced the images will be uploaded to one or other of the servers. So if had the system simply generate a link to a zipped folder of images and email the link to backoffice staff they would end up not being able to access the images if the load balancer directs them to a server other than the one where the images were uploaded - phew! So I'm looking for some advice on the best approach in this scenario: a) setup some kind of sync between the servers - what would you suggest? b ) store the images in a database - guessing blob data ? The servers both share a mysql service so this seems reasonable. c) some other ingenious solution proposed by the all knowing people of php freaks Any advice is very welcome! Drongo
  13. Hi Mate As christian pointed out basename is needed - sry my bad i was typing it out a bit fast earlier. Your code to grab what is essentially the file name should look like this: $PageLink = basename($_SERVER['PHP_SELF']); Then the conditional for the link will look something like <a href="fysio.php" <?php if($PageLink == 'fysio.php'){ echo 'class="ClassToApplyUnderline"';} else {echo 'class="ClassThatDoesNotUseUnderline"';}?> >page1</a> A good practice if you need to test a variable that doesn't appear to be matching is to echo it out. So try doing echo $PageLink; This way you can see what basename(...) is giving you to work with and you can formulate your if statement from there. Hope that helps! [quote name=Togo' timestamp='1360361064' post=' 1411153] Yes, and that is exactly what i want the script to do. I want the link beeing clicked on underlined when the condition is met (beeing on the page the link refers too), and if not then don't underline it. My html table may be a mess, but it looks fine to me. I did try building it the way i assume you wan't to, but it didn't give me a different result. But this: Dosen't do a thing, and thats what im now trying to figure out why not.
  14. Hi Togo What follows is a very simplistic demonstration to get you kick started. You need to be able to grab the url. So if your site is www.mysite.com/page1.php you can do something along the lines of the following: $pageLink = $_SERVER['PHP_SELF']; This will populate a variable with whatever follows the base domain. So in the example of www.mysite.com/page1.php $pageLink will now be equal to "page1.php" You can then perform your if statement to find if you actually are on page1 <a href="page1.php" id="navLink" <?php if($pageLink == 'page1.php'){ echo 'class="UNDERLINE"'} ?> >page1</a> In reality you wouldn't really get by with something quite as simplistic as the above because the url structure would be more complicated but it should get you thinking in the right direction.
  15. There are probably lots of ways of acheiving this and if it does what you want then who is to argue? If you would prefer the page didn't refresh itself then you should look into ajax. Just do a google search on 'ajax php' and you will find lots of examples. Ajax uses javascript to get/post data asynchronously enabling data to be exchanged with the server in the background without need to to refresh the page. ajax looks a bit puzzling at first but once you break it down it's very straight forward. If you have any more questions on it after googling just shout.
  16. Hey mate Don't know if you're still working on this and what follows is a hidiously impractical solution but this might point you in the right direction. In this instance it hinges on you wrapping a span around the letter in question - which would probably mean you need to do some sort of str replace when you generate the document. Probably not worth it unless you only use the fonts sparingly - i.e. in a header. Hope thi shelps a bit! <html> <head> <style> span { display: inline-block; -webkit-transform:rotateY(180deg) !important; -moz-transform:rotateY(180deg) !important; -o-transform:rotateY(180deg) !important; -ms-transform:rotateY(180deg) !important; unicode-bidi:bidi-override !important; direction:rtl !important; } </style> </head> <body> <p> H<span>e</span>llo World</p> </body> </html>
  17. Hi Guys I worked this out in the end and I learned two things - firstly that most tutorials for this online are outdated, and secondly that facebook is the single largest sack of horse s%$t known to man with a 'war and peace' sized documentation that is mostly contradiction and dead ends. Anyway rant aside I thought I would post the solution that will hopefully help other facebook dev. noobies like me work it out. The very first step is to setup an app. For this you need to have a normal facebook profile and not a page account. IF you register just with a page style account facebook will still let you register as a developer, it will still let you enter your telephone number but once you get to the app section it will not give you the 'create app' button that you need - but facebook wont tell you that! And then you'll try to register a normal profile account and it wont let you re-enter that telephone number to register as a dev again - haha yes it's true! One you've visited the dev section of facebook and registered there (you need to enter your telephone number and they text you a code) then click 'create app'. Once you create the app you will get an 'App ID' and 'App Secret' - two long strings. Note those down and then use the script below to access the graph api: // First off you need to get an access token. This is done by sending a HTTP request to facebook. Facebook responds with a $_GET variable named $access_token . You can access this by parsing the $appToken result. $appToken = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id=APP_ID_GOES_HERE&client_secret=APP_SECRETE_GOES_HERE&grant_type=client_credentials'); // Use this function to retrieve the $_GET var. The variable name, as sent by FB, is called $access_token parse_str($appToken); //Now we've retrieved the access token we can make a call to the graph api for user data. In this instance we request id, name, feed. Requesting 'feed' retrieves status updates. It gets returned as Json $json_str = file_get_contents('https://graph.facebook.com/USER_PAGE_ID_GOES_HERE?fields=id,name,feed&access_token='.$access_token); //Decobe the json str which gives an array and then go nuts $data = json_decode($json_str); //var_dump($data); //print_r($data);
  18. Thanks Christian - as ever. I think I need to spend some time learning about building a class to inject the right resource based on requirement - altho that's quite a BIG topic to get to grips with. At least I am vaguely on the right track by passing the db con via the model constructor so that's reassuring .
  19. Hi guys Building a new application that is likely to grow in complexity over time. I therefore figured it would be perhaps wise to follow some mvc principles. The thing I am confused about is the how best to setup a mysqli db con I can reuse througout my models. Options one - have a base db class and pass in the object to the constructor of each model - thereby utilising one connection. option two - for each model setup new db connection but pass db credentials as constants via config file. or I am sure someone will recommend a better option yet. Any advice is welcome.
  20. Hi Guys Having my first unsuccessful trip into the world of facebook graph api (oh how i hate facebook). All I want to do is retrieve the facebook wall posts for a specified user. I created an app to get an access token and secret that part appears to be working as no errors are being returned. However when i try to pull the feed using the following line of code I get only the user ID back and nothing else: $json_str = file_get_contents('https://graph.facebook.com/100005065530030?fields=feed&access_token='.$access_token); If I replace ''feed' with 'name' I get the name so it's clearly working on one level. As I am woefully unfamiliar with facebook api I would very much appreciate if someone could give me a clue as to why this might be happening? Thanks, Drongo
  21. Hello Not entirely sure if this post should reside here but here goes... All I want to do is get a particular facebook page's public posts and display them on my website. Twitter does this easy enough by just requesting some xml - but facebook seems very complicated, mostly because most guides are outdated and I am not at all familiar with oAuth. I've tried to the following: https://graph.facebook.com/<page_id>/feed But this returns an error saying I need an acess token. This is where I am confused. Does anyone know preciesly what kind of access token I would need to achieve my simple task? And do I simply create this in the apps section of facebook? It would be very much appreciated if someone could point me in the right direction as I have a client breathing down my neck and no time to delve deeply into the fb documentation at this stage :/ Drongo
  22. Hi Crystal Something like this should point you in the right direction: <script> function removeText(){ var textArea = document.getElementById("text"); if(textArea.value == 'Please add your comment'){ textArea.value = ''; } } </script> <form> <textarea id="text" onfocus="removeText();">Please add your comment</textarea> </form> The onfocus event is useful for form elements. When the user clicks into the field (making it the focus) then the function will fire. Hope that helps. Drongo
  23. Thanks Christian As long as I know this is normal behaviour. Incidentally is 'bubble up' the technical term Drongo
  24. Yes but in the example if I click the div with ID '#popUp' the click function fires. But if I click the 'close' link, the click function also fires. This is the bit I don't understand. surely the click function should only fire when you click the div and not the link?
  25. Hi Is there supposed to be an attachment? You seem to be referring to something... Anyway you could probably achieve this by simply setting the checkbox and then in your php code do a check for it, e.g. $to = 'aidan@example.com' . ', '; // note the comma if(isset($_POST['ccEmail'])){ $to .= $_POST['userEmail']; Obviously you wouldn't directly use post variables in your code without validating and sanitising them but you get the idea. At least I think this is what you're after. Alternatively you could substitute the $to for a Bcc with an extra header: $headers .= 'Bcc: $_POST['userEMAIL'] . "\r\n"; All mail functions are explained here: http://php.net/manual/en/function.mail.php
×
×
  • 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.