TySkby 41 Junior Poster

I'm a hobbyist-gone-pro, and I can share some of the feelings of intimidation when it comes to learning concepts like OOP, MVC, and new frameworks.

I'd advocate for the approach where you do it yourself (at least the first time), especially with an MVC approach. It's incredibly valuable to be able to understand how classes and methods work, and for me, the best way to do that was to do it without a framework. It helped me learn the basics by building off my existing knowledge.

Once I had that under my belt, I went ahead and started learning how to use some of the frameworks. I'm glad I did because it really does speed up development in many cases. As always, pick the best tool for the job, but considering a framework as a potential tool can be very helpful.

If you're new to the whole framework thing, I'd suggest starting with CodeIgniter. It's a lot like CakePHP, but much more flexible when it comes to doing things that aren't strictly "The Framework Way". Don't get me wrong- Cake is good too, but I think as a beginner's framework (and a pro's), CodeIgniter is definitely the way to go.

TySkby 41 Junior Poster

MySQLi (MySQL Improved) is a PHP driver for MySQL databases that offers functionality more commonly desired in Object-Oriented programming. It may be useful if you are using Object-Oriented PHP (OOPHP), but for smaller stuff it's mostly a matter of preference. The developers of PHP seem to recommend the MySQLi driver over the "regular" MySQL driver.

In terms of frameworks, I would suggest you start by learning something like CodeIgniter. It's fairly easy to get the hang of if you're looking to develop OOPHP applications and allows for a lot of flexibility in how you do things (like how you can use a MySQL database). Like any other framework, it's not for every job, but it's a good one for MVC (Model-View-Controller) applications.

Zend is another commonly used framework that is part of many PHP installations by default.

PEAR also comes with many PHP installations. It offers functionality common to many PHP applications and is a really useful tool to have on your belt. PEAR can be used alongside/with other PHP frameworks.

Another framework that I haven't personally used a lot is CakePHP. Some argue that it requires a bit more discipline and advanced knowledge of PHP since it can be stricter than something like CodeIgniter, but it is another example of a very good MVC framework for PHP.

Hope that gives you some extra useful knowledge. I'd recommend researching and reading about this stuff to give you a more in-depth understanding …

cereal commented: well explained +7
TySkby 41 Junior Poster

If I'm reading this correctly, you have been able to split the string variable $str into an array. Assuming you have named the new array $str_array, you could do something like this:

-Iterate through the array and for each value in $str_array, use strlen() to count the number of characters in the current value
-Compare it to the existing longest value (we'll call it $longest). If it is larger, check if it's in the $area array.
-If it is, replace the value of $longest to be the value of the current iteration.

With this method, you'd come out with something similar to the following code:

//Set the $longest variable to be an empty string for now
$longest = '';

//Iterate through $str_array with the current iteration set to $value
foreach($str_array as $value)
{
	//Get the length of $value
	$length_value = strlen($value);
	//Get the length of $longest
	$length_longest = strlen($longest);
	
	//Compare the lengths
	if ($length_value > $length_longest)
	{
		//$value has more characters than $longest, so check if it is in $area
		if (in_array($value, $area))
		{
			//$value is a value of $area array, so make it the new value for $longest
			$longest = $value;
		}
	}
}

At the end of this loop, $longest will be equal to the longest word that exists in both $str_array and $area arrays.

Obviously this could be shortened down to be more efficient and such (and I would encourage you to do that), but I figured it would help more people …

asif49 commented: Offered great help! +3
TySkby 41 Junior Poster

I know this is marked as solved but I've done this before and wanted to add my two cents if I may.

I have a custom CMS that does this, and here is my process, which I feel is pretty simple, as all images can be in the same directory:
1. Save the original file name to a variable ($name)
2. Generate a unique name to replace the file. I used rand() as part of a loop that checks the database to make sure the random number isn't already in use. If the loop finds a match, it starts over again with a new rand().
3. When you've got your unique random number, rename the file with that number and save it to your preferred directory.
4. Save the original file name ($name) to your database together with the new file name.
5. For display purposes, you can use the original file name (like "kitchen.jpg") so the user can identify the image. But in your business logic, you actually only use "kitchen.jpg" for display- file management uses the random file name generated above.

Hope that helps someone!

karthik_ppts commented: Thanks for sharing +5
TySkby 41 Junior Poster

There are lots of ways to do this, but here's a relatively simple example. Maybe others can chip in a few other ways of doing this.


1. Create a new nullable column in MySQL 'profiles' table (maybe call it 'reset_token')
2. If a user needs a password reset, give them a form to type their email address and hit 'submit'.
3. When the form is submitted, generate a random unique value for 'reset_token' and save it to that user's row in MySQL. Then send an email with the 'reset token' value to the user and a link that takes them to a password reset page.
4. On the password reset page, have a form for the user to type their email address, their provided reset token, and a new password.
5. When that form is submitted, check to see that the reset token matches with the email address in the 'profiles' table. If it does, md5() encrypt the new password and replace the old encrypted password with the new one.

almostbob commented: like it +13
TySkby 41 Junior Poster

Hello there, and welcome to DaniWeb.

I'm not a moderator or anything other than a regular old poster here, but I can tell you that two things will not get you the help you are looking for:

1. Requesting things to be made for you. As I understand it, this forum is for people who are looking for help and/or advice concerning their code/configurations/errors, etc.

2. Spamming the forum by making one thread and then making the exact same one a bit later with the word 'URGENT!!!!!!'.


I'm not trying to be a jerk here- this is just my understanding. And my perception is that you are requesting that contributors to this forum 'make code' for you, and that you demand it be done quickly (lest you create a new thread insisting you receive help sooner). Having urgent projects that require immediate assistance is why people hire programmers, or extra programmers. And if you're looking for a pre-made script, then that's what search engines are for.


However, I for one would be quite happy to assist you if you could provide some code that you are having issues with and needed help looking it over, or had a question about a concept or methodology. If you're asking about pre-made scripts, maybe you have a list of certain possibles and would like some help deciding which one to use?

TySkby 41 Junior Poster

Sorry that this is not completely specific to your problem, but since you said "Unfortunately, it's the regex I've been struggling with. I trying to do this
'a_key'(whitespace)=>(whitespace)'(content_to_replace)' for it, but I'm going around in circles."

Might I suggest something like Regex Buddy? Regex always hurts my head, and I find that the tool is something that reduces that from the level of a nasty migraine to a run-of-the-mill headache.

Only problem is that it's not free. So you may want to check out this thread for some alternatives.

diafol commented: Good links - cheers +13