What is wrong with this code PHP [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 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>

Related

PHP img src (simple) [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 6 years ago.
Improve this question
I am trying to add an image file to my PHP so when I echo, the picture will appear alongside the message. However I am getting a syntax error on line 3. Any help would be appreciated.
<?php
echo "President has been killed";
<IMG SRC = "D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png;"/>
?>
<?php
echo 'President has been killed
<img src="D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png;" /> ';
?>
Note the change in quotes -- single and double -- and placement of the semi-colon.
or
<?php
echo "President has been killed";
?>
<img src="D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png;" />
Move the image outside the php. Using this depends on overall markup though.
The semi-colon ends, or stops the echo statement.
Of course there's an syntax error. You are trying to output HTML inside PHP block:
Change your code to:
<?php
echo "President has been killed";
?>
<IMG SRC = "D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png;"/>
<?php
echo "President has been killed";
<IMG SRC = "D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png;"/>
?>
firstly you don't need the entire location, place the image in the folder in your root called images then place the image in there.
<?php
echo '<p>President has been killed<p><img src = "D:/User Data\Documents/Sheridan/Summer Year 3/Enterprise Java Development/Projects/PhpAssignment/skull.png"/>';
?>

unexpected endif line 34 don't know why [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
parse error unexpected endif at line i don't know why
<form name="contactform" method="post" action="check.php" class="form-horizontal" role="form">
<?php if(array_key_exists('errors', $_SESSION)); ?>
<div class="alert alert-danger">
<?php implode('<br>', $_SESSION['errors']); ?>
</div>
<?php unset($_SESSION['errors']); ?>
<?php endif;?>
Change
<?php if(array_key_exists('errors', $_SESSION)); ?>
to:
<?php if(array_key_exists('errors', $_SESSION)): ?>
Reference
Explanation:
In your code, you are putting semi-colon ; after if statement.
It means you are closing if control structure, hence, endif below has no meaning.
If you put :, the code between if and endif will be considered as body of control structure and hence will not produce error.

$_GET . Undefined Variable. Cant find solution [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'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>

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>'; ?>

typo issue in php using html [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i have this simple typo issue here i guess.
How can i resolve it?
<?php the_content("<br /> <span class='custom-more'>Read More: " . get_the_title('', '', false) "</span>"); ?>
I need to make a read more button in WordPress and i need to wrap the read more inside a span class.
I get this error message:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in
How am i supposed to resolve this?
Thanks
You are missing the concatenation operator . between get_the_title function and </span>
<?
php the_content("<br /> <span class='custom-more'>Read More: ".get_the_title('', '', false)."</span>");
?>
You are missing the concatenate (.)
Correct code will be
php the_content("<br /> <span class='custom-more'>Read More: ".get_the_title('', '', false)."</span>");

Categories