Upload errors in PHP

Asked

Viewed 37 times

0

I used the variables you gave me regarding... 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... It does not update because I think something is wrong regarding the update entry.

 $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 or show errors...

I think it’s about this: $colunas = '$praBanco'

The goal is that it add in the Database the path of the uploaded images. As was done in INSERT, click now UPLOAD.

  • How can I fix Upload?

1 answer

0


As you already have $colunas and $praBanco can loop and concatenate the values respectively of the elements of the arrays returned by the function explode 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 on ideone inserir a descrição da imagem aqui

  • It was a mistake. He says that Notice: Undefined variable: paraUpadate in D: xampp htdocs Superfacil_v1.7.9 inc Creator class_edit_ads.php on line 210 Notice: Undefined offset: 1 in D: xampp htdocs Superfacil_v1.7.9 inc Creator class_edit_ads.php on line 210

  • Error was here: $forUpadate .= $explodeColunas[$i]."=". $explodePraBanco[$i].",";

  • I did tests here and ran it correctly. It makes a echo $paraUpadate and see if it’s mounted correctly

  • Stay like this... Notice: Undefined offset: 1 in D: xampp htdocs Superfacil_v1.7.9 inc Creator class_edit_ads.php on line 211 string(118) " ads_image_1 = ads_image_2 = ads_image_3 == 'im/pd/5ad3dd6bd58c86.55498080.jpg',= 'im/pd/5ad3dd6bda312.43966416.jp"

  • But the way it guards is wrong ads_image_1 = ads_image_2 = ads_image_3 == 'im/pd/5ad3dd6bd58c86.55498080.jpg',= 'im/pd/5ad3dd6bd5a312.43966416.jp"

  • Goal is to send 1 or 3 files... 1 seems to send well, now the remaining 2 not.. "==" are... interfering..

  • Ok, I’ve fixed it... I’ve had it, but it’s still showing Undefined offset: 1 /2/3....

  • You need to declare the variables not to give error of Undefined variable: That is primary hehehe

  • Sure, but at this time it’s hard to see, but... Apart from the =, it’s NULL in the Database fields... : D and with = (giving the Undefined variable) it results... and the variables are set there above with $x = ''

  • I edited the answer and put it on ideone to run, running without errors. Nothing else I can do. From now on you’d have to be a fortune teller to know what you did in your code.

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.