Question : I"m getting an undefined index error message on this script.

It has to do with the index act but I can't figure it out.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
<?php

include("../dbconnect.php");

$info = mysql_query("SELECT * FROM requests"); 

echo '<table border="1" cellpadding="3" cellspacing="1"> 
  <tr valign="top"> 
    <td>Date</td> 
    <td>From</td> 
    <td>Subject</td> 
    <td>Message</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
  </tr>'; 
     
if (mysql_num_rows($info) < 1) { 
echo '<tr valign="top"> 
  <td colspan="4">There are no members that match the query. Please go back and try again</td> 
    </tr>'; 
} 

else { 
   while ($qry = mysql_fetch_array($info)) { 

//create the layout 

?>
  <tr valign="top"> 
    <td><?php echo $qry['ID']; ?></td>     
    <td><?php echo $qry['date']; ?></td> 
    <td><?php echo $qry['from']; ?></td> 
    <td><?php echo $qry['subject']; ?></td> 
    <td><?php echo nl2br($qry['message']); ?></td> 
    <td><a href="?act=edit&id=<?php echo $qry['ID']; ?>">Edit</a></td> 
    <td>Delete</td> 
  </tr> 


<?php

   } 
} 


echo '</table>'; 


if ($_GET['act'] == 'edit') {
    require("edit.php");
} 
?>

Answer : I"m getting an undefined index error message on this script.

Run this query in your fav mysql query tool:

SELECT * FROM requests limit 1;

Now, match up the column names, CASE-sensitive, against these lines

    <td><?php echo $qry['ID']; ?></td>    
    <td><?php echo $qry['date']; ?></td>
    <td><?php echo $qry['from']; ?></td>
    <td><?php echo $qry['subject']; ?></td>
    <td><?php echo nl2br($qry['message']); ?></td>
    <td><a href="?act=edit&id=<?php echo $qry['ID']; ?>">Edit</a></td>

Specifically, "ID", "date", "from", "subject", "message"
php/mysql_fetch_assoc is case sensitive
Random Solutions  
 
programming4us programming4us