473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problems using copy() and rename()

Im trying to move a file but am having luck
my code is below. The temp and target paths are valid as they echo
correctly. but I cant get the copy() function to work, or the rename()
function

$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);

echo "Target - ".$target_path." Temp - ".$temp_path."<br>";

copy($temp_path, $target_path);

has any one experienced this problem?

Ian

Oct 21 '06 #1
12 2865

"mantrid" <ia********@virgin.netwrote in message
news:%7*************@newsfe5-win.ntli.net...
Im trying to move a file but am having luck
my code is below. The temp and target paths are valid as they echo
correctly. but I cant get the copy() function to work, or the rename()
function

$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);

echo "Target - ".$target_path." Temp - ".$temp_path."<br>";

copy($temp_path, $target_path);

has any one experienced this problem?
are you receiving any error if so what is it? Also if it is as it looks and
is a file that has been uploaded then why not use the move_uploaded_file()
function.
Oct 21 '06 #2

"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>
"mantrid" <ia********@virgin.netwrote in message
news:%7*************@newsfe5-win.ntli.net...
Im trying to move a file but am having luck
my code is below. The temp and target paths are valid as they echo
correctly. but I cant get the copy() function to work, or the rename()
function

$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);

echo "Target - ".$target_path." Temp - ".$temp_path."<br>";

copy($temp_path, $target_path);

has any one experienced this problem?

are you receiving any error if so what is it? Also if it is as it looks
and
is a file that has been uploaded then why not use the move_uploaded_file()
function.

I tried with the move_uploaded_file() originally but this didnt work
either. I thought maybe it only works initially with $_FILES as I understand
it checks that a file has been uploaded and returns negative if it cant find
one.
Ther is no error message it appears to work as my success message is
displayed but the file is not there
Oct 21 '06 #3

"mantrid" <ia********@virgin.netwrote in message
news:eU*******************@newsfe6-gui.ntli.net...
>
"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...

"mantrid" <ia********@virgin.netwrote in message
news:%7*************@newsfe5-win.ntli.net...
Im trying to move a file but am having luck
my code is below. The temp and target paths are valid as they echo
correctly. but I cant get the copy() function to work, or the rename()
function
>
$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);
>
echo "Target - ".$target_path." Temp - ".$temp_path."<br>";
>
copy($temp_path, $target_path);
>
has any one experienced this problem?
>


are you receiving any error if so what is it? Also if it is as it looks
and
is a file that has been uploaded then why not use the
move_uploaded_file()
function.

I tried with the move_uploaded_file() originally but this didnt work
either. I thought maybe it only works initially with $_FILES as I
understand
it checks that a file has been uploaded and returns negative if it cant
find
one.
Ther is no error message it appears to work as my success message is
displayed but the file is not there

Here is the full code. as you can see ive commented out much of it to try
and narrow down the problem. Ive used an echo to check that the session
variables are valid. but the file just will not move

$userid=$_SESSION[userid];
$delquest=$_SESSION[delquest];
$archivequest=$_SESSION[archivequest];
$changedquests=$_SESSION[changed];
$questids=$_SESSION[questids];
$imagechanged=$_SESSION[imagechanged];
$delimage=$_SESSION['delimage'];
$msg=$_SESSION['msg'];
$uploadedfile=$_SESSION['uploadedfile'];
$imagepath=$_SESSION['imagepath'];
$questuserid=$_SESSION[questuserid];
$imagequestindex=$_SESSION[imagequestindex];

