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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter trajektorijus

    (@trajektorijus)

    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).”‘)”);
    }
    }
    }

    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)."')");
    		}
    	}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug’ is closed to new replies.