我正在创建一个脚本,它将查询旧数据库并从中提取信息,然后将其推送到新数据库(使用新结构)。
我的问题是旧数据库中的一个表有text
类型的列。当我拉这个文本(有效)并尝试将其推送到新数据库(具有类型为mediumtext
的列)时,查询不会成功。
显然查询有一些错误但由于某种原因我的页面没有输出任何错误。
这个问题更多的是关于我做错了什么以及如何将错误输出到页面,但无论如何,有人可以帮助我吗?谢谢!
PHP:
$grad5app = mysqli_query($grad5app_connect, "SELECT * FROM international");
while ($row = mysqli_fetch_array($grad5app)) {
$applicationId = $row[0];
$toefl_hasTaken = $row[27];
$toefl_hasReported = $row[28];
$toefl_date = $row[2];
$toefl_score = $row[3];
$hasUSCareer = $row[4];
$usCareerDetails = $row[5];
$hasFurtherStudies = $row[29];
$furtherStudiesDetails = $row[6];
$hasHomeCareer = $row[30];
$homeCareerDetails = $row[7];
$financeDetails = $row[8];
$usFriendsOrRelatives = $row[9];
$usEmergencyContact_name = $row[10];
$usEmergencyContact_relationship = $row[17];
//$usEmergencyContact_contactInformationId = $row[];
$homeEmergencyContact_name = $row[18];
$homeEmergencyContact_relationship = $row[26];
//$homeEmergencyContact_contactInformationId = $row[];
echo $usCareerDetails;
$grad5app1 = mysqli_query($grad5app_connect, "SELECT * FROM applicants WHERE applicant_id = ".$applicationId." ");
while ($row1 = mysqli_fetch_array($grad5app1)) {
$isInternationalStudent = $row1[132];
mysqli_query($gradschool_application_2_connect, "INSERT INTO APPLICATION_International (applicationId, isInternationalStudent, toefl_hasTaken, toefl_hasReported, toefl_date, toefl_score, hasUSCareer, usCareerDetails".
") VALUES (".$applicationId.", ".$isInternationalStudent.", ".$toefl_hasTaken.", ".$toefl_hasReported.", '".$toefl_date."', ".$toefl_score.", ".$hasUSCareer.", '".$usCareerDetails."')");
}
}
变量$usCareerDetails
属于text
类型,需要将其推送到mediumtext
类型的列。但是,如果我从查询中删除usCareerDetails
,那么此查询无法正常推送数据。
页面输出:
I'm gonna work in the USA for 2 years.
输出是从旧数据库中提取的echo $usCareerDetails;
。