Comments (3)
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.
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.
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)
- AAAA records? HOT 1
- Small corrections in is_email_statustext.php HOT 8
- TLD "invalid" + domainname check + IDNs? HOT 5
- Java: Unicode hostnames causes crash HOT 1
- (PHP) Optional: Make warning tests optional HOT 3
- Empty quoted strings HOT 2
- Double dash in local part HOT 1
- Quoted pair in local part counts as a single character for length calculation HOT 1
- Comments around address literal HOT 2
- Forms marked "obsolete" by the RFCs should raise warning HOT 1
- Folding White Space before and after the @ sign
- Test dns-check and non-dns-check data separately
- tests_beta.xml fails in Java package
- Value throws an exception when running IsEMail.is_email_verbose(email, true) HOT 1
- Out of Range Exception thrown in C# validate function when entire sub domain section is in parens HOT 5
- Patch for /PHP/trunk/test/tests.xml HOT 3
- the email like xxxx@xxx,is it a right email? HOT 1
- Invalid email adress passed off as valid
- Invalid domain (with ampersand) validates OK, not even warning data in ResultInfo in C#
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isemail.