 |
Error ตรง sql ที่ select ออกมาครับ ช่วยดูโค้ดหน่อย หาตั้งนานแล้วไม่เจอครับ |
|
 |
|
|
 |
 |
|
Error ตรง sql ที่ select ออกมาครับ ช่วยดูโค้ดหน่อย หาตั้งนานแล้วไม่เจอครับ
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>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2012-06-22 14:37:35
|
 |
 |
 |
 |
Date :
2012-06-22 11:46:07 |
By :
nottpoo |
View :
1214 |
Reply :
9 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าคุณ echo คิวรี่ออกมาดูก็จะรู้ครับว่ามันผิดตรงไหน ....
การใส่ตัวแปรเข้าไปในตัวแปรต้องเชื่อมต่อตัวอักษรให้ถูกต้องด้วยครับ
key word คือ single quotes, double quotes, dot
|
 |
 |
 |
 |
Date :
2012-06-22 11:58:55 |
By :
Songkram |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$_GET[sendF] ไม่มีค่า
|
 |
 |
 |
 |
Date :
2012-06-22 12:18:36 |
By :
ผ่านมา |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแก้ตรงนี้ครับ
Code (PHP)
$sql="select * from ty_sendjobvacancies where id_job=$_GET[sendF] order by id DESC";
เป็น
$sql="select * from ty_sendjobvacancies where id_job='$_GET[sendF]' order by id DESC";
|
 |
 |
 |
 |
Date :
2012-06-22 12:20:19 |
By :
randOmizE |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โอเคหาย Error cแล้วครับ ผมลองโค้ดตามคุณ random แนะนำครับ
แต่ขอถามต่ออีกนิดหนึ่ง คือว่า พอกด send to friend ไปแล้ว $_GET[sendF] ไม่มีค่าเลยครับ ทั้งที่ ตามรูปหมายเลย 1 2 3 ที่ส่งมามันก็มีค่ามาตลอด และพอส่งเข้าเมล์แล้วมันจะดึงแต่ id=1 มาตลอดเลย ผมอยากให้ดึงค่าตาม desc หนะครับ ดูรูปนะครับ


แนะนำด้วยนะครับเซียนทั้งหลาย
|
ประวัติการแก้ไข 2012-06-22 14:41:42 2012-06-22 15:18:13
 |
 |
 |
 |
Date :
2012-06-22 14:36:06 |
By :
nottpoo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใน form Popup ตรง action คุณน่าจะต้องใส่ ?sendF=<?=$_GET["SendF"];?> เข้าไปด้วยครับ
|
 |
 |
 |
 |
Date :
2012-06-22 14:41:28 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใส่ไปแล้วพี่วิน มันก็ยังดึงแต่ id=1 เหมือนเดิมตอนส่งเมล์ไป


ปัญหาคือ $_GET[sendF] ไม่มีหนะครับ ทำไงครับ
Code (PHP)
$sql="select * from ty_sendjobvacancies where id_job='$_GET[sendF]' order by id DESC";
|
ประวัติการแก้ไข 2012-06-22 14:53:47
 |
 |
 |
 |
Date :
2012-06-22 14:49:55 |
By :
nottpoo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ละครับ
ขอบคุณทุกท่านครับ มันเป็นอย่างที่พี่วินแนะนำ แต่ผมพิมพ์ผิดเองครับ ดันใส่ตัวอักษร เล็ก ใหญ่ ตอนส่งค่าครับ มันเลยทำให้ $_GET[sandF] ไม่มีค่าหนะครับ
|
 |
 |
 |
 |
Date :
2012-06-22 15:21:53 |
By :
nottpoo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
var_dump($_GET['sendF']); ออกมาก่อนเลยครับ ว่ามีค่าไหม
|
 |
 |
 |
 |
Date :
2012-06-22 15:28:07 |
By :
ไวยวิทย์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวแปรทุกตัว ค่าออกหมดแล้ว แต่ยังติดอีกนิดหนึ่งคือ
ตอนส่งเมล์หนะ มันจะดึงเอาแต่ id=1 มาส่งตลอดเลย ทั้งที่ในฐานข้อมูลมีข้อมูล id=1 id=2 id=3 id=4 id=5
ทำให้มันส่งเมล์ไม่ถูกต้อง ต้องการให้มันส่งเมล์ตามค่า $_GET ที่ส่งมาครับ ปัญหาคือเมื่อ id_job=2 หรือ 7 หลายๆตัวมันจะส่งเฉพาะ
ค่า 2 ตัวแรกเท่านั้นครับ ทำให้มันส่งเมล์ไม่ถูกต้อง
แนะนำด้วยครับ โค้ด sendmail ตัวล่าสุดครับ

application_detail
<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>
sendtofriend.php
<form action="sendtofriends.php?sendFS=<?=$_GET['sendF']?>" method="post" name="send_jobvacation" target="_parent">
.
.
.
</from>
sendtofriends.php
require_once("Class/class.phpmailer.php");
require_once("Class/class.smtp.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());
if(isset($_POST['id_sendF'])){
$sendFS=$_GET['sendFS'];
$sql="select * from ty_sendjobvacancies where id='$sendFS' order by id DESC";
//$sql="select * from ty_sendjobvacancies order by id DESC";
$q=mysql_query($sql) or die (mysql_error());
echo $sql ."<br>";
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->Host = "mail.toscanavalley.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 = "nottpoo9978#9978"; // GMAIL password
//$mail->Username = "[email protected]"; // GMAIL username
//$mail->Password = "poopoopoo"; // 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 Sender :$rec[sender]<br>".
"E-mail Sender : $rec[from_email]<br>".
"Name Receive : $rec[receive]<br>".
"E-mail Receive : $rec[to_email]<br>".
"Detail : $rec[detail]<br>".
"link : <a href=http://localhost/toscana_beta/en/contact/application_detail.php?detail=$rec[id_job]>http://www.toscanavalley.com/en/contact/application_detail.php?detail=$rec[id_job]</a><br>".
"Thank <br> From Automatic E-mail systems.(www.toscanavalley.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
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
return false;
} else {
echo "Message sent!";
return true;
}
?>
|
ประวัติการแก้ไข 2012-06-25 10:50:29 2012-06-25 10:52:06 2012-06-26 10:15:57 2012-06-26 10:20:42 2012-06-26 10:38:17
 |
 |
 |
 |
Date :
2012-06-25 10:49:20 |
By :
nottpoo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|