I have a login script with a Twitter-like posting script and I tried to insert the user name into the posts but that didn't work. They are both using the same database but I can't figure out why. Here is the php.
<?php
session_start();
require_once 'database.php';
if (isset($_SESSION['user'])){
echo "Welcome ".$_SESSION['user'];
?>
<?php
$posts = show_posts($_SESSION['userid']);
if (count($posts)){
?>
Now the posts part
<table class="imagetable">
<table align="center" border='0' cellspacing='0' cellpadding='5' width='300'>
<td background="cell-blue.jpg">
<?php
foreach ($posts as $key => $list){
echo "<tr valign='middle'>
";
echo "<td>".".$_SESSION['user']" . "<p>'s BFFL is</p>".$list['body'] ."<br/>
";
echo "<small>".$list['stamp'] ."<hr>"."</small></td>
";
echo "</tr>
";
}
?>
</table>
I'm a noob to php, and I can't get why it's not working... I just want the name of the user to be in the post.
There was an extra period (concat operator) before your session variable. I cleaned it up for you.
echo "<td>" . $_SESSION['user'] . "<p>'s BFFL is</p>" . $list['body'] . "<br/>
";