Saludos,
estoy diseñando un admin y al momento de decirle que me actualice las imágenes este me las borra de la base de datos, solo me almacena la imagen dentro del ftp y en la bd la elimina..
Les muestro a ver si ven el error
Código PHP:
<?php //require_once('includes/sesion.php'); ?>
<?php require_once('../Connections/azimut.php'); ?>
<?php
include_once("fckeditor/fckeditor.php") ;
?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
if ($_POST['opcion']==1){
$ediciondir= '../wlc/';
$uploaddir=$ediciondir;
if (!is_dir($ediciondir)) { mkdir($uploaddir, 0777); }
move_uploaded_file($_FILES['img2']['tmp_name'], $uploaddir . $_FILES['img2']['name']);
$filename = $_FILES['img2']['name'];}
else {
$filename = $_POST['img'];
}
$updateSQL = sprintf("UPDATE inicio SET wlc=%s, tenemos=%s, img=%s WHERE id=%s",
GetSQLValueString($_POST['wlc'], "text"),
GetSQLValueString($_POST['tenemos'], "text"),
GetSQLValueString($_POST['img'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_azimut, $azimut);
$Result1 = mysql_query($updateSQL, $azimut) or die(mysql_error());
$updateGoTo = "act_textos_index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "1";
if (isset($_GET['id'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_azimut, $azimut);
$query_Recordset1 = sprintf("SELECT * FROM inicio WHERE id = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $azimut) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
y el formulario
Código PHP:
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2" enctype="multipart/form-data">
<table align="center">
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap" class="textoINDEX">Texto Bienvenidos: </td>
<td class="textoTitulos2"><div align="left"><span class="textoINDEX">
<?php
$oFCKeditor = new FCKeditor('wlc');
$oFCKeditor->BasePath = 'fckeditor/';
$oFCKeditor->Value = $row_Recordset1['wlc'];
$oFCKeditor->Create();
?>
</span></div></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap" class="textoINDEX">Tenemos para ti: </td>
<td class="textoTitulos2"><div align="left"><span class="textoINDEX">
<?php
$oFCKeditor = new FCKeditor('tenemos');
$oFCKeditor->BasePath = 'fckeditor/';
$oFCKeditor->Value = $row_Recordset1['tenemos'];
$oFCKeditor->Create();
?>
</span></div></td>
</tr>
<tr valign="baseline">
<td align="right" valign="top" nowrap="nowrap" class="textoINDEX"> </td>
<td class="textoTitulos2"> </td>
</tr>
<tr valign="baseline" class="textoprincipal">
<td colspan="2" align="right" nowrap="nowrap"><span class="textoINDEX">Actualizar Imagen? Si
<input name="opcion" type="radio" class="textoprincipal" value="1" />
/No
<input name="opcion" type="radio" class="textoprincipal" value="0" checked="checked" />
<input name="imagen" type="hidden" class="todopanel" value="<?php echo $row_Recordset1['img']; ?>" size="32" />
<input name="img2" type="file" class="textoINDEX" id="img2" />
</span></span></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap="nowrap" class="textoprincipal"> </td>
<td><div align="left"></div></td>
</tr>
<tr valign="baseline">
<td align="right" nowrap="nowrap" class="textoprincipal"> </td>
<td><input type="submit" class="textoINDEX" value="Actualizar" /></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
<input type="hidden" name="MM_update" value="form2" />
<input type="hidden" name="id" value="<?php echo $row_Recordset1['id']; ?>" />
</form>
le he dado vueltas y aun persiste el problema.. alguien me ayuda por favor?
Gracias de antemano!!!