$_GET . Undefined Variable. Cant find solution [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm having an issue and am out of ideas.
I'm trying to get a parameter from the URL, but PHP insists in saying that the variable is not defined.
The URL is
http://localhost/trendwatcher/index.php?date=2014-10-18
And the script is something like
<?php include "header.php"; ?>
<section id="stats">
Showing trends for <?php echo $GET_["date"]; ?>
</section>
And finally, the error:
Showing trends for
Notice: Undefined variable: GET_ in C:\xampp\htdocs\trendwatcher\index.php on line 4
Does anyone have any ideas?
Thanks!

Fix your code from:
<section id="stats">
Showing trends for <?php echo $GET_["date"]; ?>
</section>
to
<section id="stats">
Showing trends for <?php echo $_GET["date"]; ?>
</section>

Related

What is wrong with this code PHP [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have this code :
<div class="gigel"><?php
// In case there is opening and closing shortcode.
echo do_shortcode('[woocs show_flags=1 width='300px' flag_position='right']');
?></div>
This is shortcode:
[woocs show_flags=1 width='300px' flag_position='right']
This is the error:
Parse error: syntax error, unexpected '300' (T_LNUMBER) in /home/dacproie/public_html/test2/wp/wp-content/themes/mix/header.php on line 189
How can I solve this problem?
Thanks in advance!
just change below code with
<div class="gigel"><?php
// In case there is opening and closing shortcode.
echo do_shortcode("[woocs show_flags=1 width='300px' flag_position='right']");
?></div>
i hope this is working for you.
please, try to clean your code
<?php
$forHtml = do_shortcode("[woocs show_flags=1 width='300px' flag_position='right']");
?>
<!-- separate your layers -->
<div class="gigel"><?php
<?php print ("%s", $forHtml); ?>
?></div>
Always try to use double quotes when you have to use do_shortcode() function.
So use of double quotes instead of single quotes fix your problem and you need to modify it as like :
<div class="gigel">
<?php
echo do_shortcode("[woocs show_flags=1 width='300px' flag_position='right']");
?>
</div>

PHP code is not working in html tags [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
So, I am creating my own error page. And it takes some information from the url.
Here is a code in the top of the error.php
<?php
$error_message = $_GET["error_message"];
if(!$error_message) {
$error_message = "вы оказались здесь из-за сбоя в работе программы.";
}
echo $error_message;
?>
And it works fine. But when I am trying to echo this vatiable in my html code below, nothing happens:
<p>Нам очень жаль, но произошел сбой. Вероятно, <span class="error"><?php echo $error_messsage ?></span>.</p>
I really cant understand, where my problem is.
Thanks for any help.
There's a spelling error in your HTML code. It should be:
<p>Нам очень жаль, но произошел сбой. Вероятно, <span class="error"><?php echo $error_message ?></span>.</p>
One too many "s"s in the variable name in your original code.
Typo error sir :)
<p>Нам очень жаль, но произошел сбой. Вероятно, <span class="error"><?php echo $error_message ?></span>.</p>
Too many s on $error_message;

Error PHP Twitter share [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a problem with this code:
<?php echo 'Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>'; ?>
I get the error:
Parse error: parse error, expecting ','' or';''
You either need to escape all of the single quotes in that string or don't use PHP to output that code (recommended):
<?php
//some php code
?>
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?''http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<?php
// more PHP code
?>
Escaped quotes:
<?php echo 'Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>'; ?>

Store a variable in a external file [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
How can I store a variable in an external file?
Heres the code:
index.php:
<?php
$info=file('sites/test.php')
$titel=trim($info[1]);
echo $title;
?>
sites/test.php:
line1
line2
line3
What I would like index.php to output:
line1
I cant use include_once, because I only want the first line from sites/test.php
Spoonfeeding, I know:
<?php
$info=file('sites/test.php');
$title=trim($info[0]);
echo $title;
?>
Try this:
<?php
$d=explode("\n", file_get_contents('sites/test.php'));
echo $d[0];

php foreach() error message [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
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
Improve this question
I'm creating a mobile website that takes feeds from a rss link and displays it as list..
here is my code
<div data-role="content">
<ul data-role="listview" data-theme="c" data-dividertheme="a" data-counttheme="a">
<?php
foreach($feed->query->results->item as $item) {
?>
<li>
<a href="article.php?notices=<?php echo $siteName;?>&origLink=<?php echo urlencode($item->guid->content);?>">
<?php echo $item->title; ?>
</a>
</li>
<?php } ?>
</ul>
</div>
but this is showing an error on line 12! which is below foreach($feed->query->results->item as $item)
EDIT:
Thanks everyone for your help. The rss link had slow response time so the YQL was timing out.. but now it's working..
Try to check for is_array like
if( is_array($feed->query->results->item) ) {
foreach($feed->query->results->item as $item) {
//The run the foreach loop
}
}
An if it is not an array then print the single result.Even we need to check whether they are getting results or not.
This is just guesswork but I think $feed->query->results->item is not an array. What you meant was $feed->query->results perhaps?
foreach ($feed->query->results as $item) {
// Do stuff
}
I think $feed->query->results->item this is empty. So it would be great if You provide the output of $feed.
then it will be easier to give You the exact result.
$feed->query->results->item is not an array ... or nothing is returning from the DB .. try to var_dump($feed->query->results->item) before the foreach and check if you are looping on the right value

Categories