Jump to content

[SOLVED] Not getting anything returned from the database?


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>

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?

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 ')

^_^

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.