Thank you Very Much laserlight for your replies and help..
I seem to be a little closer....
adding the + in this line seems to do nothing:
$urlsplit = preg_split("/\r+/", $domain);
VERSES
$urlsplit = preg_split("/\r/", $domain);
However; The other code you provided does basically work for checking for duplicates so the most I can have is one blank record in the table as it is then seen as a duplicate, etc..
As of now if the domains are entered (typed) into the form feild it all seems to work fine, however if they are copied and pasted from a text file they do not catch the blank records or sometimes even duplicate entries..
Is there perhaps another format that may work better or atleast worth a try ??
Current code now is:
<?php
require('config.php');
$urlsplit = preg_split("/\r/", $domain);
foreach ($urlsplit as $key => $value) {
$query = mysql_query("SELECT domain FROM usersdomains WHERE domain='$value'");
if (mysql_num_rows($query) > 0)
unset($urlsplit[$key]);
}
$a = count($urlsplit);
sort($urlsplit);
$sql = "SELECT domain FROM usersdomains";
$res = mysql_query($sql);
$i = 0;
while ($a > $i) {
$sqlquery = "INSERT INTO usersdomains (sellerid, domain, category, takeoffers, price, website) VALUES ('$sellerid', '$urlsplit[$i]', '$category', '$takeoffers', '$price', '$website') ";
$result = mysql_query($sqlquery);
$i++;
}
if ($result) {
print "<b><font color=red>$a</font> Domains Have been Successfully Added</b><br><br><br>";
print "<b><a href='javascript:history.go(-1)'>Add More Domains</a></b><br><br>";
} else {
print "<b>Domains NOT Added. Please Report This Error <br>";
echo mysql_error();
}
?>
Would perhaps having a error when duplicates or blank rows that forces the user to go back and fix be better and a more sure way ??
Any additional help would really be appreciated...