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>'; ?>
Related
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 am trying to display an image using a variable "$images" that contains the URL parsed form an API.
This is my code:
echo "<td>""<img src='",$image,"'>""</td>\n";
I assume there is a typo I cannot detect because I get a blank screen when running this.
echo "<td>"."<img src='".$image."'>"."</td>";
Or
echo "<td><img src='".$image."'></td>";
You were missing the dots/commas after/before the td tags
use . not ,
<img src='".$image."'>
PHP requires that you chain your strings together using a .
E.g.
echo 'Test' . ' ' . 'Hello'; // Test Hello
Or simply :
echo "<td><img src='$image'></td>";
Check documentation.
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>
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>
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 currently studing PHP and I tried to color the <h1> tag. But the previous style influenced the <h1> tag.
This is my code:
<?php
echo "<span style='color:#$lets'>hello world!</span";
echo "<Br />
<Br />";
printf("<h1 stlye='color:#%X%X%X'>hello world! again.</h1>",200,250,100);
?>
You haven't closed your span tag and you have a typo, should be style instead of stlye.
<?php
echo "<span style='color:#$lets'>hello world!</span>";
echo "<Br />
<Br />";
printf("<h1 style='color:#%X%X%X'>hello world! again.</h1>",200,250,100);
?>
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];