Jump to content

[SOLVED] undefined index error on retrieving certain table columns


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!

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.