Jump to content

Migration from linux -> windows and errors


illuz1on

Recommended Posts

Hey

 

I moved a php script of mine over to a windows machine and im getting the following errors after the move:

 

Notice: Undefined index: op in C:\Nanoson Sites\Personalised Promotions\personal.co.za\ouwewerf\login.php on line 6

 

 

Anyone know what might cause this?

 

Thanks

illuz1on

Link to comment
https://forums.phpfreaks.com/topic/58248-migration-from-linux-windows-and-errors/
Share on other sites

Anyone know what might cause this?

 

Poor coding practice. Your trying to access variables that dont exist.

 

Simply put, the Linux setup must have had a lower error setting. You can simply get rid of the errors by turning error reporting down, or better still, fix them in your code.

 

Post some code if need be.

To fix the problems for the undefined index, something like this is what I use

 

<?php
$id = isset($_POST['id'])?$_POST['id']:'';

// or better yet create a function

function check_isset($array, $id) {
      return isset($array[$id])?$array[$id]:'';
}

$id = check_isset($_POST, 'id');
?>

 

Either way would avoid the notice undefined index error.

 

For the out of range question, post relevant code.

This is the code for the insert.php:

 

<?
include("db.php");

$title = $_POST["title"];
$fromz = $_POST["fromz"];
$toz = $_POST["toz"];
$description = $_POST["description"];
$contactname = $_POST["contactname"];
$contacttel = $_POST["contacttel"];
$contactemail = $_POST["contactemail"];
$type = $_POST["type"];

$addoffer = MYSQL_QUERY("INSERT INTO specialoffer (id,title,fromz,toz,contacttel,contactname,contactemail,description,type)". "VALUES ('NULL', '$title', '$fromz', '$toz', '$contacttel', '$contactname', '$contactemail', '$description', '$type')") or die (mysql_error ());

echo("Special Offer Added!<br>");
echo "<br>";
echo("<b>Type of offer: $type");
echo("<br>");
echo("<b>Title:</b> $title<br>");
echo("<b>Validity - From:</b> $fromz <b>untill</b> $toz<br>");
echo("<b>Contact Name:</b> $contactname<br>");
echo("<b>Contact Tel:</b> $contacttel<br>");
echo("<b>Contact E-Mail:</b> $contactemail<br>");
echo("<b>Description:</b> $description<br>");
echo "<br>";
echo "<a href=\"display1.php\">View offers</a> | <a href=\"admin.php\">Back to administrstion</a>";
?>

Is the id field auto incrementing? If so... just leave it out of your query all together.

 

$addoffer = MYSQL_QUERY("INSERT INTO specialoffer (title,fromz,toz,contacttel,contactname,contactemail,description,type)". "VALUES ('$title', '$fromz', '$toz', '$contacttel', '$contactname', '$contactemail', '$description', '$type')") or die (mysql_error ());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.