Problem with php's rename function


Posted on 16th Feb 2014 07:03 pm by admin

So, i'm having a problem with the php rename function. Basically my script 'delete_user.php' attempts to copy the users xml file(i stored all users information, in xml files as a backup of my database). They're all located in a folder named "xml", which is located in the root directory of my website, as is 'delete_user.php'. What i want to do is, that the file name is changed when the person's user account is deleted. Here's the code i've tried to do it with, i get an 'invalid directory / file error' when i try to run the script.

Code: <?php $path = "/xml/";
// you cannot see it here, but $login contains a username. (The username is the name of the file)
// eg. an user named "sharal" would have an associated xml file named "sharal.xml"
// this is not exactly what i want it to do, but it simply renames the file with it's original name
// and adds "old" behind it
$file = $login;
$old = "old";
$new_path = $login . $old;

rename($path.$file.".xml", $path.$new_path.".xml"); ?>

No comments posted yet

Your Answer:

Login to answer
102 Like 9 Dislike
Previous forums Next forums
Other forums

simple script won't work. Please help
I'm new to php, and I am having trouble displaying a simple script in my web browser. My php code ex

Uploading files/images via forms
Hey all, I am building a database for work that will contain some minor data on plant species along

Content-Disposition: attachment; filename=... not working as i thought it should
taken the following code from the php.net site the script is not working.

what is not happeni

Help: problem with Headers to download PDF file
Hi,

I'm trying to implement a script where when a user clicks a link he gets a PDF file to op

file downloaded can't be read !!
<?php
$fileName = 'mypic.jpg';
$mimeType = 'image/jpeg';
header('content-dispositio

How to store checkbox array in a session, and then be able to add to it?
I'm trying to store an array of checkbox values into a session array, sort of like a shopping cart,

mySQL and PHP search
Hello,
I am trying to code a project and ran into a brick wall with one of my pages. I am pretty

Deleting a record php
Attempting to setup delete a record page. The below code I put together doesn't seem to work.

$_FILES array
Ok,

I just started experimenting with PHP today. My goal right now is to have people be able

Include a php
Hello,

I'm trying to include a function that shows the recent searches.
Example I have <

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash