Jump to content

[SOLVED] undefined index error on retrieving certain table columns


delphi123

Recommended Posts

Hi folks,

 

On the code below it's all working great, except certain columns stored in the db return an error, eg:

 

Notice: Undefined index: id in C:\wamp\www\news\index.php on line 23

 

The only wild guess I can make is that these appear to be related to integers and/or these columns not have collation set? 

 

Can anyone help me fix this?

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo "<tr><td valign='top'><a href='{$row['id']}'>{$row['title']}</a><br>" .
         "<span style='font-size:10px'>{$row['text']}</span></td>" .
         "<td valign='top'>{$row['status']}</td>" .
	 "</tr>";
} 

<?php
while($row = mysql_fetch_assoc($result)) {
    echo "<tr>\n
	  <td valign='top'><a href='".$row['id']."'>".$row['title']."</a><br />
          <span style='font-size:10px'>".$row['text']."</span></td>\n
          <td valign='top'>".$row['status']."</td>\n
	  </tr>\n";
} 
?>

:-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[ :-[

 

Oh dear! How stupid am I, forgot that I'd made a specific field selection in my sql request in the include file (soit was only grabbing those specific columns, rather than *).

 

All works lovely now and I'm no longer pulling my hair - but apologies for wasting your time with such a stupid mistake!

 

Your debugging idea to dump the database records is a great one though and I'll be sure to use it in future!

 

Thanks very much for your amazingly quick and patient help!

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.