Skip to main content
gamedev.net
🔒 Locked

Strange php problem

Started by tHiSiSbOb Sep 2, 2003 at 9:25 PM 5 replies 300+ views
Original Post
tHiSiSbOb
tHiSiSbOb
I am trying to write a program that fetches the contents of a data base and puts it in tables. When I run it in IE, it works fine. When I run it in anything else, it doesn;t show the text that should be in the tables. I looked at the source through Firebird and it shows that it didn't print anything from this: .$row["message"]., in the following code. So it just has the <tr><td></td></tr>. See for yourselves. Here is the php code :
<?

$db=mysql_pconnect("something","username","pass");

mysql_select_db("dxhut",$db);

$query="SELECT message FROM news";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$inum=mysql_num_rows($result);



printf("<html><head><title>DX-Hut</title></head>\n");
printf("<style type = 'text/css'>\n");
printf(".menu{position:absolute;left:25px;top:250px;}\n");
printf(".news{position:absolute;left:200px;top:250px;}\n");
printf("</style>\n");

printf("<table class=menu border=1 cellspacing=0 cellpadding=0 height=150px width=100px>\n");
printf("<tr><td></td></tr>\n");
printf("</table>\n");
printf("<body>");
printf("<table class = news border=1 cellspacing=0 cellpadding=0 width='400px'>\n");

for($i=0;$i<$inum;$i++)
{
	$row=mysql_fetch_array($result);
	echo("<tr><td>\n");
	echo("<table border=1 cellspacing=0 cellpadding=0>\n");
		

	echo("<tr><td><p>".$row["message"]."</p></td></tr>\n");
	
	echo("</table>\n");
	echo("</td></tr>\n");
	
	

}
printf("</table>");
printf("</body>");
printf("</html>");
?>
[edited by - tHiSiSbOb on September 2, 2003 10:26:08 PM] [edited by - tHiSiSbOb on September 2, 2003 10:26:56 PM]
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
capn_midnight
capn_midnight
considering that PHP is a server side script, I think you should look to see what discrepencies there are in the HTTP headers between IE and Mozilla.

That''s just off the top of my head though. Other than that, you should get identical code.
nes8bit
nes8bit
Just to let you know, this line really bothers me

printf("<table class = news border=1 cellspacing=0 cellpadding=0 width=''400px''>\n");

change it to class=news at least please. Also, I think you should make use of quotes to preserve sanity. At least use single quotes like you did in the width on that line.

------------------------------------------------------------
GDSAUBY GameDev Society For UnBanning YodaTheCoda
If you want to see yoda unbanned then put this in your sig
DakeDesu
DakeDesu
While we are dissecting the script...

What the heck is with all the Printf functions? Most of those lines you have printf on could probably be changed to echo--and even better, use Heredoc syntax to make it more easier to read.

Yes, use heredoc syntax--makes code more readable--or for areas where no variables are likely to show up in output, unescape the PHP.
ApochPiQ
ApochPiQ
telnet to the server on port 80 and type GET /nameofpage.php and press enter. See what pops up. Then copy that to a new .HTM file on your local HD, and open it in Firebird. If it works, then you know there is an HTTP header problem. If it doesnt work, then we confirm my theory that Firebird is a piece of crap.
Raymondo
Raymondo
quote:
Original post by DakeDesu
While we are dissecting the script...

What the heck is with all the Printf functions? Most of those lines you have printf on could probably be changed to echo--and even better, use Heredoc syntax to make it more easier to read.

Yes, use heredoc syntax--makes code more readable--or for areas where no variables are likely to show up in output, unescape the PHP.


I play around with Dreamweaver, but I often find myself writing little tidbits of code here and there. Mind me asking what the heredoc syntax is?
DakeDesu
DakeDesu
quote:
Original post by Raymondo
quote:
Original post by DakeDesu
While we are dissecting the script...

What the heck is with all the Printf functions? Most of those lines you have printf on could probably be changed to echo--and even better, use Heredoc syntax to make it more easier to read.

Yes, use heredoc syntax--makes code more readable--or for areas where no variables are likely to show up in output, unescape the PHP.
I play around with Dreamweaver, but I often find myself writing little tidbits of code here and there. Mind me asking what the heredoc syntax is?


It is very similar to Python's triple quotes, and is also found in Perl. Basic heredoc syntax is:

$variable = <<<EOF
Blah be blah.
EOF;
// Or:

echo <<<EOF
La de da $narf .
EOF;


Generally used for long areas of text, that contain quite a few variables. If variables are not really used in that text you can simply unescape the php instead of using a heredoc:

if ($condition) { ?>
Nothing here changes
<?php } ?>


/me hopes gamedev does not screw up the [ source ]


""""""""We're a pair of giant dicks." - Relee " --runemaster" - DakeDesu " - runemaster " -DakeDesu" -superpig" -DakeDesu" and now DukeAtreides076
[ Got Immortality? ] [ Home page ] [ Evil Twin ] [ Jargon File ] [ Politics Forum ]
Projects: [ Game Developer Man ] [ Variables ] [ YearNeo/VariaML ] [ Daytanea ] [ Gnu-Com: Alien Research ]


[edited by - DakeDesu on September 3, 2003 11:57:27 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.