The edit functionality works well, but i need to rename the image to the result of a random var.
As you can see in the example:
Code: Select all
<?php
require_once("../classes/Queries.php");
require_once("../classes/Uploads.php");
require_once("../classes/XML.php");
$nodes = array();
function detectaIE()
{
if (isset($_SERVER['HTTP_USER_AGENT']) &&
(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
return true;
else
return false;
}
$obj = new stdClass();
$obj->tabelas = array("tab_texturas");
$obj->campos = array(array("nome", "'".$_POST['textura']."'"));
$obj->registo = array("id", $_POST['id']);
$obj_imagem = new stdClass();
$obj_imagem->tabelas = array("tab_texturas");
$obj_imagem->registo = array("id", $_POST['id']);
$actualiza = new Queries();
$update = $actualiza->actualizaRegisto($obj);
if ($update->estado == 1){
$sql = "UPDATE tab_texturas SET nome = '" . $_POST['textura']."' WHERE id = " . $_POST['id'];
if ($query = mysql_db_query("margon", $sql)){
$imagem = new Uploads();
if (detectaIE()){
$tipo = "image/pjpeg";
} else {
$tipo = "image/jpeg";
}
$uploads = $imagem->upload('imagem', '../../imagens/texturas', $tipo);
$random=rand(0,9999);
$newpicname=$random;
$uploadfile = $newpicname;
$pasta = "imagens/texturas";
$ficheiro = $pasta . "/" . $uploadfile . ".jpg";
if ($uploads->estado == 1){
$obj_imagem->campos = array(array("imagem", "'" . substr($uploads->upload, 6) . "'"));
$update = $actualiza->actualizaRegisto($obj_imagem);
if ($update->estado != 1){
print("Ocorreu o erroC: ".$update->numErro. " - ".$update->erro."<br>".$update->sql);
}
} else if ($uploads->estado == 0){
print("Ocorreu o erroB: ".$uploads->erro);
} else if ($uploads->estado == 2){
print("Ocorreu o erroA: ".$uploads->erroFicheiro . "");
} else {
print("Ocorreu o erroX: ".$uploads->estado);
}
header("Location:../index2.php?cmd=prod&ver=textedit&id=".$_POST['id']);
} else {
print ("ERRO FATAL: " . mysql_error() . "<br />" . $sql);
}
} else {
print("Ocorreu o erroX: ".$update->numErro. " - ".$update->erro."<br>".$update->sql);
}
?>I believe that im near the solution and it might be a problem of bad syntax construction near:
Code: Select all
$obj_imagem->campos = array(array("imagem", "'" . substr($uploads->upload, 6) . "'"));Im quite new to php so please forgive any stupidity from my behalf!
Thank you in advance!