/    Sign up×
Community /Pin to ProfileBookmark

Undefined index:

hi, I’m having trouble with code that are works great in online but on my local pc I’m getting errors said

Undefined index: step in C:webserverapachehtdocsindex.php on line 46

please see line 46 where it said

<?php
if (!$_GET[‘step’] && !$_POST[‘step’]) {
?>

does anyone tell me how can i solve this please!

please see in the bold line…

[quote]

<?php
$module_title = ‘Jcow ‘;
$module_name = ‘admin’;
$writable_arr = array(‘./my/config.php’);
require(“./install/db_ctrl.php”);
$default_lang = ‘en’;
require(“./install/lang/$default_lang/install.php”);
$dbtype = ‘MySQL’;
$homeurl = “http://”.$_SERVER[‘HTTP_HOST’].preg_replace(“//install.php/i”,””,$_SERVER[‘REQUEST_URI’]);
if (preg_match(‘/localhost/i’,$homeurl) || preg_match(“/^192.168/i”,$homeurl) || preg_match(“/^10.2./i”,$homeurl) || preg_match(“/^127.0.0/i”,$homeurl)) {
$testing = 1;
}
// header ———————————————————————————————————————-

?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html
xmlns=”http://www.w3.org/1999/xhtml“>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<link href=”install/default.css” rel=”stylesheet” type=”text/css” media=”all” />
<title><?php echo’ TK SNS ‘?></title>
</head>
<body>

<div id=”logo”>
<br>
<span style=”font-size:20px;font-weight:bold”>
TK Network Installation</span>
</div>
<div id=”content”>
<div id=”main”>
[b]<?php
if (!$_GET[‘step’] && !$_POST[‘step’]) {
?>[/b]

<table width=”100%”>
<tr><td colspan=”2″>
<i><?php echo $msg[‘about’]; ?></i>
</td></tr>
<form action=”install.php” method=”post”>
<tr><td colspan=”2″ class=”row1″>
Database
</td></tr>
<tr>
<td align=”left” class=”row2″>
<?php echo $msg[‘dbhost’]; ?></td><td class=”row2″><input type=”text” name=”dbhost” value=”localhost” /></td>
</tr>
<tr>
<td align=”left” class=”row2″><?php echo $msg[‘dbname’]; ?></td><td class=”row2″><input type=”text” name=”dbname” /><br />(The database should be existing)</td>
</tr>

[/quote]

please help thanks.

AM

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 24.2013 — The long form would be:
[code=php]
if ((!isset($_GET['step']) || !$_GET['step']) && (!isset($_POST['step']) || !$_POST['step'])) {
[/code]

A shorter form would be:
[code=php]
(if(empty($_GET['step']) && empty($_POST['step'])) {
[/code]

A shortest form would be:
[code=php]
if(empty($_REQUEST['step'])) {
[/code]
Copy linkTweet thisAlerts:
@redmagebrApr 24.2013 — Try using "isset($_GET['x'])" instead of "!$". You're getting errors because your code is trying to actually access the $_GET['step'] variable. Since it isn't set, it throws an error. Your online server is most likely throwing the same error, it just doesn't report them to you (which is common outside of development servers).

The isset function will return TRUE if the variable inside it exists and FALSE otherwise, so you should be clear. When using it in arrays (which is the case of this example) it will return TRUE if the index exists. This means that if you have set $myArray['something'] isset($myArray) and isset($myArray['something']) will be TRUE, while isset($myArray['Something else']) will be FALSE.
×

Success!

Help @Alidad spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...