Thread: Query Confusion
View Single Post
Old 10-01-2007, 09:37 PM   #1 (permalink)
CMellor
The Acquainted
Upcoming Programmer 
 
CMellor's Avatar
 
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
CMellor is on a distinguished road
Default Query Confusion

Hey,

I'm pretty sure this can be classed more as a MySQL problem than a PHP one.

Check out this bit of code:

PHP Code:
<?php
// If submit was pressed, send PM
if(isset($_POST['submit_send_pm'])) {
    
// Put in variables
    
extract($_POST);
        
    
// Get the recipitent's ID
    
$recepID mysql_query("SELECT id, pm_notify FROM members, settings
    WHERE username = '"
.$to."'
         AND pm_notify = '0'||'1'
    "
);
    
// Grab ID
    
$recepRow mysql_fetch_object($recepID);
        
    
// Insert new info into database
    
$query mysql_query(sprintf("INSERT INTO private_msg SET
     subject = '%s',
      message = '%s',
      date = UNIX_TIMESTAMP(),
      sent_from = '%d',
      sent_to = '%d'"
,
        
// Values
        
escape($subject),
        
$message,
        
escape($_COOKIE['userID']),
        
escape($recepRow->id)
    )) or die(
mysql_error());
        
    
// Check if users wants to be notified, if so, send them an e-mail
    
if($recepRow->pm_notify == 1) {
        echo(
'Mail Sent');
    }
}
?>
Once the query has does it's work, I want to check if the user who it was sent to, has their 'pm_notify' selection set to 'yes' (or in the database, '1') If the option is set to '1', it will send an e-mail, though I just echo'd some text for testing purposes.

I can't seem to grab the 'pm_notify' row from the user to check if it is set to 0 or 1, can anyone think what might be the problem with my query?

Thanks.
__________________
Not quite a n00b...
CMellor is offline  
Reply With Quote