if(count($imagechanged)>0){
$targetdir = "pupiltester/";
$tempdir= "temp/";
$allowed_file_types = "(jpg|jpeg|gif|bmp|png)";
for ($x = 0; $x < count($imagequestindex); $x++){
if(!empty($uploadedfile["name"][$x])){

$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);
$imagefile=$imagepath[$x];
echo "Userid - ".$questuserid[$x]." Target - ".$target_path." Temp -
".$temp_path." To replace - ".$imagefile."<br>";
copy("$temp_path", "$target_path");
//if($uploadedfile["size"][$x] < 35841) {
//if(preg_match("/\." . $allowed_file_types . "$/i",
$uploadedfile["name"][$x])) {
if(file_exists($target_path)){
//if($questuserid[$x]=$userid){
$sql2 = "UPDATE questions SET
ImagePath='".$uploadedfile["name"][$x]."' WHERE ImagePath='".$imagefile."'";
$addquest = mysql_query($sql2) or $msg.="<br><span
class='RedWarning'>Problem adding image name ".$uploadedfile['name'][$x]."
to database: " . mysql_error()."</span>";

if(file_exists($targetdir.$imagefile)){unlink($tar getdir.$imagefile);}
//$msg.="<br><span class='greenbody'>Link formed to your existing
file by the name of ".$uploadedfile["name"][$x].".</span>";
//}else{
//$msg.="<br><span class='RedWarning'>A image by the name of
".$uploadedfile["name"][$x]." already exists for another users question.
Please rename it and try again.</span>";
//}
}else{
rename($temp_path, $target_path);
//if(move_uploaded_file($temp_path, $target_path)){
//$msg.="<br><span class='greenbody'>Uploaded the image
".$uploadedfile["name"][$x]." (" .$uploadedfile["type"][$x]. ",
".ceil($uploadedfile["size"][$x] / 1024) . " Kb).</span>";
//if($uploadedfile['name'][$x]!==''){
$sql2 = "UPDATE questions SET
ImagePath='".$uploadedfile["name"][$x]."' WHERE ImagePath='".$imagefile."'";
$addquest = mysql_query($sql2) or $msg.="<br><span
class='RedWarning'>Problem adding image name ".$uploadedfile['name'][$x]."
to database: " . mysql_error()."</span>";

if(file_exists($targetdir.$imagefile)){unlink($tar getdir.$imagefile);}
//}
//}else{
//$msg.="<br><span class='Red Warning'>Error uploading image -
".$uploadedfile['name'][$x].$uploadedfile['error'][$x]."</span>";
//}
}
//}else{
//$msg.="<br><span
class='RedWarning'>".$uploadedfile['name'][$x].$uploadedfile['error'][$x]."
not uploaded. Not a valid image file.</span>";
//}
//}else{
//$msg.="<br><span class='RedWarning'>".$uploadedfile['name'][$x]." is
greater than 35Kb.</span>";
//}
}
}
//$_SESSION['msg']=$msg;
//echo("<br><br><div align='center'>".$msg."<br><br><a
href='usersquestions.php' class='BodyLink'>Return</a></div>");
}

Oct 21 '06 #4

"mantrid" <ia********@virgin.netwrote in message
news:kZ*******************@newsfe6-gui.ntli.net...
>
"mantrid" <ia********@virgin.netwrote in message
news:eU*******************@newsfe6-gui.ntli.net...

"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>
"mantrid" <ia********@virgin.netwrote in message
news:%7*************@newsfe5-win.ntli.net...
Im trying to move a file but am having luck
my code is below. The temp and target paths are valid as they echo
correctly. but I cant get the copy() function to work, or the
rename()
function

$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);

echo "Target - ".$target_path." Temp - ".$temp_path."<br>";

copy($temp_path, $target_path);

has any one experienced this problem?

>

are you receiving any error if so what is it? Also if it is as it
looks
and
is a file that has been uploaded then why not use the
move_uploaded_file()
function.
>
>
I tried with the move_uploaded_file() originally but this didnt work
either. I thought maybe it only works initially with $_FILES as I
understand
it checks that a file has been uploaded and returns negative if it cant
find
one.
Ther is no error message it appears to work as my success message is
displayed but the file is not there

Here is the full code. as you can see ive commented out much of it to try
and narrow down the problem. Ive used an echo to check that the session
variables are valid. but the file just will not move

