Easy code...I'm blind...what am I missing?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tchester
Forum Newbie
Posts: 10
Joined: Thu Jun 12, 2008 3:59 pm

Easy code...I'm blind...what am I missing?

Post by tchester »

My php was working before I migrated to new server. I gotta be blind...something has to be wrong. PHP works on other sites, and test of <?php echo 'hello world'; ?> works!

Using latest version of PHP4, i've even tried PHP 5

Code: Select all

 
<?php
mysql_connect("localhost", "userhere", "passhere") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("1point") or die(mysql_error());
 
$result = mysql_query("SELECT news_title, date_format(news_date, '%b %D, %Y') as date FROM news");
 
$num = mysql_num_rows($result);
 
$i=0;
while($i < $num) {
 
$date = mysql_result($result,$i,'date');
$news_title = mysql_result($result,$i,'news_title');
 
echo "
            <tr>
                <td><div class='style14'>$date</div><br>$news_title<br><br></td>
            </tr>
            <tr>
                <td class='style10' style='width: 90%; height: 2px'></td>
            </tr>
";
 
$i++;
}
?>
 
Page is viewable here: http://www.envoydata.com/test/index.php
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Easy code...I'm blind...what am I missing?

Post by WebbieDave »

Your web page reveals a short tag in use. Check short_open_tag in your ini.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Easy code...I'm blind...what am I missing?

Post by markusn00b »

Yup, you're going to have to switch to full tags; it's best that way - then you don't have problems when migrating.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Easy code...I'm blind...what am I missing?

Post by califdon »

You should probably also read http://us2.php.net/function.mysql-result about the use of mysql_result().
tchester
Forum Newbie
Posts: 10
Joined: Thu Jun 12, 2008 3:59 pm

Re: Easy code...I'm blind...what am I missing?

Post by tchester »

WebbieDave, markusn00b...you guys are awesome!!!...I knew it was something dumb like that.
Post Reply