Hey guys.
Having a strange problem(at least I find it strange, you guys will probably pick it right up). I have a shoutbox running at my site, which is supposed to return time/date and time from PHPs
Here is the code for adding content to the box, as well as displaying it below.
[code]
Shoutbox
Name:
Message:
<?php
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die(“Unable to select database”);
$query=“SELECT * FROM ShoutBox
ORDER BY user-id
DESC LIMIT 5”;
$result=mysql_query($query);
$num=mysql_numrows($result);
while($r=mysql_fetch_array($result))
{
$time=$r[“time”];
$id=$r[“user-id”];
$message=$r[“message”];
$name=$r[“user-name”];
?>
<?php echo $message;?> |
<?php echo $name;?>
<?php echo $time;?>
|
And here is the PHP that’s supposed to work the magic.
[php]<?php
mysql_connect (“localhost”, “”, “”)
or die (‘I cannot connect to the database.’);
mysql_select_db ("")
or die(mysql_error(‘I can not select the table.’));
echo $name;
$name=$_POST[‘name’];
echo $message;
$message=$_POST[‘message’];
$time=date(“h:ia d/j/y”);
echo $time;
echo $result;
$result=MYSQL_QUERY(“INSERT INTO ShoutBox VALUES (‘NULL’,’$name’, ‘$message’,’$time’)”);
$result = mysql_query(“select * from ShoutBox order by user-id desc limit 5”);
?>[/php]
I’m not really sure how to further troubleshoot this problem as I can’t see a reason why PHPs date(“h:ia d/j/y”) doesn’t work. I am a bit puzzled at it saying d(for day?) j(not sure what this is) and y(for year?) though. Please advise if available