-2

thankyou.php我在 000webhost 服务器上的文件夹中存储了以下内容public_html,以及我要连接的 MySQL 数据库。该页面是一个从 jotform 嵌入的表单,在提交时我希望将答案发布到 MySQL 数据库。

我已经测试了代码一百万次,它似乎运行良好,但我仍然收到错误:

感谢您输入您的销售详细信息无法连接到“mysql6.000webhost.com”上的 MySQL 服务器 (4)

我创建了一个进一步的 test.php 来测试连接,它提出了连接。你认为这是jotform的问题吗?我已阅读其他用户已设法使连接正常工作,所以我认为这可能是 mysql6000webhost 的问题?

<?php
$fullname = $_POST['clientmanager'];

print "<p><p>";

print " Thankyou $fullname for entering your sales details";


// This function will run within each post array including multi-dimensional arrays 
function ExtendedAddslash(&$params)
{ 
        foreach ($params as &$var) {
            // check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside.
            is_array($var) ? ExtendedAddslash($var) : $var=addslashes($var);
        }
}

// Initialize ExtendedAddslash() function for every $_POST variable
ExtendedAddslash($_POST);      

$submission_id = $_POST['submission_id']; 
$formID = $_POST['formID'];
$IP = $_POST['ip'];
$Placement = $_POST['selectplacement4'];
$Client_Name= $_POST['name7'];
$Client_Address= $_POST['address'][0] ."-". $_POST['address'][1]."-". $_POST['address'][2]."-". $_POST['address'][3]."-". $_POST['address'][4]."-". $_POST['address'][5];
$Client_Phone= $_POST['phonenumber'][0] ."-". $_POST['phonenumber'][1];
$Attn_Name1= $_POST['name'];
$Attn_Email1= $_POST['email15'];
$Attn_Name2= $_POST['name2'];
$Attn_Email2= $_POST['email2'];
$Candidate_Name= $_POST['candidatename'];
$Position= $_POST['position'];
$Start_Date= $_POST['startdate'][0] ."-". $_POST['startdate'][1]."-". $_POST['startdate'][2];
$frequency= $_POST['frequency'];
$rate= $_POST['rate24'];
$Units= $_POST['noof'];
$Salary= $_POST['salary'];
$feepercent= $_POST['fee'];
$Reason= $_POST['input33'];
$feeamt= $_POST['feeamt'];
$RecruiterName= $_POST['recruitername'];
$NewRecName= $_POST['entername'];
$RecruiterPercent= $_POST['recruiter'];
$ClientMgrName= $_POST['clientmanager'];
$ClientMgrPercent= $_POST['clientmanager36'];
$TotalFeePercent= $_POST['associatefees37'];
$TotalFee= $_POST['associatefees'];


$db_host = 'mysql6.000webhost.com';
$db_username = 'a8748341_blt';
$db_password = '******';
$db_name = 'a8748341_bltrec';

mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error());
mysql_select_db($db_name); 

// search submission ID

$query = "SELECT * FROM bltrecruiting where submission_id = $submission_id";
$sqlsearch = mysql_query($query);
$resultcount = mysql_numrows($sqlsearch);

if ($resultcount > 0) {

    mysql_query("UPDATE `bltrecruiting` SET 
                                `Placement` = '$Placement',
                                `Client_Name` = '$Client_Name',
                                `Client_Address` = '$Client_Address',
                                `Client_Phone` = '$Client_Phone',
                                `Attn_Name1` = '$Attn_Name1',
                                `Attn_Email1` = '$Attn_Email1',
                                `Attn_Name2` = '$Attn_Name2',
                                `Attn_Email2` = '$Attn_Email2'

                             WHERE `submission_id` = '$submission_id'") 
     or die(mysql_error());

} else {

    mysql_query("INSERT INTO `bltrecruiting` (submission_id, formID, IP, Placement, Client_Name, Client_Address, Client_Phone, Attn_Name1, Attn_Email1, Attn_Name2, Attn_Email2, Candidate_Name, Position, Start_Date, frequency, rate, Units, Salary, feepercent, Reason, feeamt, RecruiterName, NewRecName, RecruiterPercent, ClientMgrName, ClientMgrPercent, TotalFeePercent, TotalFee) 
                               VALUES ('submission_id, formID, IP, Placement, Client_Name, Client_Address, Client_Phone, Attn_Name1, Attn_Email1, Attn_Name2, Attn_Email2, Candidate_Name, Position, Start_Date, frequency, rate, Units, Salary, feepercent, Reason, feeamt, RecruiterName, NewRecName, RecruiterPercent, ClientMgrName, ClientMgrPercent, TotalFeePercent, TotalFee) ") 
    or die(mysql_error());  

}
?>
4

1 回答 1

0

您的插入查询 VALUES 对我来说看起来很奇怪:
一个打开的单引号从未关闭,
没有使用您在上面初始化一些行的 php 变量...

也许你的意思是

VALUES ('$submission_id', '$formID', '$IP', '$Placement', ...., '$TotalFeePercent', '$TotalFee')
于 2014-12-16T20:59:05.930 回答