Jump to content

Recommended Posts

Hey guys,

 

my function is not working:

function getmd5($code){
    include("connect.php");
    $code = $code;
    $query = sprintf("SELECT decipher_code FROM codes WHERE md5_code = '%s'", mysql_real_escape_string($code));
    $numrows = mysql_num_rows(mysql_query($query));
    $result = mysql_query($query);
    if($numrows = 1){
        while(mysql_fetch_assoc($result)){
            return $row['decipher_code'];
        }
    }else{
        return false;
    }
}

 

For some reason its not returning anything

 

here are the mysql dumps:

-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 25, 2010 at 08:02 AM
-- Server version: 5.1.41
-- PHP Version: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `decipher`
--

-- --------------------------------------------------------

--
-- Table structure for table `codes`
--

CREATE TABLE IF NOT EXISTS `codes` (
  `code_id` int(11) NOT NULL AUTO_INCREMENT,
  `md5_code` varchar(32) NOT NULL,
  `decipher_code` varchar(200) NOT NULL,
  PRIMARY KEY (`code_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

--
-- Dumping data for table `codes`
--

INSERT INTO `codes` (`code_id`, `md5_code`, `decipher_code`) VALUES
(1, 'dc639d6429d2b9bf1eb47fb241c2dbe5', '²y;#"Rz«–é*¿-þdÕ§…8îo°àͦvæÏòÄýCWÅP)·ÇGh?»+$ÜÛT¡^6Øô2AV'),
(2, '146af588a5ef0bc04a53870b474fa85a', 'VgéÄ,êR@–Óe¢D¤¿×¥jBã Yá¼füÒ\\àq¹3™€¨°èZAùô<ÃS~*¦¦kä|+ÏEñ'),
(3, 'b197cfa5068c629bcc9e39abb8802a29', '«~$÷\\QÌ°·¨¬ó½ýµßÍãy³®¶r±{©Éçü)§\\xìñk\\¥`ò,w=iSÆP*h©DoÞ…F'),
(4, '384bb45c3cce0a8256b62c88476db549', '%RÑ-)¦¤ðÐ#×ãLçlNèý7Iµ¿UÌFÕà÷å&£ó?߯ÿ¶0,3XÇÚíDÎkQ2˜[þ ȸ'),
(5, '532e3fe9997a27ca8917a7240bb2dfa7', '¨Ø±¦1IÿM£¶,í÷v͸ü#Q¤N¥€hfå(´B[rÌ ñlWA2µ?\\Üdû@óÄi=Ãéß'),
(6, 'dd180ec755d4f07bedd2e3d6558e122d', 'k¤Ò>ù$ÔÌÇV´Ö¢°2`óØG«{]ë®lO݈"ÐÁu—R–Í|QYÜSÿÓ©¹7øN…ª(xúdi'),
(7, '61f4618bf4af0b1b00e7c091c22060bc', 'Ömü©èO¼Úìô:©øÑ«ÏçBíd*öy¬é?;T¥JûÅ2ÍSÝX=–5na0vÔ.R¸È@ªKÞ˜Ü'),
(8, 'cf178ef5c5dbfe85e6ac078b206e1c28', 'öpu>DÊîlØG9e–íñ)tÙªMÚF3 $y#\\ˆ×ç «n®[*`ü¾Ü8³Âd}Em€úƶ¼ð´'),
(9, '39afd367b1603a8c46e84af25b64216d', '¼Ì¤5ÜÇÉQBO|\\¾æÂðH¦1ìßµn)¦iRù}—׿ÃJ3&%°è€^ø÷ä»ö6î2[4ësFÙ'),
(10, 'e59807215ca555a0078c6242d7c0a216', '<V¸¼ì|?å˜b,@íÎ~¾¦û)Eã½fÃ+ó¹KiÔ¦ä¥ù§µïð={_1w¨jz°N#±%Læ2Ì'),
(11, '231d3ad7add92ebe4ac9231b72d47dbc', ';åÁöHªwâa®Î ÚóÖñ]£Õä¯Ã2}k^PëõÏsØF4ûÆé3bGz+|xìÈð©¤{=n¼¢u'),
(12, '156077e5e43012400da2fbccdca6ce00', 'd,1Kêg8¼EíÁ÷u¬l¡}ÌÒa`î=WQA2RsµG˜àÖ*£ýqP-Ç9ÉTÄc´CnjYìÚëØ'),
(13, '46d468c2af0af93a979938f7d0f04af9', '&¿<ª7²4ÐèĵËJìSåÚLeUÝÒoÃdá´çúÊ:N_Ìm·lø>VÇÜnfíô€ü+#ëW}û¦'),
(14, 'e7a10f40712dc3f9c96c9143aaa45b19', ' 4;ß*îK¯¸ÎhÝ·"7~À]Uü.Ñf嬡´¿ÐÈÆd¢a˜3ÔíÕ±ñú™Á&^w¦v÷G6àÙp');

 

Thanks

 

Jragon

Well, first off you're not defining $row in the loop, but that doesn't even matter because you don't need a loop if there's only going to be at max 1 result returned.

 

function getmd5($code){
    include("connect.php");
    $code = $code;
    $query = sprintf("SELECT decipher_code FROM codes WHERE md5_code = '%s'", mysql_real_escape_string($code));
    $numrows = mysql_num_rows(mysql_query($query));
    $result = mysql_query($query);
    if($numrows = 1){
        return mysql_fetch_assoc($result);
    }else{
        return false;
    }
}

Its now giving me a new error with this function:

function cryptc($code, $string, $type){
    if($type == 'decrypt'){
        if(getmd5($code) != false){
        $string = $string;
        $code = $code;
        $replace = strget('abc', 'decrypt', $code);
        $find = strget(getmd5($code), ' ', $code);
        $result = strtr($string, $find, $replace);
        return $result;
        }else{
            return 'Sorry your code dose not exist.';
        }
    }else{
        include("connect.php");
        $find = strget('abc', 'encrypt', ' ');
        $replace = randstr(79);
        $md5 = md5($replace);
        $query = sprintf("INSERT INTO codes (code_id, md5_code, decipher_code, abc_code) VALUES('%s', '%s', '%s', '%s')", mysql_real_escape_string(''), mysql_real_escape_string($md5), mysql_real_escape_string($replace), mysql_real_escape_string($find));
        mysql_query($query);
        $result = strtr($string, $find, $replace);
        return 'Here is your result:<br />' . $result . '<br />Here is you code to decrypt it:<br />' . $md5;
    }
}

 

Heres my error:

Warning: strtr() expects parameter 3 to be string, array given in C:\xampp\htdocs\makecode\includes\inlude.php on line 36

 

also heres my strget function:

function  strget($option, $option2, $code){
    if($option == 'abc'){
        if($option2 == 'encrypt'){
            $string = str_shuffle('q1w2e3r4t5y6u7i8o9p0a-s=d!f"g£h\$j/k<lzxc\>vb`n¬m¦QWERTYUIOPASDFGHJKLZXCVBNM ,.');
            return $string;
        }else{
            $query = sprintf("SELECT abc_code FROM codes WHERE md5_code = '%s'", mysql_real_escape_string($code));
            $numrows = mysql_num_rows(mysql_query($query));
            $result = mysql_query($query);
            if($numrows == 1){
                return mysql_fetch_assoc($result);
            }else{
                return die('Sorry that code dose not exist');
            }
        }
    }else{
        $string = $option;
        return $string;
    }
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.