Ive written this basic little tool, that I use whenever I need to alter md5 hashed passwords directly into my mysql databases or flat files.
Check it out it may come in handy.
Ok so its time for some more PHP tips.
Stripping characters from a string
If you want to strip certain characters from a string you can do so like this.
$string='I-need-to-get-rid-of-the-dashes';
$string=str_replace("-"," ",$string);
//result is - I need to get rid of the dashes
Here is another tid-bit. Splitting text. If you want to split a paragraph, you can use the following!
$string='This sentence has many words but i want to restrict it to only five.';
$string=implode(" ", array_slice(preg_split("/\s+/", $string), 0, 5));
//result is - This sentence has many words
You can also go a little further and split a paragraph or sentence in the middle. Missing the beginning and end and only using the middle part. See below.
$string='This sentence has many words but i want to restrict it to only five.';
$string=implode(" ", array_slice(preg_split("/\s+/", $string), 3, 5));
//result is - many words but i want
Easy enough! Just a little but they’re gems
Ok ive been over and over this the last few hours and it totally drove me friggn nuts. But finally got it working, so for anyone who has a similar problem and they cant delete rows in mysql with a php statement, this may help you. See below.
I did have this:
$sql="DELETE FROM images WHERE id=$id";
but changed it to this:
$sql=mysql_query("DELETE FROM images WHERE id=$id");
And it worked!
