Deathwillow Posted December 10, 2008 Share Posted December 10, 2008 So i'm COMPLETELY new to php and was looking for a place to help me learn and hopefully I've found it. I'm currently just writing a simple news script using mySQL to store the information. I've come across a problem though. Maybe you guys can help me out with it: <?php //Open connection include("config.php"); //Select database $connection = mysql_select_db("**********") or die(mysql_error()); echo "Connected"; //Create Query $query = "SELECT * FROM news"; $result = mysql_query($query); if ($result) { echo "<link href=news.css rel=stylesheet type=text/css>"; while ($row = mysql_fetch_array($result)) { echo "<table id=news class=newsBox cellpadding=0 cellspacing=0>"; echo "<tr>"; echo "<td colspan=2 rowspan=4 class=topLeft><img src=images/" . $row["icon"] . "></td>"; echo "</tr>"; echo "<tr>"; echo "<td class=topTop colspan=2></td>" echo "<td class=topRight rowspan=3></td>" echo "</tr>"; echo "<tr>"; echo "<td class=titleBack><div class=newsTitle>" . $row["title"] . "</div></td>"; echo "</tr>"; echo "<tr>"; echo "<td class=topBottom colspan=2></td>" echo "</tr>"; echo "<tr>"; echo "<td class=left></td>"; echo "<td class=left2 colspan=2>"; echo "<div class=boxContent>" . $row["blog"] . "</div>"; echo "</td>"; echo "<td class=boxContent></td>"; echo "<td class=right></td>"; echo "</tr>"; echo "<tr>"; echo "<td class=bottomLeft></td>"; echo "<td class=bottomLeft2></td>"; echo "<td class=bottom></td>"; echo "<td class=bottomRight></td>"; echo "</tr>"; echo "</table>"; } echo "</table>"; } else { echo "<div>Error</div>"; } Doesn't display anything, nor give any errors. I could be going about it completely the wrong way, but I'm only following examples I've come across and I usually jump right into things pretty quickly. Any help would be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/ Share on other sites More sharing options...
chronister Posted December 10, 2008 Share Posted December 10, 2008 add this to the top of the page... ini_set('error_reporting', E_ALL); That one line of code will save you many headaches..... it will set error reporting to E_ALL which will show you all errors. Nate Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711161 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 Still doesn't display anything. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711167 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 Fixed the extra echo "</table>"; at the end, still get a blank screen. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711173 Share on other sites More sharing options...
5kyy8lu3 Posted December 10, 2008 Share Posted December 10, 2008 Fixed the extra echo "</table>"; at the end, still get a blank screen. i'm not sure it matters but you never opened <html> and <body> (unless your include file does that for ya), but either way, you could add a border to the table temporarily to see if it's even drawing the table (meaning data isn't being pulled from the database) good luck Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711175 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 This is the source code that calls the newscript <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>A useless website designed by Deathwillow</title> <link href="news.css" rel="stylesheet" type="text/css"> <link href="main.css" rel="stylesheet" type="text/css"> <script src="http://www.wowhead.com/widgets/power.js"></script> <script type="text/javascript" src="jquery.js"/><!-- kicks so much ass --></script> </head> <body> <center> <table height="100%" class="main" cellpadding="0" cellspacing="0"> <tr> <td class="mainLeft" rowspan="3"></td> <td class="mainCenter"></td> <td class="mainRight" rowspan="3"></td> </tr> <tr> <td class="mainLinks"> <div class="linkBarsTop">Top division</div> <div class="linkBarsBottom">Bottom Division</div> </td> </tr> <tr> <td class="mainContent" valign="top" align="center"> <?php include("addNews.php"); ?> </td> </tr> </table> </center> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711185 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 What I'm thinking might be is maybe the CSS file? all the information as far as the width, height, background etc etc of the table are held in that file. Am I not able to use the news.css file? here's the code in the css file I'm talking about: #news { width: 600px; height: auto } table.newsBox { margin: 0px; border: 0px; font-family: Arial, Helvetica, Sans-serif; font-size: 0.7em; width: 100% } table.newsBox td { padding: 0px } table.newsBox td.topLeft { width: 80px; height: 80px; background-position: 15% 15% } table.newsBox td.topBlank { width: 500px; height: 10px } table.newsBox td.topTop { width: 500px; height: 14px } table.newsBox td.topBottom { width: 500px; height: 48px } table.newsBox td.topRight { width: 18px; height: 80px } table.newsBox td.left { width: 22; height: auto } table.newsBox td.left2 { width: 58; height: auto } table.newsBox td.boxContent { width: auto; height: auto } table.newsBox td.right { width: 18; height: auto } table.newsBox td.bottomLeft { width: 22px; height: 12px } table.newsBox td.bottomLeft2 { width: 58px; height: 12px } table.newsBox td.bottom { width: 500px; height: 12px } table.newsBox td.bottomRight { width: 18px; height: 12px } table.newsBox td.titleBack { width: auto; height: 18px } table.newsBox caption { caption-side: bottom; text-align: right } table.newsBox td h1 { font: 5pt Verdana; font-weight: bold; color: #ffcc00 } table.newsBox td div.newsTitle { width: 400; height: 30; font-weight: bold; color: #ffcc00; font-size: 12px Verdana } .topLeft { background: url(itemdb/Ability_Druid_ManaTree.png) no-repeat top left } .topBlank { background: url(images/spacer.gif) repeat } .topTop { background: url(images/top-top.jpg) repeat-x } .topBottom { background: url(images/top-bottom.jpg) repeat-x } .topRight { background: url(images/top-right.jpg) no-repeat top right } .left { background: url(images/left.jpg) repeat-y } /* .left2 { background: url(images/bg3.jpg) repeat } */ .left2 { background-color: #292828 } .right { background: url(images/right.jpg) repeat-y } .bottomLeft { background: url(images/bot-left.jpg) no-repeat bottom left } .bottomLeft2 { background: url(images/bot.jpg) repeat bottom } .bottom { background: url(images/bot.jpg) repeat-x } .bottomRight { background: url(images/bot-right.jpg) no-repeat bottom right } .titleBack { background: url(images/bg2.jpg) repeat-x; } /* .boxContent { background: url(images/bg3.jpg) repeat } */ .boxContent { background-color: #292828 } .boxContent p { font-family: Verdana, Arial, Helvetica, sans-serif; font: 10px; color: #6f6e6e; margin-left: 15px; margin-right: 15px; } .boxContent p.comment { float: right } Now all this code works by itself, as I tested it before I started adding the php code. Honestly that's the only problem I can think of. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711190 Share on other sites More sharing options...
Mchl Posted December 10, 2008 Share Posted December 10, 2008 $connection = mysql_select_db("**********") or die(mysql_error()); [/php This is not how you connect to database. Use mysql_connect function first. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711192 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 include("config.php"); That's how I open the connection to the server, and it works. That line you quoted simply selects the database that the table is in. Obviously the ********* are replaced with the name of the database. I should also point out if I remove all the tables etc etc, and just use echo $row["title"]; it works just fine. It's only when I try and make the table. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711198 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 doesnt display anything: does that mean it doesnt even disply connected? jsut looking at this part: <?php //Open connection include("config.php"); //Select database $connection = mysql_select_db("**********") or die(mysql_error()); echo "Connected"; Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711200 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 Doesn't display anything, not even the Connected. On the other hand if I replace all the table code with just: while ($row = mysql_fetch_array($result)) { echo $row["title"]; echo $row["id"]; } the script works perfectly. The problem comes when I start trying to place the information inside of a table using a CSS file. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711205 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 if you go view source on the blank page what do you get? Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711206 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>A useless website designed by Deathwillow</title> <link href="news.css" rel="stylesheet" type="text/css"> <link href="main.css" rel="stylesheet" type="text/css"> <script src="http://www.wowhead.com/widgets/power.js"></script> <script type="text/javascript" src="jquery.js"/><!-- kicks so much ass --></script> </head> <body> <center> <table height="100%" class="main" cellpadding="0" cellspacing="0"> <tr> <td class="mainLeft" rowspan="3"></td> <td class="mainCenter"></td> <td class="mainRight" rowspan="3"></td> </tr> <tr> <td class="mainLinks"> <div class="linkBarsTop"></div> <div class="linkBarsBottom"></div> </td> </tr> <tr> <td class="mainContent" valign="top" align="center"> Right where i have the include it goes blank =/ Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711209 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 hmm can we please see config.php (dont forget to blank any sensitive data) Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711210 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 Pretty simple atm: <?php mysql_connect("CORRECT SERVER", "USERNAME", "PASSWORD") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711211 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 strange nothing there which should kill it without displaying anything. but thats where it is dying. could you try replacing that line with: mysql_connect("CORRECT SERVER", "USERNAME", "PASSWORD") or die("it died here"); just because im curious if it is dying there. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711216 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 Same story. http://www.deathwillow.com/test/index.php - Just straight up code without accessing the database, how it should look if working properly. no PHP. http://www.deathwillow.com/test/index2.php - What i'm getting when I try using the above code. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711218 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 nice theme but... heres your problem... should have seen it earlier: echo "<td class=topTop colspan=2></td>" echo "<td class=topRight rowspan=3></td>" your missing a ; line 9 of the first page you posted. what coding application are you using? Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711219 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 acctually found a few more like that, and meant 19 not 9 so line 18, 19, and 25 are all missing the closing ; Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711221 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 acctually found a few more like that, and meant 19 not 9 so line 18, 19, and 25 are all missing the closing ; haha yea I caught the other one once you posted the first 2... a noob mistake by a noob programmer! thanks for your persistent help on the matter, it's much appreciated. The table with the correct information's appearing now, it's just making it look pretty now. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711222 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 lol dont worry we all do it. Quote Link to comment https://forums.phpfreaks.com/topic/136321-solved-displaying-news/#findComment-711228 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.