I have these value save in the MySQL table using PHP.
doug%2B
and this below,
doug%252B75ogud%252B
how do you convert those into normal string? using PHP how?
What command should i use.
Thank you.
| SitePoint Sponsor |
I have these value save in the MySQL table using PHP.
doug%2B
and this below,
doug%252B75ogud%252B
how do you convert those into normal string? using PHP how?
What command should i use.
Thank you.
anyone can decode those?
thanks in advance.



I already tried it and this is what i get,
doug+
doug%2B75ogud%2B
The + sign and %2B is not part of the string.
If decoded properly it suppose to show like these below,
doug
doug75ogud
Anyone can decode these properly?
Thank you.


How exactly you have gotten this kind of strings?
actually the value 'doug%2B' is the firstname it came from a form,
here is the codes,
and then the username 'doug%252B75ogud%252B' is came from a function formula,Code:$objPaypal-> lastName = urlencode($_POST['lastname']); $objPaypal-> lastName = strtolower($objPaypal->lastName); $objPaypal-> lastName = urlencode($objPaypal->lastName);
here is the codes for that,
Code:function createUser() { //fetch username $userFirst = $this->firstName; //create random user $userNumber = rand(10, 99); //fetch lastname then randomize. $userLast = str_shuffle($userFirst); //concantenate them. $tmpUserName = $userFirst . $userNumber . $userLast; $this->userName = urlencode($tmpUserName); //fetch from member table the username $query = "SELECT username FROM member WHERE username='$tmpUserName'"; $result = mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); $row = mysql_fetch_array($result); $dbUserName = $row['username']; if($dbUserName == $this->userName) { //this function again. $this->createUser(); } else { //store username into variable $this->userName = urlencode($tmpUserName); } }
Thanks in advance.
okay lets assume i already remove the 2nd urlencode.
how about the 2nd codes for the username?
thanks.


This function creates unique username based on user input right? And then compares the created temporary username to usernames in database. If it does not exist it puts it in variable and if it exists it runs again the random username creation process. So if I got it right the user input from the form is first urlencoded (this could be undone) but after str_shuffle I don't think that can be anymore decoded anyhow.


In the last example there is the firstname/username, random number, and finally the firstname/username run through str_shuffle. It is very likely your double urldecode messed it up for you to understand.PHP Code:$str = 'doug%252B75ogud%252B';
$str = urldecode($str); // prints 'doug%2B75ogud%2B'
var_dump($str); // prints 'doug%2B75ogud%2B'
$str = urldecode($str);
var_dump($str); // prints 'doug+75ogud+'
$str = str_replace('+', ' ', $str);
var_dump($str); // prints 'doug 75ogud '
Bookmarks