You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id_job DESC' at line 1
Code (PHP)
<?php
/**
* Application Form
* @version 1.0
*/
// path to the root
$path_to = '../';
// includes
require '../config.inc.php';
require '../lib.inc.php';
require '../init.inc.php';
require_once("Class/class.phpmailer.php");
// create database connection
$db = new MysqlDB(DB_HOSTNAME, DB_DATABASE, DB_USERNAME, DB_PASSWORD);
@mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD)or die(mysql_error());
@mysql_select_db(DB_DATABASE)or die(mysql_error());
/*// strip all vars
if (get_magic_quotes_gpc() == 1) {
stripSlashesArray($_GET);
}*/
$body_id = 'Send job vacancies';
// include top
include $path_to.'top.incs.php';
$datetoday=date('Y-m-d');
$sql_save="insert into ty_sendjobvacancies(id_job,sender,from_email,receive,to_email,detail,datetoday)values('$_POST[id_sendF]','$_POST[txtsender]','$_POST[Emai_s]','$_POST[txtreceive]','$_POST[Email_r]','$_POST[txtdetail]','$datetoday')";
$query=mysql_query($sql_save)or die (mysql_error());
//$sql="SELECT ty_listdetail. * ,ty_sendjobvacancies. * FROM ty_listdetail , ty_sendjobvacancies WHERE ty_listdetail.id_job = ty_sendjobvacancies.id_job && id=$_GET[sendF]";
$sql="select * from ty_sendjobvacancies where id_job=$_GET[sendF] order by id DESC";
$q=mysql_query($sql) or die (mysql_error());
echo $sql;
while($rec=mysql_fetch_assoc($q)){
//code sned mail phpmailer
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->IsSMTP();
$mail->CharSet = "utf-8";
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "info665"; // GMAIL password
$mail->From = "[email protected]"; // "[email protected]";
$mail->FromName = "$rec[sender]"; // set from Name
$mail->Subject = "Job Vacancies";
$mail->Body =" Send Job Vacancies from friend to you.<br><br> ".
"Name - surname Sender :$rec[sender]<br>".
"E-mail Sender : $rec[from_email]<br>".
"Name Receive : $rec[receive]<br>".
"E-mail Sender : $rec[to_email]<br>".
"Detail : $rec[detail]<br>".
"link : "."<a href=http://www.mydomain.com/en/contact/application_detail?detail=$rec[id_job]"."<br>".
"Thank <br> From Automatic E-mail systems.(www.mydomain.com)";
$mail->AddAddress("$rec[to_email]", "Job Vacancies"); // to Address
//$mail->AddAttachment("application/$rec[resume_file]");
//$mail->AddAttachment("zip/PHPMailer_v5.2.zip");
//$mail->AddCC("[email protected]", "Job Vacancies"); //CC
//$mail->AddBCC("[email protected]", "Job Vacancies"); //BCC
$mail->set('X-Priority', '1'); //Priority 1 = High, 3 = Normal, 5 = low :Security
}//while
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
return false;
} else {
echo "Message sent!";
return true;
}
?>
</body>
</html>
<a href="javascript:sendtofriend.php?sendF=<?=$rec['id_job'];?>" onClick="javascript:window.open('sendtofriend.php?sendF=<?=$rec['id_job']?>','','scrollbars=no,width=330,height=280,left=560,top=300');">Send to Friends</a>