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 4 years ago.
Improve this question
I have a simple link that needs to pass a variable through $_GET and set it to a variable in the page that is being opened. It is failing every time however and I am not sure why.
<a class='section_header' href='category/index.php?`id='" . $catid . "'><b>" . $row[0] ."</b></a>
Code in category/index.php
$id = $_GET['id'];
echo $id;
<a class='section_header' href="category/index.php?id=<?php echo $catid?>"><b><?php echo $row[0];?></b></a>
Try
<a class='section_header' href='category/index.php?id='" . $catid . "'><b>" . $row[0] ."</b></a>
You had a random ` in there. Once it prints out you can use inspect element to make sure the url looks correct and id is populated.
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 6 years ago.
Improve this question
i just need on small info i want just add '#' to one variable and and put add thing into one variable. i am adding small php code to here please suggest me.
<?php
$email34 = $row['email'];
$rem = '#gmail.com';
$trim_email = str_replace($rem ,'', $email34);
$tag_name ="#".$trim_emial.;
echo $tag_name;
?>
but i am getting only # as output;
but my out should be "#mahesh1" if any have idea about this code please help me. thank you advanced.
there is so much spelling mistakes in the variables... try below given code
<?php $email34 = $row['email'];
$rem = '#gmail.com';
$trim_email = str_replace($rem ,'', $email34);
$tag_name ="#".$trim_email;
echo $tag_name;
?>
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
Can anyone help me for this why doesn't my code work?
$h.= ' 'mysql_result($res,$z,"name")'';
It gives me an error because of the <a href
$h .= ''.mysql_result($res,$z,"name").'';
Should work now
. before mysql_result and after.
Also take a look here it will help you to understand String Operators and etc.
You need to concatenate.
$h.= ' ' . mysql_result($res,$z,"name") . '';
Anyway, I would suggest you to put mysql_result($res,$z,"name") into a variable, to increase readability and avoid executing the function every time you call it.
I mean:
$name = mysql_result($res,$z,"name");
$h.= ' ' . $name . '';
Try this
$h.= ''.mysql_result($res,$z,"name").'';
You are missing . the concatenation operator
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 can not color the $_SESSION['username'] while echo in php.
echo "Welcome, " .$_SESSION['username']."! "; //this code is running
echo '<span style="color:#AFA;text-align:center;">Welcome,'$_SESSION['username'];'</span>'; // this part is not working...
Please help me if you can
You forgot the concatenation ..
echo '<span style="color:#AFA;text-align:center;">Welcome,' . $_SESSION['username'] . '</span>'; // this part is not working...
Notice the missing . before and after $_SESSION['username'];
echo'<span style="color:#AFA;text-align:center;">Welcome,'.$_SESSION['username'].'</span>';
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 9 years ago.
Improve this question
how can I print out a variable name in text in php?
I want to accomplish something as simple as having this:
echo "|" . "$myvariable" . "|";
print out this:
|$myvariable|
instead of this:
||
how can I accomplish this?
Use single quotes so that the variables don't get interpolated:
echo "|" . '$myvariable' . "|";
As others pointed out, use single quotes to show the variable name "as is".
echo "|" . '$myvariable' . "|";
Be sure to read this part of the manual.