Jump to content

[SOLVED] Not getting anything returned from the database?


toxictoad

Recommended Posts

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

<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

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

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? :-/

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

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.