Jump to content


gizmola

Member Since 06 May 2003
Offline Last Active May 14 2017 11:43 PM

Posts I've Made

In Topic: URL rewriting replace %20 signs with - to make seo friendly url

05 April 2017 - 10:05 PM

Usually to avoid this type of problem, people proactively create slugs/permalinks for their entries.  It gets around the first issue you are facing, but also gets around the issue of insuring that there aren't multiple posts with the same title.  If that were to happen, you have to realize that one of the posts would essentially be orphaned because you would not have a way of getting to it through the system.  Sometimes people will just append a number at the beginning or end of the slug that insures it will be unique.  An easy way to do it is to prepend the internal ID number for the item.

 

Our forum software is an example:  https://forums.phpfr...o-friendly-url/

 

 

As you can see, it has the advantage of correctly handling a situation where the actual title (as in your case) actually includes reference to a url parameter.  Any rule would be confused by that, if you just blindly url decode or do a search/replace looking for url encoded spaces.

 

Or another way to do it is to use a seperate ID parameter. This is what Stackoverflow does, for example:  http://stackoverflow...sses-using-jaxb

 

My advice is to use one of these schemes which are tried and true, and at that point, your rewrite is simpler and more robust because you are controlling your url's rather than trying to deal with all the things people could put into a title and having to deal with the using spaces, url parameter characters or even dashes, which would become an issue.  You are retrieving articles by the slug/permalink rather than the title.  There are very few drawbacks other than what to do if people want to edit the title of an existing article.  In many cases it is best not to change the slugline after article creation, within a small window in case your site has been crawled by a search engine.  You don't want to risk losing a search engine placement with an editted post, because you found a small typo and fixed it.


In Topic: PDO or MySQLi?

05 April 2017 - 05:42 AM

I agree with the things stated.  PDO is just better designed and easier to use.  If I use an ORM it's typically Doctrine2, and that depends and loosely wraps PDO.  AFAIK, laravel's db abstraction also depends on PDO.


In Topic: Need Help with Php Arrays

30 March 2017 - 10:04 PM

Thanks Gizmola for your response, like I mentioned that I am new to this Web Service and unfortunately I had to do this urgently. From your explaination I started thinking that perhaps the problem is with the JSON Results from the web service I am trying to consume this from, Now, perhaps if I post the the results as they are and the code I am trying to display the fields from these results, perhaps you guys may be able to help me because I struggled with this the whole of yesterday. Here below are the JSON Results followed by the actual code to display fields:

 

 

I stated that specifically I thought.  2 Json blocks returned rather than one.  You can work around it as per Requinix's code, or even more complicated code, but the fact of the matter is, that you shouldn't have to.  Is this webservice something internal or related to the project?  I would be asking them wtf they are returning 2 blocks of json instead of one!  Working around something stupid like this should be a last resort.


In Topic: Create isJediEnabled() and getJediKeypair() method

28 March 2017 - 12:46 AM

function isJediEnabled($something)
{
   if ($something) {
       return true;
   } else {
       return false;
   } 
}

function getJediKeyPair()
{
    return 'Keypair';
}
Feel free to PayPal me some cash for the help. If this isn't what you are looking for we need some actual details in regards to what these functions are actually suppossed to do. For example, in regards to a 'Keypair' then you're talking about a private key and a public key. Why you would have a function that returns a 'Keypair' doesn't make a whole lot of sense without some background as to what you are trying to do and why. We aren't mind readers.

Show us some code you've been working on!

In Topic: Php Variable Posting to Another Php Code Which Is at Different Directory

27 March 2017 - 10:21 PM

Look at these manual pages:

http://php.net/manua...iables.argv.php

http://php.net/manua...tion.getopt.php