WordPress.org

Forums

Mail Subscribe List
Bug (3 posts)

  1. trajektorijus
    Member
    Posted 1 year ago #

    Hi, after submission i receive a Warning "mysql_num_rows() expects parameter 1 to be resource boolean given" on line 273 at sml.php.

  2. trajektorijus
    Member
    Posted 1 year ago #

    Here's my approach:

    // Handle form Post
    if ($_POST['sml_subscribe']) {
    $name = $_POST['sml_name'];
    $email = $_POST['sml_email'];
    if (is_email($email)) {

    $exists = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."sml WHERE sml_email LIKE '".$wpdb->escape($email)."'");

    if (count($exists) < 1) {
    $wpdb->query("insert into ".$wpdb->prefix."sml (sml_name, sml_email) values ('".$wpdb->escape($name)."', '".$wpdb->escape($email)."')");
    }
    }
    }

  3. vitalik1921
    Member
    Posted 1 year ago #

    Use:

    if ($_POST['sml_subscribe']) {
    	$name = $_POST['sml_name'];
    	$email = $_POST['sml_email'];
    	if (is_email($email)) {
    
    		$count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."sml where sml_email like '".$wpdb->escape($email)."' limit 1");
    		if ($count <1) {
    			$wpdb->query("insert into ".$wpdb->prefix."sml (sml_name, sml_email) values ('".$wpdb->escape($name)."', '".$wpdb->escape($email)."')");
    		}
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.