toxictoad Posted September 21, 2008 Share Posted September 21, 2008 Hi all, I'm trying to pull data from my database and display it on my web page but I'm not getting anything? I want to setup an RSS feed so I created my database/table and added a few fields and want to pull just two of these fields to show on my page. The database is called 'rss' The only table in it is called 'rssfeeds' The two fields I want to show are 'Title' and 'Content' This is my page so far <html> <head><title>RSS TEST PAGE</title></head> <body> <?php mysql_connect("localhost", "USERNAME", "PASSWORD") or die ('I can't connect to the database because: ' . mysql_error()); mysql_select_db("phatjoin_rss"); $query = mysql_query("SELECT * FROM rssfeeds"); while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']. ";} ?> </body> </html> Can anyone see what's wrong? I don't get any errors on the page it's just blank. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/ Share on other sites More sharing options...
.josh Posted September 21, 2008 Share Posted September 21, 2008 no errors huh...turn your error reporting on. You didn't properly use quotes. up ther ein your ...or die('I can't ... you closed your msg out and it's out of sync from there, all the way down your script. Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647172 Share on other sites More sharing options...
dezkit Posted September 21, 2008 Share Posted September 21, 2008 <html> <head><title>RSS TEST PAGE</title></head> <body> <?php mysql_connect("localhost", "USERNAME", "PASSWORD") or die ("I can't connect to the database because: " . mysql_error()); mysql_select_db("phatjoin_rss"); $query = mysql_query("SELECT * FROM rssfeeds"); while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']. ";} ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647175 Share on other sites More sharing options...
toxictoad Posted September 21, 2008 Author Share Posted September 21, 2008 no errors huh...turn your error reporting on. You didn't properly use quotes. up ther ein your ...or die('I can't ... you closed your msg out and it's out of sync from there, all the way down your script. Thanks CV I changed it to: <html> <head><title>RSS TEST PAGE</title></head> <body> <?php mysql_connect("localhost", "USERNAME", "PASSWORD") or die ('I cant connect to the database because: ' . mysql_error()); mysql_select_db("phatjoin_rss"); $query = mysql_query("SELECT * FROM rssfeeds"); while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']. ";} ?> </body> </html> And still nothing. I'm only familiar with CPanel and phpMyAdmin and I don't know how to turn on the error reporting? Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647181 Share on other sites More sharing options...
toxictoad Posted September 21, 2008 Author Share Posted September 21, 2008 ok I found some info about error reporting and added this <?php error_reporting(E_ALL) ?> saved, refreshed page and nothing? If I go to the page source there's nothing there either? Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647189 Share on other sites More sharing options...
Adam Posted September 21, 2008 Share Posted September 21, 2008 Should be: while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']; } EDIT: Notice the quote removed from the end... Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647207 Share on other sites More sharing options...
toxictoad Posted September 21, 2008 Author Share Posted September 21, 2008 Should be: while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']; } EDIT: Notice the quote removed from the end... Thanks MrAdam. Removed it from the code but still nothing? :-/ Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647236 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 lool <html> <head><title>RSS TEST PAGE</title></head> <body> <?php mysql_connect("localhost", "root", "my awesome password") or die ("I can't connect to the database because: " . mysql_error()); mysql_select_db("database"); $query = mysql_query("SELECT * FROM table"); while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']. " ";} ?> </body> </html> that thing should work ... btw dont forget dont use " ' " character when you have or die(' a message ') Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647240 Share on other sites More sharing options...
Adam Posted September 21, 2008 Share Posted September 21, 2008 Don't need to use: die(' .. '); .. can use: die(" .. "); ??? Is it actually showing ANYTHING in the source? Namely the HTML tags before and after the script?? Adam Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647247 Share on other sites More sharing options...
Minase Posted September 21, 2008 Share Posted September 21, 2008 look at his code you will understand what i mean and yes it work 100% Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647257 Share on other sites More sharing options...
toxictoad Posted September 21, 2008 Author Share Posted September 21, 2008 lool <html> <head><title>RSS TEST PAGE</title></head> <body> <?php mysql_connect("localhost", "root", "my awesome password") or die ("I can't connect to the database because: " . mysql_error()); mysql_select_db("database"); $query = mysql_query("SELECT * FROM table"); while ($row = mysql_fetch_array($query)) { echo "<br /> Title: " .$row['Title']. "<br /> Story: " .$row['Content']. " ";} ?> </body> </html> that thing should work ... btw dont forget dont use " ' " character when you have or die(' a message ') That's got it working thank you I was working through a tutorial and that's what they have so thanks for straightening that out for me, useful to know for future! Quote Link to comment https://forums.phpfreaks.com/topic/125203-solved-not-getting-anything-returned-from-the-database/#findComment-647298 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.