K
K
kiril90112018-02-02 00:48:08
PHP
kiril9011, 2018-02-02 00:48:08

Why doesn't copy work?

There is a code:

<?php
require 'connect.php';
$sql_select = "SELECT * FROM users WHERE DATEDIFF(blok, NOW()) = 3";
$result = mysql_query($sql_select);
if (!$result) {
return;
}
while ($row = mysql_fetch_assoc($result)) {

mail($row['email'], 'Внимание!!', 'Скоро ваш аккаунт будет заблокирован!', $from);
$file = 'vost.php';
$newfile = "../landing/{$row['login']}/vost.php";

if (!copy($file, $newfile))	;


}


it notifies the client by mail that 3 days before the account is blocked, the notification is ok, but the copy function, i.e. second part of the code, copying doesn't work, why?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
Boris Syomov, 2018-02-02
@kotomyava

In your condition:
Get the error message using php.net/manual/en/function.error-get-last.php and output or log it somewhere. And it becomes clear what is wrong.

V
VelAnna, 2018-02-02
@AnnaVel

The copy() function does not copy files to non-existent directories.
Before copying the file to the directory, you need to check if there is a directory called $row['login'] and if there is no such directory yet, then create it php.net/manual/ru/function.mkdir.php
And after that use copy( )

K
KievRestaurants, 2020-05-08
@KievRestaurants

The use of the rename() function instead of copy() helped me, who would have thought ..)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question