Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 31st, 2009, 03:35 PM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Angry how to check if a record does NOT exist in a table?

hi, i'm trying to check wether an email address is in the blacklisted table.

here is the code i am using atm,

PHP Code:
        $consumerfullname        $_POST["text_consumerfullname"];                                // rerequest consumer full name
        
$consumeremail            $_POST["text_consumeremail"];                                    // rerequest consumer email
        
$tsql "SELECT * FROM 7_blacklist WHERE `text_E-mailAddress` = ".$consumeremail.";\n";
        
$sql .= $tsql;
        
$result mysql_query($tsql);
        
$err mysql_error();
        
$sql .= strtoupper($err)."\n";
        if (
$result) {
                echo 
"    <result>\n";
                echo 
"Your e-mail address has been blacklisted for inappropriate use of Ferrety.co.za by the administrators.\n\n".
                     
"Please contact Jaap Venter at [email protected] for more information.";
                echo 
"    </result>\n";
        } else {
// do e-mail stuff
        

unfortunately for some reason that logic does not dictate, a blacklisted e-mail address can STILL send requests 0o.
I sincerely doubt it has anything to do with the - (dash) in the column name, as that is the reason for the backfacing quotes around it (`escaped-column-name`).
__________________
Sincerely,
Pierre "Greywacke" du Toit
[email protected]
don't worry about my 0 thankyou's either way, i would say thank you should you help, and i will gladly help others when this work rush is over.

Last edited by Greywacke; December 31st, 2009 at 03:38 PM..
 
Old December 31st, 2009, 04:14 PM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Unhappy what the heck now???

woops, forgot the double quotes around the inserted string :P

pity that didn't do a thing to the results :(

here follows the code i am trying to use now.

PHP Code:
        $tsql "SELECT * FROM 7_blacklist WHERE `text_E-mailAddress` = \"".$consumeremail."\";\n";
        
$sql .= $tsql;
        
$result mysql_query($tsql);
        
$err mysql_error();
        
$sql .= strtoupper($err)."\n";
        if (
$result) {
                     if (
mysql_num_rows($result) <= 0) {
                                     echo 
"    <result>\n";
                                     echo 
"Your e-mail address has been blacklisted for inappropriate use of Ferrety.co.za by the administrators.\n\n".
                                                
"Please contact Jaap Venter at [email protected] for more information.";
                                     echo 
"    </result>\n";
                     } else {
                                  
// do mailer stuff
                    
}
        } 
it still alerts the error when you use a non-blacklisted address, and still sends the mails regardless.
__________________
Sincerely,
Pierre "Greywacke" du Toit
[email protected]
don't worry about my 0 thankyou's either way, i would say thank you should you help, and i will gladly help others when this work rush is over.

Last edited by Greywacke; December 31st, 2009 at 08:21 PM..
 
Old January 1st, 2010, 04:14 AM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Talking yay success!!! XD

i've gotten it to work yay! don't be working when u'r tired hey! lol

PHP Code:
        $tsql "SELECT * FROM 7_blacklist WHERE `text_E-mailAddress` = \"".$consumeremail."\";\n";
        
$sql .= $tsql;
        
$result mysql_query($tsql);
        
$err mysql_error();
        
$sql .= strtoupper($err)."\n";
        if (
$result) {
            if (
mysql_num_rows($result) > 0) {
                
// do blacklist alert stuff
            
} else {
                
// do mailer stuff
            
}
        } 
__________________
Sincerely,
Pierre "Greywacke" du Toit
[email protected]
don't worry about my 0 thankyou's either way, i would say thank you should you help, and i will gladly help others when this work rush is over.





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Check if directory exist ArnArn XSLT 3 November 23rd, 2008 03:44 PM
check for image field exist goldenstate ASP.NET 2.0 Basics 2 May 22nd, 2007 12:36 PM
record exist or not keyvanjan Classic ASP Basics 2 May 5th, 2006 11:39 AM
Return a record that doesn't exist in a table? Unregistered SQL Server 2000 4 May 3rd, 2006 01:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.