In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("Anyangwe, Tanwani") wrote:

> $result = mysql_query("SELECT * FROM motor_vehicle",$db);
> $strSep = '&nbsp;|&nbsp;';
> while ($myrow = mysql_fetch_array($result))
> {
> echo $myrow['id'].$strSep;
> }
> Gives me the following error:
> Warning: Undefined index: id in C:\PHP\Test_Scripts\testdb2.php on line 16

1) It's not considered a good habit to use "select *" in scripts.  When you 
later modify the table defs, your scripts will be blown.  Even if you never 
add/drop/change a column, it's still messy since whenever you're working on 
the code you have to remember--accurately--all of the columns and exactly 
(case_sensitive_ what they are named.  Yuck.  Much cleaner to include the 
column names in your query now.  "Select id from motor_vehicle"--then you 
know for sure you're working with a column of that name.

2) mysql_fetch_array doesn't fetch NULLs.  If the value of column 'id' in a 
given row is NULL, then $myrow['id'] will be undefined for that row. See 


PHP Database Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to