Jump to content

[SOLVED] mysql_fetch_assoc simply not retrieving any data from the columns


dazzclub

Recommended Posts

Hi people,

 

my code below doesnt seem to be retrieving any data. The data im calling or accessing is "headline", "date" and "publication"

 

<?php

$sql ="SELECT * FROM press_material ORDER BY id";

if($result = mysql_query($sql))

 

while($row = mysql_fetch_assoc($result)) {

 

 

 

echo '

<tr>

<td>' .$row['headline']. '</td>

<td>' .$row['date']. '</td>

<td><a href="press/' .$row['publication']. '.pdf" title="' .$row['publication']. '" target="_blank">' .$row['publication']. '.pdf </a></td>

</tr>';}

?>

 

any ideas to what i have forgotton to do?

 

regards

Dazzclub

Link to comment
Share on other sites

double post in the same section, nice!  you could have at least tried another section...

 

Hmm, that looks correct, you sure there's something in press_material?  Change this line:

 

$result = mysql_query($sql) or die(mysql_error());

Link to comment
Share on other sites

my guess is that when you throw on some error reporting you'll find msql screaming at you about using "date" as a column name.  If you want to use reserved words as column names, you need to wrap them up in backticks like so: `date` ... but you shouldn't do that because that only really works for mysql and also it's bad programming practice to use reserved words as column names.

 

but i could be wrong.  Not about the whole backtick thing; about the problem.

Link to comment
Share on other sites

Hi people,

 

Firstly a huge apologies for breaking the forum rules, ive been here long enough and posted several topics that i should no better. Double posting was caused when i submitted my post, the process just seemed to just hang there. You know where the input box changes colour, like an overlay. so i just simply refresed and hence the double post.

 

No excuse for not wrapping my code, its very annoying for you guys, sorry.

 

The reason for my problem was caused by my host losing the database even though i double checked to see if any data was there it was.

 

Again sorry and thanks, I appreciate all your help.

 

Regards

Dazzclub

Link to comment
Share on other sites

Just for info, DATE is not a reserved word.

 

my guess is that when you throw on some error reporting you'll find msql screaming at you about using "date" as a column name.  If you want to use reserved words as column names, you need to wrap them up in backticks like so: `date` ... but you shouldn't do that because that only really works for mysql and also it's bad programming practice to use reserved words as column names.

 

but i could be wrong.  Not about the whole backtick thing; about the problem.

Link to comment
Share on other sites

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.