![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
PHP Dump issue.
I've been trying to dump some info from an SQL Database into a webpage using PHP. My problem is that there is a massive gap appearing at the beginning before the information comes out(see here ignore general appearance, will be fixed afterwards
), I've tried editing the html etc as much as possible but that doesn't affect it, it's the PHP itself I think. Can you find any reason why this code would present that problem?
$sql = "SELECT raiders as raiders, spent , earned, balance
FROM raidpoints";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
echo '<tr><td width="120" align="center" valign="top">';
echo $row["raiders"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["spent"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["earned"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["balance"];
echo '</td></tr><br>';
}Will also be making the code more efficient afterwards, just need help with the logic of the current code. ![]() |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 705
Rep Power: 3
![]() |
Re: PHP Dump issue.
Taking a wild guess, I'd say that you should provide a connection to your MySQL server when you call mysql_query() (unless you have it set so that the default connection works...). Also, as one of my own habits, I tend to verify that the query worked right, e.g:
$result = mysql_query($query, $dbLink) or die("MySQL query failed. Query was:<br />$query");![]() HTH
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
Re: PHP Dump issue.
Ah, sorry for lack of full info hehe. I do have the full code just below
![]() $conn = mysql_connect("localhost", "<edited to hide username>", "<edited to hide password>");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("honourbo_raidpoints")) {
echo "Unable to select honourbo_raidpoints: " . mysql_error();
exit;
}
$sql = "SELECT raiders as raiders, spent , earned, balance
FROM raidpoints";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo '<tr><td width="120" align="center" valign="top">';
echo $row["raiders"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["spent"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["earned"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["balance"];
echo '</td></tr><br>';
}This is just the php code, since the HTML plays no part in the errors. I receive no error messages at all. Any ideas? |
|
|
|
|
|
#4 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 729
Rep Power: 4
![]() |
Re: PHP Dump issue.
The blank space is because of the following.
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> I'm going to blame the parts of the file that you didn't paste.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Nov 2005
Location: Belfast
Posts: 34
Rep Power: 0
![]() |
Re: PHP Dump issue.
Sorry for the hassle so far guys hehe. The code I just started using is taken from the main page of the Gaming Guild, however even when I simply put the PHP into a php file and uploaded it, it still showed the same problem. Full code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<Title>Honourbound - Raid Points Status</Title>
<meta name="description" content="Honourbound, a World of Warcraft guild on Outland EU Realm" />
<meta name="keywords" content="Honourbound, honourbound, world of warcraft, wow, WoW, Outland, outland" />
<meta name="Generator" content="Joomla! - Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved." />
<meta name="robots" content="index, follow" />
<link rel="shortcut icon" href="http://www.honourbound.net/images/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" href="http://www.honourbound.net/images/favicon.ico" />
<link href="http://www.honourbound.net/templates/rt_replicant/css/rokmoomenu.css" rel="stylesheet" type="text/css" />
<link href="http://www.honourbound.net/templates/rt_replicant/css/template_css.css" rel="stylesheet" type="text/css" />
<link href="http://www.honourbound.net/templates/rt_replicant/css/header-dark-red.css" rel="stylesheet" type="text/css" />
<link href="http://www.honourbound.net/templates/rt_replicant/css/rokslidestrip.css" rel="stylesheet" type="text/css" />
<link href="http://www.honourbound.net/templates/rt_replicant/rokzoom/rokzoom.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link href="http://www.honourbound.net/templates/rt_replicant/css/template_ie6.css" rel="stylesheet" type="text/css" />
<style type="text/css">
img { behavior: url(http://www.honourbound.net/templates/rt_replicant/css/iepngfix.htc); }
</style>
<![endif]-->
<style type="text/css">
body {color: #fff;background: #000000 url(http://www.honourbound.net/templates/rt_replicant/images/bg/NewHBbackground.jpg) 50% 0 no-repeat fixed;}
a { color: #fc0 }
.moduletable h3, #horiz-menu, ul#rokslide-toolbar { color: #fff; }
#horiz-menu a, h3.toggler { color: #fc0; }
.sections td,#showcase,#mainframe td#left,#mainframe td#right,#mainframe #user1,#mainframe #page,pre {border: 1px solid #364148;}
#shadow-bottom .padding { border-top: 1px solid #364148;}
.style1
{
width: 100%;
height: 6%;
}
.style2
{
height: 52px;
}
.style3
{
height: 52px;
text-align: center;
}
</style>
<script type="text/javascript" src="http://www.honourbound.net/templates/rt_replicant/js/mootools.js"></script>
<script type="text/javascript" src="http://www.honourbound.net/templates/rt_replicant/rokzoom/rokzoom.js"></script>
<script type="text/javascript" src="http://www.honourbound.net/templates/rt_replicant/js/mootools.bgiframe.js"></script>
<script type="text/javascript" src="http://www.honourbound.net/templates/rt_replicant/js/rokmoomenu.js"></script>
<script type="text/javascript">
window.addEvent('domready', function() {
new Rokmoomenu($E('ul.nav'), {
bgiframe: false,
delay: 500,
animate: {
props: ['opacity', 'width', 'height'],
opts: {
duration:400,
fps: 100,
transition: Fx.Transitions.Cubic.easeOut
}
}
});
});
</script>
<script type="text/javascript">
window.addEvent('load', function() {
RokZoom.init({
imageDir: 'templates/rt_replicant/rokzoom/images/',
resizeFX: {
duration: 500,
transition: Fx.Transitions.Circ.easeOut,
wait: false
}
});
});
</script>
</head>
<body id="smoke">
<div class="surround">
<div class="wrapper">
<div id="shadow-top"></div>
<div id="shadow-middle" style="text-align: center">
<div class="padding">
<table class="style1" border="1">
<tr><td width="120" valign="top" class="style3"><u><b style="text-align: center">Player</b></u><br></td>
<td align="center" valign="top" class="style2"><u><b>Points Spent</b></u><br></td>
<td valign="top" class="style3"><u><b>Points Earned</b></u><br></td>
<td valign="top" class="style3"><u><b>Current Balance</b></u><br></td></tr>
<?php
$conn = mysql_connect("localhost", "<Edited to hide the username>", "<Edited to hide the password");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("honourbo_raidpoints")) {
echo "Unable to select honourbo_raidpoints: " . mysql_error();
exit;
}
$sql = "SELECT raiders as raiders, spent , earned, balance
FROM raidpoints";
$result = mysql_query($sql);
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo '<tr><td width="120" align="center" valign="top">';
echo $row["raiders"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["spent"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["earned"];
echo '</td>';
echo '<td width="120" align="center" valign="top">';
echo $row["balance"];
echo '</td></tr><br>';
}
?>
</tr>
</table>
</div>
<a href="http://www.honourbound.net" class="nounder">
<div id="pathway"><span id="logo"></span></a>
</div>
<td id="middle">
<div id="page">
</div>
</div>
<div id="shadow-bottom">
<div class="padding">
</div>
</div>
<div id="shadow-rocket"><a href="http://www.rockettheme.com/" title="RocketTheme Joomla Template Club" class="nounder"><img src="http://www.honourbound.net/templates/rt_replicant/images/blank.gif" alt="RocketTheme Joomla Templates" id="rocket" /></a></div>
</div>
</div>
<div id="fgimage"></div>
<div id="bgimage"></div>
</body>
</html><!-- 1205653478 --> |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| installing php (beginners question) | spekkio7 | PHP | 4 | Jan 11th, 2008 10:06 AM |
| New PHP Based Forum-RPG | dizdain | Paid Job Offers | 5 | Dec 3rd, 2007 2:32 AM |
| Php Tutorial 3 | bulio | PHP | 4 | Jul 16th, 2006 4:00 AM |
| Php Tutorial 1 | bulio | PHP | 17 | May 29th, 2006 4:54 AM |
| Php Tutorial 2 | bulio | PHP | 2 | Jul 1st, 2005 7:30 AM |