Page 1 of 1

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

Posted: Fri Jun 27, 2008 11:24 pm
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

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

Posted: Sat Jun 28, 2008 4:07 am
by WebbieDave
Your web page reveals a short tag in use. Check short_open_tag in your ini.

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

Posted: Sat Jun 28, 2008 6:22 am
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.

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

Posted: Sat Jun 28, 2008 3:01 pm
by califdon
You should probably also read http://us2.php.net/function.mysql-result about the use of mysql_result().

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

Posted: Sun Jun 29, 2008 2:37 pm
by tchester
WebbieDave, markusn00b...you guys are awesome!!!...I knew it was something dumb like that.