dun want to have the same email address..how?
Moderator: General Moderators
dun want to have the same email address..how?
hi, I got some problem in my php.
I dun want to have the same e-mail address in my guestbook.
So i create the error...
$error = "select email from guestbook where email = ('".$email."');";
if (!$error)
(
echo 'Error: Email address already exist.';
exit;
}
but this is not working. When i run in the localhost, the got error come our like this..
Parse error: parse error, unexpected T_ECHO in C:\Program Files\Apache Group\Apache2\htdocs\sign_guestbook.php on line 43
Can i know how to slove the problem...
I dun want to have the same e-mail address in my guestbook.
So i create the error...
$error = "select email from guestbook where email = ('".$email."');";
if (!$error)
(
echo 'Error: Email address already exist.';
exit;
}
but this is not working. When i run in the localhost, the got error come our like this..
Parse error: parse error, unexpected T_ECHO in C:\Program Files\Apache Group\Apache2\htdocs\sign_guestbook.php on line 43
Can i know how to slove the problem...
Code: Select all
$error = "select email from guestbook where email = ('".$email."');";
if (!$error)
{
echo 'Error: Email address already exist.';
exit;
}um, are you querying that before you check it?
also, i've never seen parentheses around the value, what's that for?
also, i've never seen parentheses around the value, what's that for?
Code: Select all
<?php
$query_error = mysql_query ("SELECT `email` FROM `guestbook` WHERE `email` = '".$email."';";
### not sure if this is needed, i'm not sure...
$error = mysql_fetch_row ($query_error);
if (!$error) {
echo 'Error: Email address already exist.';
exit;
}
?>- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
Joyce - it's far quicker (and easier!) to do the following when checking if a value already exists:
Code: Select all
$query = "SELECT COUNT(*) AS hits FROM guestbook WHERE email = '$email'";
// Query the DB here
$hits = mysql_result($result, 0, 'hits');
if ($hits > 0)
{
echo "Sorry email address already exists";
}you can do this too so it stops the script "dead in its tracks"
Code: Select all
if ($hits > 0)
{
die("Sorry email address already exists");
}- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact: