# \[PHP\] random password acting wierd

**URL:** https://forum.kirupa.com/t/php-random-password-acting-wierd/222612
**Category:** programming
**Created:** [April 15, 2007, 10:25am UTC](https://forum.kirupa.com/t/php-random-password-acting-wierd/222612 "2007-04-15T10:25:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![danulf](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/danulf/32/555_2.png) [@danulf](https://forum.kirupa.com/u/danulf)
#### Post date: [April 15, 2007, 10:25am UTC](https://forum.kirupa.com/t/php-random-password-acting-wierd/222612/1 "2007-04-15T10:25:17Z")

</div>

I have this line to make a random password based on the current time, encrypted with the md5 encryption, shortened to 6 characters.

```php
$randompass = substr(md5(time()),0,6);

```

If I echo $randompass everything looks good (it shows 46d520), but if I insert the password into a MySQL database it get odd. I get this:  
 ![](http://img120.imageshack.us/img120/272/randompasspc7.gif)  
I don’t know what the star means, but it must be that all isn’t shown or something, because that password (star or not) doesn’t work either :-/
