Alphanumeric Output into MySQL Database

Discussion in 'PHP' started by nonexistentera12, Sep 18, 2008.

  1. #1
    Hello.
    I have the script below that creates a list of random alphanumeric combinations.
    
    include('db_connect.inc.php');
    function md5this($length,$limit){
    	while ($length<$limit){
    		set_time_limit(0);
    		$charset = "abcdefghijklmnopqrstuvwxyz0123456789";
    		// Do not edit beyond this point!
    
    		for($i=0;$i<strlen($charset);$i++)
    			$x[]=$charset[$i];
    			for($i=0,$z="",$e="echo ";$i<$length;$i++){
    	 		   	$z.="foreach(\$x as \$y[$i])"; 
    				$e.="\$y[$i].";
    				
    			}
    			$evalinsert = eval($z.$e."\"<br />\";");
    
    
    		$length++;
    	}
    }
    
    mysql_query("INSERT INTO `md5Sums` (
    			`id` ,
    			`anValue`,
    			`md5Sum`
    			)
    			VALUES (
    			NULL , '$evalinsert', '".md5($evalinsert)."'
    			);") or die(mysql_error());
    
    
    Code (markup):
    I know that it is connecting to the database and inserting data, but not the data that it is producing in my browser. It inserts a blank for anValue and a random hash for the md5Sum.:confused:
    Is there any one that knows what I should do, or how to rewrite the script to allow it as an array.

    Script output is http://tylerperroux.com/md5.php

    Any help is much appreciated.
    Thank you an advance.
     
    nonexistentera12, Sep 18, 2008 IP
  2. ClickMedia

    ClickMedia Banned

    Messages:
    104
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Now the scope for $evalinsert is only inside the function "md5this" .So use $evalinsert as global and try .
     
    ClickMedia, Sep 18, 2008 IP
  3. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Where are you call the function md5this?
    Why it not returning any value?
     
    webrickco, Sep 19, 2008 IP
  4. nonexistentera12

    nonexistentera12 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the fast response. Never got anything from PHPFreaks. Thank you
    Sorry for that.
    It is called by md5this(1,3)

    And just to be sure is this how you set a global variable.
    $GLOBALS['$evalinsert'];

    Just not sure. I have never had to set any globals.
    Thanks you
     
    nonexistentera12, Sep 19, 2008 IP
  5. nonexistentera12

    nonexistentera12 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Im still getting just one entry per script run, but the script is outputing more than just that.
     
    nonexistentera12, Sep 20, 2008 IP