I am having a few problems with this...could someone tell me why the code is showing up and not the info from the variables please.


Code:
<?php
include('http://morphteque.alex10819.net/forum/config.php');
mysql_connect('localhost', $dbuser, $dbpasswd);
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM phpbb_topics WHERE forum_id='1' ORDER BY topic_id DESC LIMIT 5")
   or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
    $post = mysql_fetch_assoc(mysql_query("SELECT * FROM phpbb_posts_text WHERE post_id='{$row['topic_first_post_id']}' LIMIT 1"));
    $post2 = mysql_fetch_assoc(mysql_query("SELECT * FROM phpbb_posts WHERE post_id='{$row['topic_first_post_id']}' LIMIT 1"));
   <table border="1" width="80%"><tr><td width="30%"><strong>Title</strong></td><td width="40%"><strong>Description</strong></td><td><strong>Date</strong></td></tr><tr><td>.$post["post_subject"].</td><td>.$post["post_text"].</td><td>.date("F d, Y (h:i),$post2["post_time"]).</td></tr></table>;
   }
?>


Thanks Very Happy
You have to "echo" the HTML... doesn't l ook like you did that... next, if you want to use a variable, you have to do it correctly.

[code]
echo 'Hello, my name is '.$name.', would you like a bottle of coke?';
[/code[
vs...

[code]
echo 'hello my name is . $name ., would you like a bottle of coke?';
[/code]

considering how I don't see a single quotation mark of any sort around your echoed statements...

Code:
   echo '<table border="1" width="80%"><tr><td width="30%"><strong>Title</strong></td><td width="40%"><strong>Description</strong></td><td><strong>Date</strong></td></tr><tr><td>'.$post["post_subject"].'</td><td>'.$post["post_text"].'</td><td>'.date("F d, Y (h:i)','$post2["post_time"])'.</td></tr></table>;


You mean like this?
No, you're putting quotes around your variables...

Sigh... I'd fix it for you, but you wouldn't learn anything...[/code]
I would much rather you do not fix it because you are right, I would not learn anything....and that would just be pointless...


Code:
   echo '<table border="1" width="80%"><tr><td width="30%"><strong>Title</strong></td><td width="40%"><strong>Description</strong></td><td><strong>Date</strong></td></tr><tr><td>.$post["post_subject"].</td><td>.$post["post_text"].</td><td>.date("F d, Y (h:i),$post2["post_time"]).</td></tr></table>';
All of your strings need to be inside quotes of some sort. All of your variables must be outside
So is this right for the whole thing?


Code:
<?php
include('./forum/config.php');
mysql_connect('localhost', $dbuser, $dbpasswd);
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM phpbb_topics WHERE forum_id='1' ORDER BY topic_id DESC LIMIT 5")
   or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
    $post = mysql_fetch_assoc(mysql_query("SELECT * FROM phpbb_posts_text WHERE post_id='{$row['topic_first_post_id']}' LIMIT 1"));
    $post2 = mysql_fetch_assoc(mysql_query("SELECT * FROM phpbb_posts WHERE post_id='{$row['topic_first_post_id']}' LIMIT 1"));
     echo '<table border="1" width="80%"><tr><td width="30%"><strong>Title</strong></td><td width="40%"><strong>Description</strong></td><td><strong>Date</strong></td></tr><tr><td>'.$post['post_subject'].'</td><td>'.$post['post_text'].'</td><td>'.date('F d, Y (h:i)',$post2['post_time']).'</td></tr></table>';
   }
?>
Try it and see Razz
ok, vars must be outside single quotes, but they can be in double quotes (I usually use the double ones).
Yeah, but he's using arrays, so that would require curly braces,a nd I'm in no mood to teach him about curly braces Razz
no they don't. I do "<tr><td>$row[post]</td></tr>"; all the time.
Well it's technically incorrect Razz
The mistake I mad was so bad from the beginning I am not even going to tell you what it was....Thanks for all your patience Alex10819. ***Mexi1010 Slaps himself silly Exclamation
You didn't echo, I tell you Razz
Nope that is not it, it is even stupider. Very Happy
Yes... stupider

Well, good work fixing it!

(http://www.theonion.com/content/video/report_70_percent_of_all_praise)
Heh, alex I saw that video earlier today, it's very funny Smile.
And somewhat fitting Razz
Lol that is a funny video.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement