I'm trying to put a php script to resize images dynamically, until then I had no problem. I have a folder that gets saved the images that were edited by the script and the images arrive right, but I wanted the image name to be also saved in the database.
$sql = "SELECT * FROM foto WHERE foto = '6671.jpg' OR foto = '6672.jpg'";
$query = mysqli_query($conecta, $sql);
while ($linha = mysqli_fetch_array($query)) {
$img_origem = ImageCreateFromJpeg($linha['foto']);
$largura = imagesx($img_origem);
$altura = imagesy($img_origem);
$nova_largura = 200;
$nova_altura = $altura * $nova_largura / $largura;
$img_destino = imagecreatetruecolor($nova_largura, $nova_altura);
imagecopyresampled($img_destino, $img_origem, 0, 0, 0, 0, $nova_largura, $nova_altura, $largura, $altura);
$up = imageJPEG($img_destino,'teste/'. rand() . '.jpg', 85);
$sql = "INSERT INTO foto (foto) VALUES ('" . $up . "')";
$query = mysqli_query($conecta, $sql);
}