$userid=$_SESSION[userid];
$delquest=$_SESSION[delquest];
$archivequest=$_SESSION[archivequest];
$changedquests=$_SESSION[changed];
$questids=$_SESSION[questids];
$imagechanged=$_SESSION[imagechanged];
$delimage=$_SESSION['delimage'];
$msg=$_SESSION['msg'];
$uploadedfile=$_SESSION['uploadedfile'];
$imagepath=$_SESSION['imagepath'];
$questuserid=$_SESSION[questuserid];
$imagequestindex=$_SESSION[imagequestindex];

if(count($imagechanged)>0){
$targetdir = "pupiltester/";
$tempdir= "temp/";
$allowed_file_types = "(jpg|jpeg|gif|bmp|png)";
for ($x = 0; $x < count($imagequestindex); $x++){
if(!empty($uploadedfile["name"][$x])){

$target_path = $targetdir . basename($uploadedfile["name"][$x]);
$temp_path = $tempdir. basename($uploadedfile["name"][$x]);
$imagefile=$imagepath[$x];
echo "Userid - ".$questuserid[$x]." Target - ".$target_path."
Temp -
".$temp_path." To replace - ".$imagefile."<br>";
copy("$temp_path", "$target_path");
//if($uploadedfile["size"][$x] < 35841) {
//if(preg_match("/\." . $allowed_file_types . "$/i",
$uploadedfile["name"][$x])) {
if(file_exists($target_path)){
//if($questuserid[$x]=$userid){
$sql2 = "UPDATE questions SET
ImagePath='".$uploadedfile["name"][$x]."' WHERE
ImagePath='".$imagefile."'";
$addquest = mysql_query($sql2) or $msg.="<br><span
class='RedWarning'>Problem adding image name ".$uploadedfile['name'][$x]."
to database: " . mysql_error()."</span>";

if(file_exists($targetdir.$imagefile)){unlink($tar getdir.$imagefile);}
//$msg.="<br><span class='greenbody'>Link formed to your existing
file by the name of ".$uploadedfile["name"][$x].".</span>";
//}else{
//$msg.="<br><span class='RedWarning'>A image by the name of
".$uploadedfile["name"][$x]." already exists for another users question.
Please rename it and try again.</span>";
//}
}else{
rename($temp_path, $target_path);
//if(move_uploaded_file($temp_path, $target_path)){
//$msg.="<br><span class='greenbody'>Uploaded the image
".$uploadedfile["name"][$x]." (" .$uploadedfile["type"][$x]. ",
".ceil($uploadedfile["size"][$x] / 1024) . " Kb).</span>";
//if($uploadedfile['name'][$x]!==''){
$sql2 = "UPDATE questions SET
ImagePath='".$uploadedfile["name"][$x]."' WHERE
ImagePath='".$imagefile."'";
$addquest = mysql_query($sql2) or $msg.="<br><span
class='RedWarning'>Problem adding image name ".$uploadedfile['name'][$x]."
to database: " . mysql_error()."</span>";

if(file_exists($targetdir.$imagefile)){unlink($tar getdir.$imagefile);}
//}
//}else{
//$msg.="<br><span class='Red Warning'>Error uploading image -
".$uploadedfile['name'][$x].$uploadedfile['error'][$x]."</span>";
//}
}
//}else{
//$msg.="<br><span
class='RedWarning'>".$uploadedfile['name'][$x].$uploadedfile['error'][$x]."
not uploaded. Not a valid image file.</span>";
//}
//}else{
//$msg.="<br><span class='RedWarning'>".$uploadedfile['name'][$x]."
is
greater than 35Kb.</span>";
//}
}
}
//$_SESSION['msg']=$msg;
//echo("<br><br><div align='center'>".$msg."<br><br><a
href='usersquestions.php' class='BodyLink'>Return</a></div>");
}
OK ive played around with it and have found the following

THIS DOESNT WORK

$targetdir = "pupiltester/";
$tempdir= "temp/";

