第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將值保存在數(shù)組中并在表中使用后出現(xiàn)問題

將值保存在數(shù)組中并在表中使用后出現(xiàn)問題

PHP
手掌心 2022-01-24 10:02:47
我在實習(xí)中做的練習(xí)涉及一個上傳頁面,一個表格頁面,它將輸出數(shù)據(jù)庫表的記錄和一個數(shù)據(jù)庫表。問題是,經(jīng)過巨大的努力使所有連接良好,我遇到了一些麻煩,因為 index.php 頁面應(yīng)該發(fā)送信息并且正在發(fā)送數(shù)組并保存數(shù)組而不是文件。下面是 index.php 頁面的 PHP 代碼: <?phpif (!isset($_POST['Enviar'])):  // This if will search if the $_POST variable already has anything or not.$allowed =  array('txt');   //This array contains the file types which are allowed.$uploadtime = time();$uploadfile = $_FILES['file_to_upload'];include 'db_connection.php';$sql="select * from uploads";$result = $conn->query($sql);$target_dir = "uploads/";   //variable that will save the name of the folder or way where the file will be saved.$target_file = $target_dir . basename($_FILES['file_to_upload']['name']); //NOTICE undefined index: file_to_upload... because it doesn't have any value safe there yet.$goon = 1;  //This variable is used to check if there is any error messages or if the program can go on.$ext = pathinfo( $_FILES["file_to_upload"]["name"], PATHINFO_EXTENSION); // This will use the OS to get the file extension.if(!in_array($ext,$allowed) ) {echo 'Erro: Ficheiro n?o permitido. <br> Por favor, verifique se o formato do ficheiro é txt.';$goon = 0;}   第二段代碼中的字段名稱是數(shù)據(jù)庫中的名稱。誰能告訴我在 index.php 頁面中收到此錯誤消息有什么問題:注意:第 66 行 C:\xampp\htdocs\16082019\index.php 中的數(shù)組到字符串轉(zhuǎn)換
查看完整描述

2 回答

?
撒科打諢

TA貢獻1934條經(jīng)驗 獲得超2個贊

1st:謝謝你試圖幫助我xD。


第二:我已經(jīng)有了一個適合我的練習(xí)的解決方案:


$uploadfile = $_FILES['file_to_upload']; 

$uploadfile2 = $uploadfile['name']; 

然后用舊線代替:


VALUES('".$_POST['file_name']."','$uploadfile2','$ext','$uploadtime')";


查看完整回答
反對 回復(fù) 2022-01-24
?
ABOUTYOU

TA貢獻1812條經(jīng)驗 獲得超5個贊

“注意:數(shù)組到字符串的轉(zhuǎn)換”表示您正在嘗試將數(shù)組用作字符串。這是因為您將數(shù)組$_POST['file_name']與您的 INPUT 查詢字符串連接起來。您可以使用implode()函數(shù)將數(shù)組轉(zhuǎn)換為字符串:


$values = implode(',', $_POST['file_name']);

$sql = "INSERT INTO uploads (name,file_name,file_extension,uploaded_time)

        VALUES('" . $values . "','$uploadfile','$ext','$uploadtime')";


查看完整回答
反對 回復(fù) 2022-01-24
  • 2 回答
  • 0 關(guān)注
  • 159 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號