RE: [PHP] undefined variable when using if ($var) {}

From: Date: Mon, 25 Mar 2002 17:27:35 +0000
Subject: RE: [PHP] undefined variable when using if ($var) {}
Groups: php.general 
Request: Send a blank email to php-general+get-90062@lists.php.net to get a copy of this message
Good day. What is this message that you get, that you don't want? A cursory glance of the code reveals two "else" statements attached to the same "if" statement. You should address that. ============================ Darren Gamble Planner, Regional Services Shaw Cablesystems GP 630 - 3rd Avenue SW Calgary, Alberta, Canada T2P 4L4 (403) 781-4948 -----Original Message----- From: Martha S [mailto:trippykel@shaw.ca] Sent: Monday, March 25, 2002 9:44 AM To: php-general@lists.php.net Subject: [PHP] undefined variable when using if ($var) {} I'm rather new to PHP, so this should be fairly easy to answer. I checked the manual and FAQ already. I'm using the following code, and I get the following message if $id has nothing in the var (i have it set to a default of type int, not null in mysql). Is there a way around this or something I'm missing? Thanks :) -- code--- if ($id) { $result = mysql_query("SELECT * FROM entries WHERE id=$id",$db); $myrow = mysql_fetch_array($result); printf("<table border=1><tr>\n"); printf("<tr><td>%s</td></tr>", $myrow["title"]); printf("<tr><td>%s | ", $myrow["id"]); printf("%s</td></tr>", $myrow["posted"]); printf("<tr><td>%s\n</td></tr>", $myrow["post"]); printf("</table><tr>\n"); printf("<a href=\"$PHP_SELF\">all</a>"); } else { do { printf("%s <a href=\"%s?id=%s\">%s</a><br>\n", $myrow["id"], $PHP_SELF, $myrow["id"], $myrow["title"], $myrow["post"]); } while ($myrow = mysql_fetch_array($result)); } else { // no records to display echo "Sorry, no records were found!"; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#90062) next »