$target_path = $targetdir."Arm.jpg";
$temp_path = $tempdir."Arm.jpg";
rename($temp_path, $target_path);

BUT THIS DOES

$target_path = "pupiltester/Arm.jpg";
$temp_path = "temp/Arm.jpg";
rename($temp_path, $target_path);

I cant see it am I being completely thick and missing something obvious
Oct 21 '06 #5
OK ive played around with it and have found the following

THIS DOESNT WORK

$targetdir = "pupiltester/";
$tempdir= "temp/";

$target_path = $targetdir."Arm.jpg";
$temp_path = $tempdir."Arm.jpg";
rename($temp_path, $target_path);

BUT THIS DOES

$target_path = "pupiltester/Arm.jpg";
$temp_path = "temp/Arm.jpg";
rename($temp_path, $target_path);

I cant see it am I being completely thick and missing something obvious
that is mighty strange because essentially they are the same thing. Have you
tried using full path's instead of relative paths?
Oct 21 '06 #6

"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>
>OK ive played around with it and have found the following

THIS DOESNT WORK

$targetdir = "pupiltester/";
$tempdir= "temp/";

$target_path = $targetdir."Arm.jpg";
$temp_path = $tempdir."Arm.jpg";
rename($temp_path, $target_path);

BUT THIS DOES

$target_path = "pupiltester/Arm.jpg";
$temp_path = "temp/Arm.jpg";
rename($temp_path, $target_path);

I cant see it am I being completely thick and missing something obvious

that is mighty strange because essentially they are the same thing. Have
you tried using full path's instead of relative paths?
also just to further on my previous post.

Is there a reason you are storing the paths in the session? just seems a
strange thing to do. Are they changing depending on the user.

Regarding not receiving an error ensure you have the following at the top of
your script:-

error_reporting(E_ALL);

It is possible that the errors are being supressed for some reason (possibly
the default error reporting level in the php.ini file set too low)
Oct 21 '06 #7

"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>
"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
OK ive played around with it and have found the following

THIS DOESNT WORK

$targetdir = "pupiltester/";
$tempdir= "temp/";

$target_path = $targetdir."Arm.jpg";
$temp_path = $tempdir."Arm.jpg";
rename($temp_path, $target_path);

BUT THIS DOES

$target_path = "pupiltester/Arm.jpg";
$temp_path = "temp/Arm.jpg";
rename($temp_path, $target_path);

I cant see it am I being completely thick and missing something obvious
that is mighty strange because essentially they are the same thing. Have
you tried using full path's instead of relative paths?

also just to further on my previous post.

Is there a reason you are storing the paths in the session? just seems a
strange thing to do. Are they changing depending on the user.
The paths are not used directly after the form they are created on is
posted. A page detailing the changes to be made is shown first and only when
the user clicks continue does the file with the rename function open Hence
the use of sessions to carry everything forward.

Regarding not receiving an error ensure you have the following at the top
of
your script:-

error_reporting(E_ALL);
That has thrown up lots of notices, most of which are of the type:
Notice: Use of undefined constant archivequest - assumed 'archivequest' in
.......

seems to be picking up all my variables ie in the above example
$archivequest do you know how to clear these type of notices?
It is possible that the errors are being supressed for some reason
(possibly
the default error reporting level in the php.ini file set too low)
It doesn't seem to affect other error messages. it is strange that it is
only happening in this case.
I have been doing some work on this page all day Ive just

put
$targetdir = "pupiltester/";
$tempdir= "temp/";

back in. And now it works. Dont know what I did but its ok now.

Oct 21 '06 #8
That has thrown up lots of notices, most of which are of the type:
Notice: Use of undefined constant archivequest - assumed 'archivequest' in
......

seems to be picking up all my variables ie in the above example
$archivequest do you know how to clear these type of notices?
had a quick look over your code and the reason for those errors are as
follows:-

you have lines such as:-

$archivequest=$_SESSION[archivequest];

