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
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 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.
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
I have a question on parsing this line of php code. I've tried but cant get it, I have also searched tons of forums but could not find the right thing. Could someone help?
$message = "CheckSMS= . $_POST['number'] . "=" . $_POST['message'];
In the end it should look like this: CheckSMS=number=message
The syntax highlighting shows your errors, you're missing the closing " on the first one.
$message = "CheckSMS= . $_POST['number'] . "=" . $_POST['message'];
Should be:
$message = "CheckSMS=" . $_POST['number'] . "=" . $_POST['message'];
You should probably also do some input validation and so on, because you can't fully ever trust a POST variable, etc, but this solves this problem.
There's several ways to do this:
// Complex (curly) syntax
$message = "CheckSMS={$_POST['number']}={$_POST['message']}";
// Concatenation
$message = "CheckSMS=".$_POST['number']."=".$_POST['message'];
// sprintf()
$message = sprintf("CheckSMS=%s=%s", $_POST['number'], $_POST['message']);
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
Hi I am getting this error and it has become a headache for me. Can anyone please help me where I have committed mistake.
Here is my code.
<?php echo mxp_draw_pull_down_menu('datefield', MxpStatistics::getFieldsDropDown(), isset($_SESSION['statistics']['datefield']) ? $_SESSION['statistics']['datefield'] : ' ', 'onchange="javascript: saveModify(document.searchreport'.$rand.', \''.mxp_href_link_admin(FILENAME_DEFAULT, $MxpTemplate->getModule() . '&module=' . substr($file['name'], 0, strrpos($file['name'], '.'))) ."' , null, " . $_GET['windowId']);"');?>
Just remove last four characters("');) from your code.
You can detect you syntax errors easily, if you use any syntax highlighting IDE.
Also, if you try to save number of line like this, it will be a real headache for you to find syntax errors and debug.
Try this code
<?php
echo mxp_draw_pull_down_menu('datefield', MxpStatistics::getFieldsDropDown(), isset($_SESSION['statistics']['datefield']) ? $_SESSION['statistics']['datefield'] : ' ', 'onchange="javascript: saveModify(document.searchreport'.$rand.', \''.mxp_href_link_admin(FILENAME_DEFAULT, $MxpTemplate->getModule() . '&module=' . substr($file['name'], 0, strrpos($file['name'], '.'))) ."' , null, " . $_GET['windowId']);
?>
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.