Re: Undefined Variable and argument not valid . . .

From: Date: Wed, 14 Feb 2001 18:05:07 +0000
Subject: Re: Undefined Variable and argument not valid . . .
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-6630@lists.php.net to get a copy of this message
Hi John, You're trying to use a variable that is not set. Try using the isset function... Like this: if (isset($COCOD)) $result = mysql_query("SELECT * FROM tblAA_MIKER_COMPDAT WHERE COCOD=$COCOD",$db); Hope this helps... Later, Jorge santos@net-lynx.com ----- Original Message ----- From: John Halladay <John.halladay@ascensus.com> To: <php-db@lists.php.net> Sent: Wednesday, February 14, 2001 12:51 PM Subject: [PHP-DB] Undefined Variable and argument not valid . . . > Could someone please give me some direction on what is wrong with what I am > trying to do below. I've checked it over but still get the same errors. > What I'm trying to do is have a list of links that display information when > you click them. > > I'm getting the following error at the top of the first page where all the > links are displayed. > Warning: Undefined variable: COCOD in C:\Inetpub\wwwroot/maybe.php on line > 11 > > I'm getting this error when I click on one of the links and there is no info > displayed under the three listing below. > Warning: Supplied argument is not a valid MySQL result resource in > C:\Inetpub\wwwroot/maybe.php on line 15 > Company Name: > Contact: > Phone Number: > > > <html> > > <body> > > <?php > > $db = mysql_connect("localhost", "root", "*******"); > > mysql_select_db("schedules",$db); > > if ($COCOD) { > > $result = mysql_query("SELECT * FROM tblAA_MIKER_COMPDAT WHERE > COCOD=$COCOD",$db); > > $myrow = mysql_fetch_array($result); > > printf("Company Name: %s\n<br>", $myrow["CONAM"]); > > printf("Contact: %s\n<br>", $myrow["Contact"]); > > printf("Phone Number: %s\n<br>", $myrow["PhoneNumber"]); > > } else { > > $result = mysql_query("SELECT * FROM tblAA_MIKER_COMPDAT",$db); > > if ($myrow = mysql_fetch_array($result)) { > > do { > > printf("<a href=\"%s?COCOD=%s\">%s</a><br>\n", $PHP_SELF, > $myrow["COCOD"], > $myrow["CONAM"]); > > } while ($myrow = mysql_fetch_array($result)); > > } else { > > echo "Sorry, no records were found!"; > > } > > } > > ?> > > </body> > > </html> > > Thanks. > > John Halladay > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#6630) next »