Replacing "Something" with SessionId
Moderator: General Moderators
Replacing "Something" with SessionId
Hello,
I have a slight problem.
I shall explain the same with a example.
Say for example I have a value in a particular field of my database
"Hello Something How are you"
I can manage to print this value on the page without any problem.
The user has logged in and he receives the message "Hello Something How are you"
I wish to Replace the text "Something" with his login sessionid
<?echo "$userid";?> this helps me print the userid of the person logged in on the page.
However, i am clueless on how i could replace some text that am fetching from the database and then replacing the same to get the logged in userid.
Help Please
Regards
Amit
I have a slight problem.
I shall explain the same with a example.
Say for example I have a value in a particular field of my database
"Hello Something How are you"
I can manage to print this value on the page without any problem.
The user has logged in and he receives the message "Hello Something How are you"
I wish to Replace the text "Something" with his login sessionid
<?echo "$userid";?> this helps me print the userid of the person logged in on the page.
However, i am clueless on how i could replace some text that am fetching from the database and then replacing the same to get the logged in userid.
Help Please
Regards
Amit
Tried http://php.net/str_replace ?
Though i'm not sure why you're not just doing, echo 'Hello '.$userid.'. How are you?';
Though i'm not sure why you're not just doing, echo 'Hello '.$userid.'. How are you?';
Hello Mark,
Thanks i saw the url and its of help, However am a total fool when it comes to php. The application am building is actually a code i found somewhere and am trying to modify the same
So i cant really figure out what to do. Could you provide me with a example that i would require. I can then make the neccessary changes to the script.
Sorry for the trouble
Regards
Amit
Thanks i saw the url and its of help, However am a total fool when it comes to php. The application am building is actually a code i found somewhere and am trying to modify the same
So i cant really figure out what to do. Could you provide me with a example that i would require. I can then make the neccessary changes to the script.
Sorry for the trouble
Regards
Amit
Code: Select all
<?php
$thetext = 'Hello Something, How are you';
$userid = 'Fred';
echo str_replace('Something', $userid, $thetext);
//this outputs Hello Fred, How are you
?>Hello Mark
Thanks,
But am a touch confused, the text "Hello Something How are you" is coming in from the database and printing on the page.
Will this still work with the same?
Do i need to just copy paste this code?
or is there someway to implement it
Thanks Again
Amit
But am a touch confused, the text "Hello Something How are you" is coming in from the database and printing on the page.
Will this still work with the same?
Do i need to just copy paste this code?
or is there someway to implement it
Thanks Again
Amit
<?
mysql_connect($server, $db_user, $db_pass)
or die ("Database CONNECT Error (line 18)");
$result75 = mysql_db_query($database, "select * from interactive where progid='$progid'and id =
'$id'")
or die ("Database INSERT Error line 19");
if (mysql_num_rows($result75))
{
print "<font face=arial><TABLE width=100% align=center>";
while ($qry = mysql_fetch_array($result75))
{
print "<tr><td>";
print "<textarea name = domain2 cols=60 rows=5>";
print $qry[text];
print "</textarea>";
}
print "</TABLE>";
print "</tr></td>";
print "<br><br>";
} } }
?>
That's the part
Thanks & Regards
Amit
mysql_connect($server, $db_user, $db_pass)
or die ("Database CONNECT Error (line 18)");
$result75 = mysql_db_query($database, "select * from interactive where progid='$progid'and id =
'$id'")
or die ("Database INSERT Error line 19");
if (mysql_num_rows($result75))
{
print "<font face=arial><TABLE width=100% align=center>";
while ($qry = mysql_fetch_array($result75))
{
print "<tr><td>";
print "<textarea name = domain2 cols=60 rows=5>";
print $qry[text];
print "</textarea>";
}
print "</TABLE>";
print "</tr></td>";
print "<br><br>";
} } }
?>
That's the part
Thanks & Regards
Amit