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 am reviewing a website that was designed years ago. There is a problem on the contact page
that spits an error:
Parse error: syntax error, unexpected T_LNUMBER in /home/content/p/r/e/prentexaf1/html/contact.php on line 61
Line 61 is that which starts: print"meta...
Here is the entire function around it:
function redirectTo($to) {
$url = $to;
print "<html><head><script> location.href='$url'¥n </script>";
print "<meta HTTP-EQUIV=Refresh CONTENT=¥"0; URL=$url¥">";
print "</head><body>If you see this page, click here to continue</body>";
print "</html>";
exit;
}
I'm unfamiliar with php enough not to know what problem is happening here (I did not write this function, just am trying to solve the error for a friend that owns the site [also didn't write it]). I've looked up the meta tag info. My instincts says this is an issue following content but that's just a hunch. Please advise..
Thank you in advance!
Some of the double quotes needed to be escaped. (Besides the funky ¥ characters which have been removed)
function redirectTo($to) {
$url = $to;
print "<html><head><script>location.href='$url'</script>";
print "<meta HTTP-EQUIV=Refresh CONTENT=\"0; URL=$url\">";
print "</head><body>If you see this page, click here to continue</body>";
print "</html>";
exit;
}
they (quotes) might have been accidently replaced with that character, using a Word processor of sorts.
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 8 years ago.
Improve this question
There is something wrong with this code, I cant make it go trough... the situation is that
the difficulty-meter needs to be checked , if it is filled, execute a mix of HTML and PHP. I'm learning php and got stuck in this functions...
Im using WP and WPML to translate that's why I add the -__e('Difficulty', 'projectname')': as a string. I get a error ,
Parse error: syntax error, unexpected 'tpage' (T_STRING), expecting ',' or ';' in /homepages/46/d448593520/htdocs/wp-content/themes/site/document.php on line 218
My full code is
<?php
// CHECK IF DIFFICULTY FIELD EMPTY
$diffcheck = get_post_meta($post->ID, 'wpcf-difficulty-meter', true);
if ( $diffcheck) {
echo "<ul class="tpage-list">
<li>'
-__e('Difficulty', 'projectname')':
'</li><li>'
types_render_field('difficulty-meter', array('output'=>'html','class'=>'tpage-difficulty'))
'</li></ul>";})
}
else {
// Show Nothing
}
// END
?>
The syntax highlighting shows your error: it's a quoting issue. You have to escape your double quotes inside of your string:
echo "<ul class=\"tpage-list\">
or use single quotes:
echo "<ul class='tpage-list'>
To complete what John Conde said, this part make no sense:
echo "<ul class="tpage-list">
<li>'
-__e('Difficulty', 'projectname')':
'</li><li>'
types_render_field('difficulty-meter', array('output'=>'html','class'=>'tpage-difficulty'))
'</li></ul>";})
Lets go through it:
// You have to keep track of concatenation. You started the string with ", you can't use it except to end string (or if you use \ like John Conde said)
// After the li: it seem like you wanted to add the value of the Difficulty thing, so you have to end your string and concaten it with a .
// Back to the strings and concaten it again to add the type render, since the string is now started with a ', I use a ' to end it
echo "
<ul class='tpage-list'>
<li>".-__e('Difficulty', 'projectname').':</li>
<li>'.
types_render_field('difficulty-meter', array('output'=>'html','class'=>'tpage-difficulty'))
.'</li>
</ul>';
I don't really see why you had a }) at the end, so I took it out
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 am trying to write a program using Call By Reference to calculate the area but I am getting a Parse Error :-
Parse error: syntax error, unexpected 'ar' (T_STRING) in C:\xampp\htdocs\workspace.php on line 7
Now I, cannot think why it is happening?
<?php
function perimeter(&$l,&$b,&$result)
{
$result=2*($l+$b);
}
funtction ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
$result=1;
$length=$_GET['length'];
$breadth=$_GET['breadth'];
echo "<h1><center>Area And Perimeter Calculator Using Call By Reference</h1></center>";
$result = perimeter($length,$breadth,$result);
echo "<br />The Perimeter Of The Rectangle Is <strong>$result</strong>";
$result= ar($length,$breadth,$result);
echo "<br /><br />The Area Of The Rectangle Is = <strong>$result</strong>";
?>
You misspelled function:
funtction ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
should be
function ar(&$le,&$br,&$result1)
{
$result1=$le*$br;
}
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 9 years ago.
Improve this question
$press=$_GET['sell'];
echo $press; //OUTPUT IS : SELL
if($press == SELL)
{
header("Location: home.php");
}
You forgot a single/double quotation
if($press=='SELL')
on the other hand, you must not send any output such as echo before header. So, do not echo anything before header.
You forgot single quote
if($press == 'SELL')
{
header("Location: home.php");
}
You have to put SELL in quotes like 'SELL'
You must not output anything before you send any headers
Do like this.. Enclose the SELL under single quotes.
This works if your URL is in the format like .. http://yourwebsite.com/yourfile.php?sell=SELL
<?php
$press=$_GET['sell'];
if($press == 'SELL')
{
header("Location: home.php");
}
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
remove
echo $press; OUTPUT IS : SELL
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 9 years ago.
Improve this question
I'm getting the error:
Parse error: syntax error, unexpected ':' in C:\wamp\www\xyz\contact-form.php on line 4
On a contact form that I'm trying to create for my portfolio site. I'm creating a simple check for the form submission and if it doesn't exist, it'll re-direct you back to to the index.
My code is:
if (!isset($_POST["save"]) || $_POST["save"] != ”contact”) {
header(“Location: index.php”);
exit;
}
Line 4 is the header() call, and I can't see what I've done wrong. I expect it's a small syntax error, any ideas?
The quotes aren't right, I'm assuming you copied it from a site, should be " not “
You're using funny quotes: (also known as smart quotes and curly quotes)
if (!isset($_POST["save"]) || $_POST["save"] != ”contact”) {
header(“Location: index.php”);
should be:
if (!isset($_POST["save"]) || $_POST["save"] != "contact") {
header("Location: index.php");