Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
error: "Notice: Undefined index: page in C:\wamp\www\digi\admin\config\setup.php on line 8"
my code is:
<?php
#setup document
//host-username-password-database_name
$db = mysqli_connect('localhost','root','','dynamic');
if($_GET['page'] == "")
{$pg = 'home';}
else
{$pg = $_GET['page'];}
include('/functions/sandbox.php');
include('/functions/template.php');
$page_title = get_page_title($db,$pg);
?>
$_GET['page'] is not defined. To correctly check if it exists you should use isset():
if(isset($_GET['page'])) {$pg = 'home';} else {$pg = $_GET['page'];}
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I declared one variables like this
echo $OPTIONS="500=>250.00, 1000=>500.00,2500=>1100.00,5000=>2250.00";
and
I got this variables through file_get_contents() functions.
$contents = file_get_contents(SERVICE_URL."options_config.php?options=".$OPTIONS);
$package=array($contents)
foreach($package as $pack=>$price)
{
echo $pack;
}
But I got 0 values. What is the problem?
print_r($package);
The result is :
Array ( [0] => 500=>250.00, 1000=>500.00,2500=>1100.00,5000=>2250.00 )
I want the result like this
500 as 250.00
1000 as 500.00
I think what you are looking for is serialize and unserialize
Example: test.php
<?php
// Handle Get Request
// This portion of your code can be on another file
//
if (isset($_GET['getOptions']))
{
$myOptions = array(
500 => 250.00,
1000 => 500.00,
2500 => 1100.00,
5000 => 2250.00
);
exit(serialize($myOptions));
}
// Sample Usage
$options = file_get_contents('http://localhost/test.php?getOptions');
$options = unserialize($options);
// Debug
var_dump($options);
?>
Outputs:
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
<?php
// configuration
require("../includes/config.php");
render("home_form.php", ["title" => "Log In"]);
?>
/**
* Renders template, passing in values.
*/
function render($template, $values = [])
{
// if template exists, render it
if (file_exists("../templates/$template"))
{
// extract variables into local scope
extract($values);
// render header
require("../templates/header.php");
// render template
require("../templates/$template");
// render footer
require("../templates/footer.php");
}
// else err
else
{
trigger_error("Invalid template: $template", E_USER_ERROR);
}
}
replace render("home_form.php", ["title" => "Log In"]);
with
render("home_form.php", array("title" => "Log In"));
and
$values = []
with
$values = array()
Which PHP version do you use?
Short array syntax is available since PHP 5.4.0: http://php.net/manual/en/migration54.new-features.php
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
[16-Aug-2013 01:38:56 America/Sao_Paulo] PHP Parse error: syntax error, unexpected '}' in /home/lineage/public_html/includes/templates/activate.php on line 21
Archive:
<?php
if (!isset($included) || !$included) exit();
if ($hash->validate($_GET['serial']))
if ($_handlerLoginServer->exec($_queryLogin['activateAccount'],array($_GET['serial'])) > 0) {
$account = $_handlerLoginServer->select($_queryLogin['accountSerial'],array($_GET['serial']));
if ($cookie->set("referral")) {
if (!$_handlerLoginServer->select($_queryLogin['checkIP'],array($_SERVER['REMOTE_ADDR'])))
$_handlerLoginServer->execute($_queryLogin['increaseReferral'],array($cookie->get("referral")));
$playerInfo = $_handlerLoginServer->select($_queryLogin['selectPlayer'],array($cookie->get("referral")));
if ($playerInfo[3] % 10 == 0) {
$balance->increase($playerInfo[1],$_config['referralReward']);
$log->add($log->format($_lang['log']['referralReward'],array($_config['referralReward'])),$playerInfo[1]);
}
}
$cookie->delete("referral");
}
$log->add($_lang['log']['activatedAccount'],$account[0]);
$_templatePage->replace("feedback",$_lang['success']['activateAccount']);
} else
$_templatePage->replace("feedback",$_lang['error']['activateAccount']);
} else
$_templatePage->replace("feedback",$_lang['error']['serialFormat']);
?>
On Line 4 and 8 you need to add an opening brace
change line 4
if ($hash->validate($_GET['serial']))
to
if ($hash->validate($_GET['serial'])) {
change line 8
if (!$_handlerLoginServer->select($_queryLogin['checkIP'],array($_SERVER['REMOTE_ADDR'])))
to
if (!$_handlerLoginServer->select($_queryLogin['checkIP'],array($_SERVER['REMOTE_ADDR']))) {
Go to line 4, and add an open squiggily bracket:
<?php
if (!isset($included) || !$included) exit();
if ($hash->validate($_GET['serial'])){
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
Parse error: syntax error, unexpected T_IF, expecting ')'
What should I do?
$show_smileys = true;
$find = array(
'!\[h1\](.+)\[/h1\]!isU',
'!\[b\](.+)\[/b\]!isU',
'!\[i\](.+)\[/i\]!isU',
'!\[u\](.+)\[/u\]!isU',
'!\[strike\](.+)\[/strike\]!isU',
'!\[spoiler\](.+)\[/spoiler\]!isU',
'!\[url=(.*?)\](.*?)\[/url\]!is',
'!\[player\](.+)\[/player\]!isU',
'!\[quote=(.*)\]!siU',
'!\[/quote\]!si'
if ($show_smileys == true) {
,'#:p#is',
'#:eek:#is',
'#:rolleyes:#is',
'#;\)#is',
'#:o#is',
'#:D#is',
'#:\(#is',
'#:mad:#is',
'#:\)#is',
'#:cool:#is'
}
);
You can't include an if condition inside an array. Define the primary portion of your array like this:
$find = array(
'!\[h1\](.+)\[/h1\]!isU',
'!\[b\](.+)\[/b\]!isU',
'!\[i\](.+)\[/i\]!isU',
'!\[u\](.+)\[/u\]!isU',
'!\[strike\](.+)\[/strike\]!isU',
'!\[spoiler\](.+)\[/spoiler\]!isU',
'!\[url=(.*?)\](.*?)\[/url\]!is',
'!\[player\](.+)\[/player\]!isU',
'!\[quote=(.*)\]!siU',
'!\[/quote\]!si'
);
And then use a condition to merge the rest:
if ($show_smileys == true) {
$smiles = array(
'#:p#is',
'#:eek:#is',
'#:rolleyes:#is',
'#;\)#is',
'#:o#is',
'#:D#is',
'#:\(#is',
'#:mad:#is',
'#:\)#is',
'#:cool:#is'
);
$final = array_merge($find, $smiles);
}
You can't put if in the middle of an array, it can only be used where statements are allowed. Do it this way:
$find = array(
'!\[h1\](.+)\[/h1\]!isU',
'!\[b\](.+)\[/b\]!isU',
'!\[i\](.+)\[/i\]!isU',
'!\[u\](.+)\[/u\]!isU',
'!\[strike\](.+)\[/strike\]!isU',
'!\[spoiler\](.+)\[/spoiler\]!isU',
'!\[url=(.*?)\](.*?)\[/url\]!is',
'!\[player\](.+)\[/player\]!isU',
'!\[quote=(.*)\]!siU',
'!\[/quote\]!si'
);
$smileys = array(
'#:p#is',
'#:eek:#is',
'#:rolleyes:#is',
'#;\)#is',
'#:o#is',
'#:D#is',
'#:\(#is',
'#:mad:#is',
'#:\)#is',
'#:cool:#is'
);
if ($show_smileys) {
$find = array_merge($find, $smileys);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
public function run() {
$this->step = $this->$_POST("step", 1);
$this->xml = new XMLFile();
$common_data = array(
'STEPCONTENT' => $this->get_step_content(),
'STEPNUMBER' => $this->step,
'STEPTITLE' => $this->get_step_title()
);
echo $this->parse($this->common_template, $common_data);
This gives the exception:
Fatal error: Method name must be a string in
C:\xampp\htdocs\test\openad\install\InstallOpenAdServer.php on line 674
Why?
This is the culprit
$this->step = $this->$_POST("step", 1);
You cannot use an $_POST super global array as a function. If you are trying to access the vairable from the $_POST, you can simple do this
$this->step = $_POST["step"];