Re: error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remember14a@xxxxxxx wrote:

Dear friends,

Script writes to database, however gives this error while on internet web server, on local host doesn't give same error.

Any guidance, please

Thank you
-----------------------------------------
Back to Main Notice: Undefined index: op in \\premfs15\sites\premium15\mrbushforpeace\webroot\replytopost.php on line 9
------------------------------------------------------------------------------
----
code of php script
------------------------------------------------------------------------------
----
<a href="www.abcdefg.us">Back to Main</a>


<?php
//connect to server and select database; we'll need it soon
$conn = mysql_connect("orf-mysql1.brinkster.com", "mrbushforpeace", "poilkjmnb") or die(mysql_error());
mysql_select_db("mrbushforpeace",$conn) or die(mysql_error());


//check to see if we're showing the form or adding the post
if ($_POST["op"] != "addpost") {
   // showing the form; check for required item in query string
   if (!$_GET["post_id"]) {
        header("Location: topiclist.php");
        exit;
   }

The problem reported in the error message is that PHP can't find the specified element in an array. I assume that line 9 is probably your if line above, with $_POST["op"]. If so, the error means that PHP can't find the index "op" in $_POST. (You should be using single quotes here, e.g. $_POST['op']) This may or may not be a problem in your script.


The reason you see the error message on one machine and not on another is probably because the two machines are set at different error reporting levels. Check the values for error_reporting in your php.ini file. The condition is the same on both machines, whether the notice is displayed or not.

Whether or not the error is a problem depends on what your code is trying to do. You can eliminate the error message by checking whether the array element exists before using it (e.g., isset($_POST['op'])). Or you can just suppress the error message by putting a @ in front of the variable name.

Janet

--
Janet Valade -- janet.valade.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux