Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP code check

Status
Not open for further replies.

martinb7

Programmer
Joined
Jan 5, 2003
Messages
235
Location
GB
Hi, on my site ( i am using a news poster by geting the info from a MySQL database.

But my code doesn't seem to be working.

Check!!

//code//

<?php

$host = &quot;host&quot;; //host
$user = &quot;user&quot;; //user
$pass = &quot;pword&quot;; //password
$db = &quot;dbase&quot;; //MySQL database

$load = $_GET['p'];
$conn = mysql_connect($host, $user, $pass);
mysql_select_db($db, $conn);
$query = mysql_query(&quot;SELECT * FROM newsposter ORDER by 'date' DESC&quot;);

while ($r = mysql_fetch_array($query)) {
$title = $r[&quot;title&quot;];
$news = $r[&quot;news&quot;];
$posted = $r[&quot;date&quot;];
$postedby = $r[&quot;postedby&quot;];

echo(<center><table width=385 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=385 height=23 class=headings background=images/pages/topbottom.gif>
<div align=center>$title</div></td>
</tr>
<tr>
<td height=23 class=headings background=images/pages/middle.gif>
<div align=center>$news</div></td>
</tr>
<tr>
<td height=23 bgcolor=#FFFFFF class=headings background=images/pages/topbottom.gif>
<div align=center>$postedby
$posted
</div></td>
</tr>
</table><center>);
}
?>

The bits in RED are the bits I want displayed on teh screen. At the moment they just say $title etc

Help!!

Thanx

Martin
 
drop the parens around what you want echoed and replace them with double quotes ...

Code:
echo &quot;blah blah $title&quot;;
 
i cant get it to work!

Still comes up with the same results: $title etc

what shall i do?
 
I'd test by simplifying the problem.

Comment out the while loop containing the complex echo statement and just output one of the the columns. Add this loop:

while ($r = mysql_fetch_array($query))
{
print $r['title'];
print '<br>';
}

Does that output work?

Want the best answers? Ask the best questions: TANSTAAFL!
 
Let me break it out for you:

echo &quot;<center><table width=385 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=385 height=23 class=headings background='images/pages/topbottom.gif'>
<div align=center>$title</div></td>
</tr>
<tr>
<td height=23 class=headings background='images/pages/middle.gif'>
<div align=center>$news</div></td>
</tr>
<tr>
<td height=23 bgcolor=#FFFFFF class=headings background='images/pages/topbottom.gif'>
<div align=center>$postedby
$posted</div></td>
</tr>
</table><center>&quot;;;



--
Mike FN
&quot;8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Web Programmer.&quot;
 
Ive fixed the problem now. Thanx for the help

Martin


affiliates.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top