RE: [PHP-DB] insert (database)
| From: | Bastien Koert | Date: | Wed, 02 Feb 2005 14:09:12 +0000 |
| Subject: | RE: [PHP-DB] insert (database) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38426@lists.php.net to get a copy of this message | ||
try
if (mysql_num_rows($res)>0) {
echo "<b>Your email: <u>$v</u> already in the list<br>";
}
else {
$sql_in = "INSERT INTO arcadia ('email') VALUES ('$v')";
$result_in = mysql_query($sql_in);
echo "<b>Your email: <u>$v</u> subscribed!<br>";
}
}
else {
include("index.php");
exit;
}
bastien
From: Yemi Obembe <fickledreams@yahoo.com> To: php-db@lists.php.net Subject: [PHP-DB] insert (database) Date: Wed, 2 Feb 2005 01:23:16 -0800 (PST) the objective of the script below is to first search if a subscriber is already in a list before subscribing his email (so as to prevent double subscription). the select part works fine....but the insert doesnt. know why? if ($v = strtolower($_POST['email'])) { $db = mysql_connect(mysql, "usser", "pw"); $con = mysql_select_db("ng",$db); $sql = "SELECT * FROM mytable WHERE email='$v'"; $res = mysql_query( $sql ) ; if ($row = mysql_fetch_array($res)) { echo "<b>Your email: <u>$v</u> already in the list<br>"; } else { $sql_in = "INSERT INTO arcadia ('email') VALUES ('$v')"; $result_in = mysql_query($sql_in); echo "<b>Your email: <u>$v</u> subscribed!<br>"; } } else { include("index.php"); exit; } --------------------------------- A passion till tomorrow, Opeyemi Obembe | ng.clawz.com --------------------------------- Do you Yahoo!? Yahoo! Search presents - Jib Jab's 'Second Term'