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;
?>
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 5 years ago.
Improve this question
i want to concat two variable and assign it to another variable
$name = Drew;
$counter = $counter + 1;
$num_padded = sprintf("%05d", $counter);
$new_padded_value = $name . $num_padded;
echo $new_padded_value;
Im expecting it to echo Drew.00001
its not working. how can I achieve this.
You're missing a string dot between the vars. The dot that you used is just the string concatenation operator; it doesn't actually add a dot to the string result. Change:
$new_padded_value = $name . $num_padded;
To:
$new_padded_value = "$name.$num_padded";
Also change:
$name = Drew;
To:
$name = "Drew";
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
Okay this really strange or I am missing something. When I run this very simmple PHP script on cmd I get the expected output which is 0. but when I uncomment the last two lines of code. . .nothing is displayed.
<?php
$test1 = 0;
echo $test1;
$test2 = 0;
#$test1_weight = 0:
#$test2_weight = 0;
?>
Is there some rule against declaring variables after an echo statement?
$test1_weight = 0:
--> change ":" to ";"
No there is no rule against declaring variables after an echo statement
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 about 300 lines of text that need to be echoed randomly.
Here's my current code:
<?php
$lines = array(
'Line 1',
'Line 2',
'Line 3'
);
$powered = echo $lines[rand(0, count($lines)-1)];
echo $powered;
?>
I know that the issue is probably with line 9 because I'm not sure how to assign the echoing to a variable. I need to be able to include this file in several others and echo $powered to get a random line.
Any help would be really appreciated.
$lines = array("one", "two", "three","four");
for($i =0; i < count($lines)-1;i++){
$line = $lines[rand(0, count($lines)-1)];
$lines = array_diff($lines, array($line));//Use this to remove the index of array
}
i wrote this in the stack overflow chat so there might be a problem or two. though, all looks well to me.
Was this what you were looking for?
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
<?php
$datetime=date("d-m-y");
$date1=date("d")+1;
$datetime1=date("$date1-m-y ");
$date1=$date1+1;
$datetime2=date("$date1-m-y ");
$date1=$date1+1;
$datetime3=date("$date1-m-y ");
echo $_POST['date1'];
echo $datetime1;
if($_POST['date1']==$datetime1)
{
header("location:bus2.php");
}
?>
here if condition doesn't work even though echo $_POST['date1']; and echo $datetime1; shows the same result.
The values are NOT the same:
$datetime1=date("$date1-m-y ");
^--this space makes all the difference:
$_POST['date1'] = '14-02-2014';
$datetime1 = '14-02-2014 ';
^--- spot the difference