Upload errors in PHP

1

I used the variables you gave me in relation to ... < strong> previous question

 $praBanco .=" '".$file_destination."', ";

 for ($x = 1; $x <=$quantColunas; $x++) {
    $colunas.=" ads_image_".$x." = ";
 } 

 $praBanco = substr($praBanco,0,-1); 
 $colunas = substr($colunas,0,-1);

$colunas and $praBanco

The problem is that ... It does not update because I think something is wrong regarding the entry in the update.

 $smtp_process = "UPDATE public_ads SET ads_title = '$ads_title', ads_content = '$ads_content', ads_price = '$ads_price', edit_attempts = edit_attempts + 1, $colunas = '$praBanco' WHERE ads_id = '$editor_id'"; 
 $smtp_request_query = $con->query($smtp_process);

But ... it does not update nor show errors ...

I think about this: $colunas = '$praBanco'

The goal is for it to add in the Database the path of uploaded images. As done in INSERT, now UPLOAD.

    
asked by anonymous 16.04.2018 / 00:25

1 answer

0

Since you already have $colunas and $praBanco you can loop and concatenate the values of the array elements returned by the explode function of PHP

$explodeColunas = explode(',', $colunas);

$explodePraBanco = explode(',', $praBanco);

for($i = 0; $i<count($explodeColunas); $i++){

    $paraUpadate .= $explodeColunas[$i]."=".$explodePraBanco[$i].",";

}

//para retirar os 3 caracteres do final da string  ,=, ( virgula sinal de igual virgula )
$paraUpadate = substr($paraUpadate,0,-3);

//agora é só colocar esse resultado na declaração UPDATE

$smtp_process = "UPDATE public_ads SET ads_title = '$ads_title', ads_content = '$ads_content', ads_price = '$ads_price', edit_attempts = edit_attempts + 1, $paraUpadate WHERE ads_id = '$editor_id'"; 

See the above code working at ideone

    
16.04.2018 / 00:57