it should be:-

$archivequest=$_SESSION['archivequest'];

because you do not have the quotes around them it is assuming they are
constants but as no constant is there it is using it as a string. This will
not always be the desired effect. Try and work with the error reporting
level that I already mentioned and it will cut down on alot of possible bugs
in your code.
Oct 21 '06 #9

"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>
That has thrown up lots of notices, most of which are of the type:
Notice: Use of undefined constant archivequest - assumed 'archivequest'
in
......

seems to be picking up all my variables ie in the above example
$archivequest do you know how to clear these type of notices?

had a quick look over your code and the reason for those errors are as
follows:-

you have lines such as:-

$archivequest=$_SESSION[archivequest];

it should be:-

$archivequest=$_SESSION['archivequest'];

because you do not have the quotes around them it is assuming they are
constants but as no constant is there it is using it as a string. This
will
not always be the desired effect. Try and work with the error reporting
level that I already mentioned and it will cut down on alot of possible
bugs
in your code.

That seems to have done it all except these ones

Notice: Undefined index: cancel in
/home/iddsoftw/public_html/questiondbase/questionupdate.php on line 11

Warning: Cannot modify header information - headers already sent by (output
started at /home/iddsoftw/public_html/questiondbase/questionupdate.php:11)
in /home/iddsoftw/public_html/questiondbase/questionupdate.php on line 17
refering to the top of my page (below)
<?php
session_start();
error_reporting(E_ALL); //show all errors

ini_set( "session.bug_compat_warn", "off" );

if(!isset($_SESSION['userid'])){
header("Location: http://www.site.co.uk/forbidden.html");
}

$cancel=$_POST['cancel'];
if(isset($cancel)){
header("Location: http://www.site.co.uk/path/my.php");
}else{
header("Cache-control: private"); //IE 6 Fix
include("../include/idd.php");

?>
<html>
<head>

<link href="../CSS/body.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
$userid=$_SESSION['userid'];
$delquest=$_SESSION['delquest'];
$archivequest=$_SESSION['archivequest'];
$changedquests=$_SESSION['changed'];
$questids=$_SESSION['questids'];
$imagechanged=$_SESSION['imagechanged'];
$delimage=$_SESSION['delimage'];
$msg=$_SESSION['msg'];
$uploadedfile=$_SESSION['uploadedfile'];
$imagepath=$_SESSION['imagepath'];
$questuserid=$_SESSION['questuserid'];
$imagequestindex=$_SESSION['imagequestindex'];

$targetdir = "pupiltester/";
$tempdir= "temp/";
CODE HERE

unset($_SESSION['delquest']);
unset($_SESSION['archivequest']);
unset($_SESSION['changed']);
unset($_SESSION['questids']);
unset($_SESSION['iseditable']);
unset($_SESSION['imagechanged']);
unset($_SESSION['uploadedfile']);
unset($_SESSION['cost']);
unset($_SESSION['question']);
unset($_SESSION['opta']);
unset($_SESSION['optb']);
unset($_SESSION['optc']);
unset($_SESSION['optd']);
unset($_SESSION['opte']);
unset($_SESSION['ans1']);
unset($_SESSION['ans2']);
unset($_SESSION['ans3']);
unset($_SESSION['ans4']);
unset($_SESSION['ans5']);
unset($_SESSION['ans6']);
unset($_SESSION['ans7']);
unset($_SESSION['ans8']);
unset($_SESSION['ans9']);
unset($_SESSION['ans10']);
unset($_SESSION['msg']);
unset($_SESSION['delimage']);
unset($_SESSION['imagepath']);
unset($_SESSION['imagequestindex']);
?>
</body>
</html>
<?php
}
?>
Oct 22 '06 #10
mantrid wrote:
"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>>>That has thrown up lots of notices, most of which are of the type:
Notice: Use of undefined constant archivequest - assumed 'archivequest'

in
>>>......

