Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Results return blank if over 480 lines

    Okay, so I have a problem I can't seem to solve. It's driving me a little crazy and perhaps its something so small I am just over-looking it.

    I am creating a small e-card system and I have a script that runs to remove people who want to opt-out of it. When someone adds up to 480 email addresses they want to send out, it works. If they add more than 480 it writes to the DB as blank.

    Here is the code below:

    index.php
    Code:
    function post_variables($action,$variables){
    			$ch = curl_init();
    			curl_setopt($ch, CURLOPT_VERBOSE, 1);
    			curl_setopt($ch, CURLOPT_URL, $action); //form action
    			curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
    			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    			curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    			curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    			curl_setopt($ch, CURLOPT_POST, 1);
    			curl_setopt($ch, CURLOPT_POSTFIELDS,$variables);//form variables
    			$result = curl_exec($ch); 
    			curl_close($ch);
    			return $result;
    		}
    
    $to_emails=post_variables("http://localhost/scripts/ecards/remove_opt_outs2.php","subject=Unclean Emails"."&email_list=".$to_emails."&sender_name=".$from_name."&sender_email=".$from_email."&email_subject=".$custom_greeting."&email_message=".$message."&image_name=".$images_web_location . $new_images[$id]."&image_url=".$target_url);
    remove_opt_outs2.php
    Code:
    //FUNCTION: GET TABLE DATA
    function get_table_data($database_connection,$sql_query){
    	//TABLE DATA
    	//get all of the data from the table and record it to an array with the keys recording the primary key and the field attributes - field name|primary key value|field type|field length eg. title|13|text|128
    	$all_data_array=array();
    	$query_result=mysql_query($sql_query,$database_connection);
    	while($query_row=mysql_fetch_row($query_result)){
    		for($d=0;$d<sizeof($query_row);$d++){		
    			//define the array
    			if(!isset($all_data_array[mysql_field_name($query_result,$d)])){
    				$all_data_array[mysql_field_name($query_result,$d)]=array();
    			}
    			//add the item's attribute to the attributes array
    			$all_data_array[mysql_field_name($query_result,$d)][sizeof($all_data_array[mysql_field_name($query_result,$d)])]=$query_row[$d];			
    			
    		}
    	}
    	return $all_data_array;
    }
    
    function post_variables($action,$variables){
    	$ch = curl_init();
    	curl_setopt($ch, CURLOPT_VERBOSE, 1);
    	curl_setopt($ch, CURLOPT_URL, $action); //form action
    	curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
    	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    	curl_setopt($ch, CURLOPT_POST, 1);
    	curl_setopt($ch, CURLOPT_POSTFIELDS,$variables);//form variables
    	$result = curl_exec($ch); 
    	curl_close($ch);
    	return $result;
    }
    
    if(isset($_POST["email_list"])){
    	$email_list=explode(",",$_POST["email_list"]);
    	
    	//Loop through every email address
    	for($a=0;$a<sizeof($email_list);$a++){
    	
    		get_table_data($database_connection,"SELECT email_address FROM `opt_outs` WHERE email_address='".$email_list[$a]."'");
    		//If this email address has been opted out, add it to the unclean list
    		if(mysql_affected_rows()>0){
    			$unclean_email_list[]=$email_list[$a];
    		}
    		//Otherwise add it to the clean list
    		else{
    			$clean_email_list[]=$email_list[$a];
    		}
    	}
    //Record the ecard details
    	if(isset($clean_email_list)){
    		$included_recipients=sizeof($clean_email_list);
    	}else{
    		$included_recipients=0;
    	}
    	//Number of recipients who had previously opted out
    	if(isset($unclean_email_list)){
    		$excluded_recipients=sizeof($unclean_email_list);
    	}else{
    		$excluded_recipients=0;
    	}
    print implode(  ", ", $clean_email_list );
    	
    	//Email the ecard details
    	post_variables("http://localhost/scripts/ecards/email_ecard_details.php",$ecard_info."&email_message=".$_POST["email_message"]."&recipient_email_addresses=".implode( ", ", $clean_email_list ));
    	
    }
    One more thing that throws me for a loop, at the bottom of the opt_out page have it email me the information that is sent. In that email I see all the addresses added, even over 480, but when it writes to the DB it comes up blank. Even if I put echo $to_emails right after $to_emails=post_variables(... it still shows up blank if the email list exceeds 480 emails.

    Can someone help?

    Thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Might be a limitation of CURL. You can add a loop to limit the amount of data you send to your post_variables call, to, send only, say, 100 emails at a time, that should fix the problem.

  • #3
    New Coder
    Join Date
    Nov 2009
    Posts
    25
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    Might be a limitation of CURL. You can add a loop to limit the amount of data you send to your post_variables call, to, send only, say, 100 emails at a time, that should fix the problem.
    Perhaps.

    I have not changed any of the code and now all of a sudden it's capping out at ~450. After that it loses all the info.

    Is this a time issue or something? The process itself only takes a couple seconds on my end...

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Quote Originally Posted by jboku View Post
    Perhaps.

    I have not changed any of the code and now all of a sudden it's capping out at ~450. After that it loses all the info.

    Is this a time issue or something? The process itself only takes a couple seconds on my end...
    If my theory is correct, it's going to be a limit on how much data CURL can process, so the number of emails depends on how many bytes are in each email address.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •