Giter VIP home page Giter VIP logo

Comments (3)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
The line

   if (is_email($email)) echo "$email is a valid email address";

appears to be OK. It should do what you expect. I can't comment on the rest of 
the code.

As a general suggestion, have you tried setting


    error_reporting(E_ALL | E_STRICT);
    ini_set('display_errors', '1');

At the top of your script?

Original comment by [email protected] on 19 Oct 2010 at 4:15

  • Changed state: Invalid
  • Added labels: Priority-Low, Type-Other
  • Removed labels: Priority-Medium, Type-Defect

from isemail.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
The line

 if (is_email($email)) echo "$email is a valid email address";

Was taken directly from your sample code.  

At the top of the page, the line

include('../blahblahblah/customers.php'); 

Is where I keep the connection file.  I changed this for security purposes.

I changed the code from:

if (is_email($email)) echo "$email is a valid email address";

to:

if (is_email($email)) { echo "$email is a valid email address";
 }
else {
    echo 'The email address '. $email.' is not valid';
  }

When I run this page, it takes about 2 seconds to run.  There are at least 
10,000 emails in this query.  Is that a realistic thing to have happen ?

If so, how can I update my column ( valid ) with the results of your validator ?

Also, I added the code:

error_reporting(E_ALL | E_STRICT);
    ini_set('display_errors', '1');

to the top of my file, however, no errors occur when running this.

Once complete, I will be happy to post a working version of this so that 
everyone can benefit from it.



Original comment by [email protected] on 19 Oct 2010 at 4:36

from isemail.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
I was able to get this project to work, and below is the code that I used.
BTW, I changed the column name, ( valid ) to ( valid_syntax), just to make 
things easier to understand.  Thanks again for your assistance and hopefully 
someone can make some use of this & maybe even improve upon it.

<?php 
include('../blahblahblah/customers.php'); 
require_once('../is_email/is_email.php');

error_reporting(E_ALL | E_STRICT);
   ini_set('display_errors', '1');

$conn = mysql_connect($dbhost, $dbuser, $dbpass, $dbname);
if (mysql_error()) {
printf("Connect failed: %s\n",mysql_error());
exit ();
}
mysql_select_db($dbname);
if (mysql_error()) {
printf("Connect to database failed: %s\n",mysql_error());
exit ();
}

/* If connection to database, run sql statement. */
if ($conn)
{   
$query = sprintf("SELECT id,valid_syntax,email FROM prospects");

// Perform Query
$result = mysql_query($query);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for 
debugging.
if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { 
 //printf ("ID: %s  Email: %s", $row[0], $row["email"]);

 $email= $row["email"];
 $valid= $row["valid_syntax"];
 $record_id = $row["id"];

 if (is_email($email)) { echo "$email is a valid email address";

mysql_query("UPDATE prospects SET valid_syntax = 'Y' WHERE id = '$record_id'") 
or die(mysql_error());
    }
else {
    echo 'The email address '. $email.' is not valid';
    echo "<font color='red'>NOT A GOOD EMAIL ADDRESS !!! </font>"; 

mysql_query("UPDATE prospects SET valid_syntax = 'N' WHERE id = 
'$record_id'")or die(mysql_error());
  }
}
echo ("Complete");

// Free the resources associated with the result set

mysql_free_result($result);
mysql_close($conn);
}
?>


This, I am sure is not perhaps the best way to get the job done, but it 
certainly did update my database with the correct inforamation.



Original comment by [email protected] on 19 Oct 2010 at 9:01

from isemail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.