Click to See Complete Forum and Search --> : declare variables??


djedery
07-06-2001, 07:32 AM
Hello - i'm the administrator for phpMyInventory (project in sourceForge - only place i really bother to maintain things).

Anyway, a user sent me this message: "Why do I get an undefined error: 'Warning: Undefined variable: id in D:\phpMyInventory\index.php on line 10'"

His config is this:

Windows NT 4.0 SP4
IIS 4.0
PHP 406 for Win32
MySQL 3.22 for Win32

I've never used php in windows - can someone tell me if variables need to be declared or something (like DIM in asp)? Is there any way around that?

ame12
07-06-2001, 05:53 PM
You don't need to explicitly declare them, but you do need to reference them (i.e., set them) before trying to read their value. The function isset() can be used to determine whether a variable has been initialized or not to prevent this from occurring.

if (!isset($v)) {
$v = "";
}

Dave


===========================================
http://badblue.com/helpphp.htm
Free small footprint web server for Windows
PHP, file-sharing, Access/Excel transcoding
===========================================

Anon
07-06-2001, 09:50 PM
Excellent - exactly what i needed to know. Much thanks!

-dje