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_HOST, C_MYSQL_USER, C_MYSQL_PWD, true) 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+1 == $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:
Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'C_MYSQL_HOST' (1) in /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