一部の業界カテゴリ ID を mysql テーブルの単一フィールドにアップロードできません。私はphp/htmlを使用しています。
私のフォームは、コンマ区切りの値として挿入したい NewsIndustryID を除いて、必要なすべての値を挿入しています - 例: 201,206,209
これは、フォームを送信したときに表示されるエラー メッセージです (NewsIndustryID フィールドを削除すると問題なく動作します)。
Warning: mysql_real_escape_string() expects parameter 1 to be string,
array given in /home/coverfor/public_html/dwzUpload/dwzDataBase.php on
line 426 Error on update record
Column 'NewsIndustryID' cannot be null
array ( 'table_name' => 'Images', 'fields' => array ( 0 => array (
'name' => 'Caption', 'value' => 'Test Image Caption', 'type' =>
'text', 'def_value' => '', 'not_def_value' => '', ), 1 => array (
'name' => 'NewsIndustryID', 'value' => array ( 0 => '201', 1 => '204',
2 => '205', ), 'type' => 'text', 'def_value' => '', 'not_def_value' =>
'', ), 2 => array ( 'name' => 'slideURL', 'value' =>
'/newsimages/jackpot_15.jpg', 'type' => 'text', ), 3 => array ( 'name'
=> 'slideHeight', 'value' => 111290, 'type' => 'int', ), 4 => array ( 'name' => sliverURL', 'value' => '/newsimages/jackpot_15_sliver.jpg',
'type' => 'text', ), 5 => array ( 'name' => 'BannerURL', 'value' =>
'/newsimages/jackpot_15_banner.jpg', 'type' => 'text', ), ), )
INSERT INTO `Images` ( `Caption`, `NewsIndustryID`, `slideURL`,
`slideHeight`, `sliverURL`, `BannerURL` ) VALUES ( 'Test Image
Caption', NULL, '/newsimages/jackpot_15.jpg', 111290,
'/newsimages/jackpot_15_sliver.jpg',
'/newsimages/jackpot_15_banner.jpg' )
誰かが素晴らしい支援を提供できれば!
これは私のページのコードです (問題がどこにあるかわからないため、HTML 宣言の前にすべてを含めたコードの量についてお詫びします):
<?php
require_once("../../dwzUpload/dwzUpload.php");
require_once('../../Connections/newsDBconnection.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "../login.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
$isValid = False;
if (!empty($UserName)) {
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
set_time_limit(5400);
$upload = new dwzUpload();
$upload->SetProgressBar("");
$upload->SetTempFolder("");
$upload->SetTotalFileSize("");
$upload->SetRedirectUrl("imagesgallery.php");
$upload->SetFiles("/newsimages;1;;png, jpg, jpeg, gif, tiff, tif;2000;1;slideURL;1;slideHeight&N;2;;0;;;;sliverURL;1;BannerURL;1;photo@_@_@0@_@_@php@_@_@-1;710;322;100;-1;230;80;100;-1;_sliver;-1;1;-1;460;230;100;-1;_banner;1@_@_@../../@_@_@POST");
$upload->SetFormName("form1");
$upload->SetUploadType("insert");
$upload->SetValueToRedirectSend("");
$upload->SetDbParam($hostname_newsDBconnection, $database_newsDBconnection, $username_newsDBconnection, $password_newsDBconnection);
$upload->SetEditTable("Images");
$upload->SetFields("Caption|value|NewsIndustryID|value");
$upload->SetColumns("Caption|text|NewsIndustryID|text");
$upload->Execute();
if (isset($_POST['NewsIndustryID'])) {
$_POST['NewsIndustryID'] = implode(',', $_POST['NewsIndustryID']);
}
?>
これは私のフォームのコードです:
<form onsubmit="return ProgressBar()" action="<?php echo $upload->GetEditAction(); ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<h1>
Upload Image to Gallery
<?php
$upload->GetProgressBarField();
?>
</h1>
<p> </p>
<p>
<label for="Caption">Caption</label>
<input type="text" name="Caption" id="Caption" />
</p>
<p>
<label for="NewsIndustryID">Related Industries</label>
<select name="NewsIndustryID[]" size="11" multiple="multiple" id="NewsIndustryID">
<option value="200" selected="selected">Not Specified</option>
<option value="201">Construction</option>
<option value="202">Energy</option>
<option value="203">Forestry</option>
<option value="204">Not For Profit</option>
<option value="205">Professionals</option>
<option value="206">Healthcare</option>
<option value="207">Manufacturing</option>
<option value="208">Mining</option>
<option value="209">Property</option>
<option value="210">Transport</option>
<option value="211">Agriculture</option>
</select>
</p>
<p>
Photo: <input name="photo" type="file" onchange="dwz_setEvent(this,'change')" onclick="dwz_setEvent(this,'click')"><br>
</p>
<p>Submit
<input type="submit" name="dwzSubmit" id="dwzSubmit" value="Submit" />
</p>
<input type="hidden" name="dwzUpload" id="dwzUpload" value="form1" />
<input type="hidden" name="MM_insert" value="form1" />
</form>