seems to be picking up all my variables ie in the above example
$archivequest do you know how to clear these type of notices?

had a quick look over your code and the reason for those errors are as
follows:-

you have lines such as:-

$archivequest=$_SESSION[archivequest];

it should be:-

$archivequest=$_SESSION['archivequest'];

because you do not have the quotes around them it is assuming they are
constants but as no constant is there it is using it as a string. This

will
>>not always be the desired effect. Try and work with the error reporting
level that I already mentioned and it will cut down on alot of possible

bugs
>>in your code.



That seems to have done it all except these ones

Notice: Undefined index: cancel in
/home/iddsoftw/public_html/questiondbase/questionupdate.php on line 11

Warning: Cannot modify header information - headers already sent by (output
started at /home/iddsoftw/public_html/questiondbase/questionupdate.php:11)
in /home/iddsoftw/public_html/questiondbase/questionupdate.php on line 17
refering to the top of my page (below)
<?php
session_start();
error_reporting(E_ALL); //show all errors

ini_set( "session.bug_compat_warn", "off" );

if(!isset($_SESSION['userid'])){
header("Location: http://www.site.co.uk/forbidden.html");
}

$cancel=$_POST['cancel'];
if(isset($cancel)){
header("Location: http://www.site.co.uk/path/my.php");
}else{
<snip>

It's saying $_POST['cancel'] isn't set, so the statement

$cancel=$_POST['cancel'];

is referencing a key ('cancel') which doesn't exist.

It should be something like:

if ($isset($_POST['cancel']) {
header("Location: http://www.site.co.uk/path/my.php");
}
else {
....

The "headers already sent" error error is because of the first error
message.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 22 '06 #11
Thanks thats solved it.
I read somewhere you should assign posted info to variables at the top of
the script so that it will make managing the code easier. Hence my
$cancel=$_POST['cancel'];
is this not the case?

Ian

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:8p******************************@comcast.com. ..
mantrid wrote:
"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>>That has thrown up lots of notices, most of which are of the type:
Notice: Use of undefined constant archivequest - assumed 'archivequest'
in
>>......

seems to be picking up all my variables ie in the above example
$archivequest do you know how to clear these type of notices?

had a quick look over your code and the reason for those errors are as
follows:-

you have lines such as:-

$archivequest=$_SESSION[archivequest];

it should be:-

$archivequest=$_SESSION['archivequest'];

because you do not have the quotes around them it is assuming they are
constants but as no constant is there it is using it as a string. This
will
>not always be the desired effect. Try and work with the error reporting
level that I already mentioned and it will cut down on alot of possible
bugs
>in your code.


That seems to have done it all except these ones

Notice: Undefined index: cancel in
/home/iddsoftw/public_html/questiondbase/questionupdate.php on line 11

Warning: Cannot modify header information - headers already sent by
(output
started at
/home/iddsoftw/public_html/questiondbase/questionupdate.php:11)
in /home/iddsoftw/public_html/questiondbase/questionupdate.php on line
17


refering to the top of my page (below)
<?php
session_start();
error_reporting(E_ALL); //show all errors

ini_set( "session.bug_compat_warn", "off" );

if(!isset($_SESSION['userid'])){
header("Location: http://www.site.co.uk/forbidden.html");
}

$cancel=$_POST['cancel'];
if(isset($cancel)){
header("Location: http://www.site.co.uk/path/my.php");
}else{
<snip>

It's saying $_POST['cancel'] isn't set, so the statement

$cancel=$_POST['cancel'];

is referencing a key ('cancel') which doesn't exist.

It should be something like:

if ($isset($_POST['cancel']) {
header("Location: http://www.site.co.uk/path/my.php");
}
else {
...

The "headers already sent" error error is because of the first error
message.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 22 '06 #12
mantrid wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:8p******************************@comcast.com. ..
>>mantrid wrote:
>>>"peter" <su****@flexiwebhost.comwrote in message
news:eh**********@aioe.org...
>That has thrown up lots of notices, most of which are of the type:
>Notice: Use of undefined constant archivequest - assumed 'archivequest'

in
>......
>
>seems to be picking up all my variables ie in the above example
>$archivequest do you know how to clear these type of notices?

had a quick look over your code and the reason for those errors are as
follows:-

you have lines such as:-

$archivequest=$_SESSION[archivequest];

it should be:-

$archivequest=$_SESSION['archivequest'];

because you do not have the quotes around them it is assuming they are
constants but as no constant is there it is using it as a string. This

will
not always be the desired effect. Try and work with the error reporting
level that I already mentioned and it will cut down on alot of possible

bugs
in your code.


That seems to have done it all except these ones

Notice: Undefined index: cancel in
/home/iddsoftw/public_html/questiondbase/questionupdate.php on line 11

Warning: Cannot modify header information - headers already sent by

(output
>>>started at

/home/iddsoftw/public_html/questiondbase/questionupdate.php:11)
>>>in /home/iddsoftw/public_html/questiondbase/questionupdate.php on line

17
>>>
refering to the top of my page (below)
<?php
session_start();
error_reporting(E_ALL); //show all errors

ini_set( "session.bug_compat_warn", "off" );

if(!isset($_SESSION['userid'])){
header("Location: http://www.site.co.uk/forbidden.html");
}

$cancel=$_POST['cancel'];
if(isset($cancel)){
header("Location: http://www.site.co.uk/path/my.php");
}else{

<snip>

It's saying $_POST['cancel'] isn't set, so the statement

$cancel=$_POST['cancel'];

is referencing a key ('cancel') which doesn't exist.

It should be something like:

if ($isset($_POST['cancel']) {
header("Location: http://www.site.co.uk/path/my.php");
}
else {
...

The "headers already sent" error error is because of the first error
message.

Thanks thats solved it.
I read somewhere you should assign posted info to variables at the top of
the script so that it will make managing the code easier. Hence my
$cancel=$_POST['cancel'];
is this not the case?

Ian
(Top posting fixed)

Yes, it's often good to do it that way. But that's only 1/2 of it. You
must also ensure that the variable is set before you try to assign it!

If $_POST['cancel'] is not set, you get just the error you saw - because
you didn't have a button/checkbox/field/whatever named 'cancel' passed
from the browser.

P.S. Please don't top post. Thanks.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 22 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Skeleton Man | last post by:
Hi, Upon installing Oracle 9i (9.2.0.1.0) on a Debian box, the whole install process completes, but when I get to the very end and it trys to setup configuration assistants, all three fail with...
3
by: ano1optimist | last post by:
I'm trying to rename a shared network file after uploading the data using an import data specification. I tried using NAME oldfilename AS newfilename and got the generic "File not found"...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
0
by: Rich G | last post by:
I am using vb.net and the Systm.io namespace for a document management project. The program receives files named with a GUID and an XML file loaded with metadata. One the fields is the real name of...
1
by: electrixnow | last post by:
Help!, I need to compile this code with static libs so it run on another XP machine that does'nt have MS Studio installed. When I compile now I get an ERROR: 1>------ Rebuild All started:...
10
by: Janelle.Dunlap | last post by:
In the database that I am creating I need to be able to rename the file with a name that the user specifies using the Save As Dialog window (I already have the code that brings up this window). In...
10
by: Cliff | last post by:
Greetings, I have been trying to teach myself C++ over the past few weeks and have finally came across a problem I could not fix. I made a simple program that prints out a square or rectangle...
9
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hi, Is it possible (w/o generating a gazillion errors) to copy a form in VS 2005 so that it can be modified and reused. In other words, I have a form, alot of which I wish to use in a different...
0
by: ishay44 | last post by:
Hello! I try to build (using Visual 2005 and Excel 2007) the example described in the Microsoft Help and Support "How to automate Excel from MFC and Visual C++ 2005 or Visual C++ .NET to fill or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.