hypertext link error


Dear All:

I try to open a edit page with the record selected, when user click on the hypertext link below:

echo "";

But, I get the error message as below:

Notice: Undefined variable: cat_id in c:inetpubwwwroothomelegancedsp_editcategory.php on line 7

Anybody could advise me on the issue.

Thank You


Try changing the line like this.

echo ‘’;

Couple things to note in the changes I made.

When you quote the text with the single quotes, you do not have to worry about escapping. However you cannot use the single quote (or apostrophe) if you do. In this case it’s not an issue.

The other disadvantage is that you can not include variables in the quoted string. It must be concatenated. In this case, it would have to be anyway, as arrays don’t work well (in my experience) in a quoted string.

Finally you should always use the single quotes and quote the INDEX (in this case, id) in your array. PHP will work without doing that, however, it makes some assumptions about the index which may or may not be true (don’t remember exactly at this time and too lazy to look it up), either way it could lead to undesired results. By quoting it, you eliminate that possibility.

Good Luck


The undefined variable error is PHP being over sensitive. You can set error reporting to 0 which will mask the error, however this is not good coding practice.

Simply use the isset() function to test the state of the variable before you use it. So, on your dsp_editcategory.php page use:

if (isset($_GET[‘cat_id’]))
//rest of code

Note also the use of the suerglobal array $_GET.

Hope this helps.