You are here: Re: problems using copy() and rename() « PHP Programming Language « IT news, forums, messages
Re: problems using copy() and rename()

Posted by Jerry Stuckle on 10/22/06 13:40

mantrid wrote:
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:8padnZI6cLYiTKfYnZ2dnUVZ_sidnZ2d@comcast.com...
>
>>mantrid wrote:
>>
>>>"peter" <submit@flexiwebhost.com> wrote in message
>>>news:ehe92r$ps7$1@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.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация