Sending Values to variables using url - php

<html>
<head>
<title>Find my Favorite Movie!</title>
</head>
<body>
<?php
echo “<a href='localhost/moviesite.php?favmovie=Inception'>Inception</a>";
?>
</body>
</html>
Getting the following error for the above code.
Parse error: syntax error, unexpected 'href' (T_STRING), expecting ',' or ';' in C:\xampp\test\movie1.php on line 7

As you can see you have a litteral mistake in
echo “<a href='localhost/moviesite.php?favmovie=Inception'>Inception</a>";
couse “ != "
change it to:
echo "<a href='localhost/moviesite.php?favmovie=Inception'>Inception</a>";

echo 'Inception';
Should do the trick for you

You have an copy and past error try this:
echo "<a href='localhost/moviesite.php?favmovie=Inception'>Inception</a>";
You are using by misstake a wrong quote “ instad of ". Often are quotes replaced wrong by some CMS like Wordpress. So you need to check double that you use the right quotes.

Related

Parse error: syntax error, unexpected '<<' (T_SL) on line 48

I have this code, but I'm getting
Parse error: syntax error, unexpected '<<' (T_SL) on line 48
I think the problem is from php code. but, i don't know what is it.
Can someone please explain why this error, or what my script is missing?
Thanks.
<!DOCTYPE html>
<html>
<head>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script>
function updatemenu() {
if (document.getElementById('responsive-menu').checked == true) {
document.getElementById('menu').style.borderBottomRightRadius = '0';
document.getElementById('menu').style.borderBottomLeftRadius = '0';
}else{
document.getElementById('menu').style.borderRadius = '9px';
}
}
</script>
</head>
<body>
<div id="content">
<center><br><br>
<?php
$uid=<<<EOD
ID : $_POST['user_id']
EOD;
$upw=<<<EOD
PW : $_POST['user_pw']
EOD;
echo $uid;
echo $upw;
?>
</center><br><br><br><br>
</div>
</body>
</html>
While you could use HEREDOC it poses an issue when it comes to spaces as another answer already points out. The way that I would approach it is to use something like the following which works and is easier to read:
<center><br><br>
ID: <?php echo $_POST['user_id']; ?>
PW: <?php echo $_POST['user_pw']; ?>
</center>
Reflecting the user's password back to them on the page isn't advised unless you are just getting a feel for how data moves around pages.
I think you have blank space after EOD, when there should be none. Please remove it and retry. Also remove any proceeding blank space before the ending EOD;
Solution: Remove trailing space after ALL <<<EOD and remove preceding whitespace before ALL the terminating EOD;

display div inside php using echo

I want display my button if it have isset($_GET). I am trying to do like this.
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> Project Users </div>';
}?>
its giving me error like
Parse error: syntax error, unexpected 'project_id' (T_STRING), expecting ',' or ';' in C:\xamppp\htdocs\mayank\add_project.php on line 101
I am not getting idea what I should do for echo project_id in div. Let me know if someone can help me for that.
Thanks
Thats incorrect to use echo inside another echo and how can you start a new php tag without closing the first.
The correct way is to concatenate the variable along the string passed in echo, here is how
<?php if(isset($_GET['project_id'])){
echo '<div class="add_btn_primary"> Project Users </div>';
}?>
instead of breaking the php tags break the ' quotes to concatenate the value in the string.
Why do you need again tag inside echo just use it as below:
<?php
if(isset($_GET['project_id']))
{
echo ('<div class="add_btn_primary"><a href="manage_project_users.php?project_id='.$_GET["project_id"].'>Project Users</a></div>');
}
?>

Parse error: syntax error, unexpected 'href' (T_STRING), expecting ',' or ';'

Getting error in this code...please help... i have changed it also like....
echo "<td>" Download"</td>";
or
<td><a href='get_file.php?id={$row['id']}'>Download</a></td>
still getting the error.
This should work for you:
(You don't concat the strings correctly and you forgot quotes for the href tag)
echo "<td><a href='get_file.php?id=" . $row['quote_id'] ."'>Download</a></td>";
Concatenation is your friend when outputting HTML.
echo '<td>Download</td>';
I usually try to put the single quotes on the outside and the double quotes on the inside because it's easier for me to manage.

php quotes in quote in quotes

I have the following code:
echo "<script type='text/javascript'>
iframe0document.getElementById('jform_articletext').value = '<?php echo \"<p align='center'><iframe src='aufgaben/'+cookieValue+'/'+cookieValue+'.html' width='322' height='497' frameborder='0'></iframe></p>\";?>';}</script>";
but it has a problem with the quotes, I tried almost everything but it says always:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /usr/www/users/mathea/joomla/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code on line 118
Ok the question should be changed to php nesting in php. I need a way to negate the offect of the php nesting like it's possible for quotes with \"
Updated
You made PHP tags within echo. That's pretty wrong!
As I understand OP:
$text = htmlentities('<?php echo \'<pre><p align="center"><iframe src="aufgaben/"+cookieValue+"/"+cookieValue+".html" width="322" height="497" frameborder="0"></iframe></p></pre>\'; ?>');
echo "<script type='text/javascript'>
iframe0document.getElementById('jform_articletext').value = ".$text.";
</script>";
You need htmlentities function to encode characters to their html equivalents and print out php tags az plain text.
But you are already in "php mode"!
Why you reopen php tag on
'<?php echo
?
Then, what is "iframe0document.getElementById"?

PHP embed html image as a link

How do I go about using an image as a link in php? I have never put two html elements together in one echo so it's kinda new for me.
Here's my code:
htmltest.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?
require("includes/conn.php"); //link to the database
?>
<html>
<title>HTML with PHP</title>
<body>
<?php
echo "<img src="homelogo.jpg" />";
?>
</body>
</html>
That's my code. I get the following error:
PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home6/dreamsm2/public_html/htmltest.php on line 11
Can anyone tell me what I'm doing wrong? Any help would be appreciated.
Change the line to:
echo '<img src="homelogo.jpg" />';
OR
echo "<img src=\"homelogo.jpg\" />";
The problem, as the error somewhat suggests, is that the PHP interpreter can't figure out where your string is supposed to start and end. Using \" escapes the quotes. Using ' around the string gives a unique string delimiter around the string, so you are free to use double quotes inside.
Note, if you needed both single and double:
echo '<img src="homelogo.jpg" />';
You can also use ' instead of " for strings, e.g.
This works: echo '"Hello!"'; => "Hello!"
This wont work: echo "'Hello'";
SIMPLY DO THIS:
echo '<img src="Downloads_clip_image010.jpg" />';
For WordPress
<div class="floatLeft">
<a href="http://trophydevelopers.com">
<img src="<?php bloginfo('template_url'); ?>/images/powered-by.png">
</a>
</div>

Categories