Hi
Now i dont know if im asking to much but in a string replace i am looking to change {SHOWOFFERS} with a function is this possible?
All i get is just the function output not the function output inserted into the $details template im trying to use.
Help please its driving me mad.
Example:
$from = "{SHOWOFFERS}";
$to = showqblock();
$messagetext = str_replace($from, $to, $details);
echo $messagetext;
The Function is a form dynamicaaly created to ask for specific questions:
Example
function showqblock()
{
global $id;
global $affid;
global $programid;
// check to see if the program is live
$selpgq = "SELECT * FROM program WHERE id='$programid'";
$selpgr = mysql_query($selpgq);
$selpgrow = mysql_fetch_array($selpgr);
echo '<form name="form1" method="post" action="ms_dataprocess.php"><table width="350" border="0" cellspacing="1" cellpadding="1">';
if ($selpgrow["name"]=="1"){echo '<tr><td width="88"><div align="right"><font size="2">Name:</div></td><td width="255"><input type="text" name="name"></td></tr>';}
if ($selpgrow["surname"]=="1"){echo '<tr><td width="88"><div align="right"><font size="2">Surname:</div></td><td width="255"><input type="text" name="surname"></td></tr>';}
if ($selpgrow["email"]=="1"){echo '<tr><td width="88"><div align="right"><font size="2">Email:</div></td><td width="255"><input type="text" name="email"></td></tr>';}
$ipaddy = $_SERVER['REMOTE_ADDR'];
if ($selpgrow["ipaddress"]=="1")
{echo '<input type="hidden" name= "ip" value="'.$ipaddy.'">';}
// now go through and show any extra questions
$extq = "SELECT * FROM extraq WHERE programid='$programid'";
$extr = mysql_query($extq);
while ($extrow=mysql_fetch_array($extr))
{
echo '<tr><td width="88"><div align="right"><font size="2">'.$extrow["name"].':</div></td><td width="255"><input type="text" name="'.$extrow["id"].'"></td></tr>';
}
echo'<input name="affiliate" type="hidden" id="affiliate" value="' . $affid . '">
<input name="track" type="hidden" id="track" value="' . $track . '">
<input name="pid" type="hidden" id="pid" value="' . $programid . '">
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>';
}
Str_replace Headache
Moderator: General Moderators
Re: Str_replace Headache
1. You can't replace text with a function. You can replace it with the return value of the function.
2. Your function doesn't return anything. It outputs.
Change your function to return a string instead of echo'ing one.
2. Your function doesn't return anything. It outputs.
Change your function to return a string instead of echo'ing one.