Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Please help me to set up php emails to be sent to different person

  1. #11
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    if that is your entire config.inc.php file then there is a problem.
    You have started / continued the session, but you have not declared the $_SESSION['id'] variable which is why you are continuing to obtain the cannot connect error.

    It also doesn't look like anywhere in your config file or the original file that you are even trying to connect to the database to begin with, so even if the variable was present you would have received an error about connecting to the database.

    in some file you need the code below.
    Code:
    $c = mysqli_connect(C_MYSQL_HOST, C_MYSQL_USER, C_MYSQL_PWD);
    $conn = mysqli_select_db($c, C_MYSQL_DB);
    then before you run your query you can do

    Code:
    if($conn)
    {
           _QUERY_
    }
    Last edited by boogyman; 12-18-2007 at 02:18 PM.

  2. #12
    Join Date
    Apr 2007
    Posts
    52
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    xxxxx
    Last edited by linux1880; 12-19-2007 at 12:51 PM.

  3. #13
    Join Date
    Apr 2007
    Posts
    52
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    hi boogyman i have another file called common.inc.php and contains the following details:

    PHP Code:
    <?    
        ConnectToDb
    ();

        function 
    ConnectToDb()
        {
            global 
    $s_db_link;
            
    $s_db_link mysql_connect (C_MYSQL_HOSTC_MYSQL_USERC_MYSQL_PWDtrue) or SQLError("Connecting to database...");
            
    mysql_select_db (C_MYSQL_DB$s_db_link) or SQLError("Selecting database...");
        }
        
        function 
    GetCount$tbl_name$where '' )
        {
            if ( 
    $where == '' )
                
    $sql "select count(*) from $tbl_name";
            else
                
    $sql "select count(*) from $tbl_name where $where";
            
            
    $rs mysql_query$sql ) or die("Conunting failed, " mysql_error());
            
    $data mysql_fetch_array($rs);
            return 
    $data[0];
        }

        function 
    GetSingleData ($table_name$field_name$condition)
        {
            
    $sql "select $field_name from $table_name where $condition";

            
    $rs_temp mysql_query ($sql) or SQLError("Getting $field_name ...");
            
            if (
    mysql_num_rows ($rs_temp) != 1)
            {
                return -
    1;
            }
            else
            {
                
    $row_temp mysql_fetch_array ($rs_temp);
                return 
    $row_temp[0];
            }
        }

        function 
    SQLError$at '' )
        {

            
    $errNo=mysql_errno();
            global 
    $debugSQL_g;
            
            if ( 
    $debugSQL_g )
            {
                print( 
    mysql_error() );
                print(
    "<br>At ".$at);
            }
            else
            {
                switch ( 
    $errNo )
                {
                    case 
    1142:
                        print( 
    '<br><h4 align=center>Your Not Authorized to Perform this Action!</h4>' );
                        break;
                    
                    case 
    1217:
                        print( 
    '<br><h4 align=center>Referental Intregrity failed! There May be Child rows Depending</h4>' );
                        break;
                    
                    case 
    1062:
                        print( 
    '<br><h4 align=center>The Combination Already Exist</h4>' );
                        break;
                    
                        
                    default:
                        if ( 
    $at == '' ){
                            print( 
    'Error in the Query<br>'.mysql_error() );
                        }else{
                            print( 
    'Error in the Query at '.$at.'<br>'.mysql_error() );
                        }
                }
            }
            
    mysql_query("ROLLBACK");
            exit;
        }
        
        function 
    Redirect($loaction)
        {
            
    header("location: " $loaction);
            exit;
        }
        
        function 
    ReportInfo($msg "Un-authorized operation!")
        {
            
    header("location: info.php?msg=".urlencode($msg));
            exit;
        }

        function 
    SaySuccess($msg)
        {
            
    header("location: success.php?msg=".urlencode($msg));
            exit;
        }

        function 
    ShowPaging($page_no$total_pages$tag_key=''$tag_val='')
        {
        
    ?>
        <table cellspacing="0" cellpadding="2">
          <tr>
        <?
            
    global $s_self_page;
            
            
    $query_string "";

            if (
    $tag_key == '')
            {
                foreach ( 
    $_GET as $key=>$var )
                    if( 
    $key != "page_no" )
                        
    $query_string .= '&'.$key.'='.$var;
            }
            else
            {
                foreach ( 
    $_GET as $key=>$var )
                    if( !(
    $key == "page_no" || $key ==$tag_key))
                        
    $query_string .= '&'.$key.'='.$var;
                
    $query_string .= '&'.$tag_key.'='.$tag_val;
            }

            if (
    $page_no >1)
                print (
    '<td valign="middle"><a href="' $s_self_page '?page=' . ($page_no-1) . $query_string '"><img src="images/button_back_on.gif" border="0"></a></td>');
            else
                print (
    '<td valign="middle"><img src="images/dd.gif">');
            print (
    '<td valign="middle"  class="BodyText">');
            for (
    $i=0$i<$total_pages$i++)
            {
                if (
    $i+== $page_no)
                    print ((
    $i+1) . " " );
                else
                    print (
    '<a href="' $s_self_page '?page_no=' . ($i+1) . $query_string '" class="PageLink">' . ($i+1) . '</a> ');
            }
            print (
    '</td>');
            
            if (
    $page_no $total_pages)
                print (
    '<td valign="middle"><a href="' $s_self_page '?page_no=' . ($page_no+1) . $query_string '"><img src="images/button_foward_on.gif" border="0"></a></td>');
            else
                print (
    '<td valign="middle"><img src="images/button_foward_off.gif"></td>');
                
            
    ?>
          </tr>
        </table>        
            <?
        
    }
        
        function 
    DrawSortColumn ($col$name$check_key ='sort')
        {
            
            global 
    $s_self_page;
            
            
    $query_string "";
            
    $class "SortLink";
            
            foreach ( 
    $_GET as $key=>$var )
                if( 
    $key != $check_key )
                    
    $query_string .= '&'.$key.'='.$var;
                
            
            
    $current = isset( $_GET[$check_key] ) ? $_GET[$check_key] : "";
                    
            if( 
    $col == $current )        
            {
                
    ?>
                <a href='<?="$s_self_page?$check_key=".urlencode("$col desc")."$query_string"?>' class='<?=$class ?>'><b><?=$name?></b></a>
                <?
            
    }
            else
            {
                
    ?>
                <a href='<?="$s_self_page?$check_key=$col$query_string"?>' class='<?=$class ?>'><b><?=$name?></b></a>
                <?
            
    }
        }

    ?>

    now i have changed the sendmail.php configuration as like this

    PHP Code:
    <?
        
    require_once "http://www.mysite/staff/config.inc.php";
        require_once 
    "http://www.amysite/staff/common.inc.php";
        
        if (isset(
    $_SESSION['id']))
        {
            
    $sql "select * from applications where id='$_SESSION[id]'";
            
    $rs mysql_query($sql) or SQLError("Getting all the details...");
            
    $row mysql_fetch_array($rs);
            unset(
    $_SESSION['id']);
        }
        else
        {
            echo(
    "<p>Still no solution...<p>");
        }

    ?>

    <?php
    $to 
    "me@gmail.com";
    $subject "Your application updates from college !";
    $body $row['noteforstudents'];
    $headers "From: info@something.com\r\n" .
        
    "X-Mailer: xxxx MBB";
    if (
    mail($to$subject$body$headers)) {
      echo(
    "<p>Message sent!</p>");
     } else {
      echo(
    "<p>Message delivery failed...</p>");
     }
    ?>
    Doing that I get this error on php page.

    PHP Code:
    Warningmysql_connect() [function.mysql-connect]: Unknown MySQL server host 'C_MYSQL_HOST' (1in /home/folder/YGYLGGI/htdocs/staff/common.inc.php on line 7
    Error in the Query at Connecting to database
    ...
    Unknown MySQL server host 'C_MYSQL_HOST' (1)
    Still no solution...


    Message sent

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •