Help: Notice: Undefined variable: edit in.....

This is a discussion on Help: Notice: Undefined variable: edit in..... within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I have some PHP code working fine on a web site. I have installed Apache web server on my ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-11-2003
Tim Dixon
 
Posts: n/a
Default Help: Notice: Undefined variable: edit in.....

Hi,
I have some PHP code working fine on a web site.
I have installed Apache web server on my local PC with PHP and mySQL

It still works, but I get lots of errors like:
Notice: Undefined variable: edit in C:\Program Files\Apache
Group\Apache2\htdocs\schools\aenews.php on line 18

In this particular case the code is:

<? if ($edit == 'Y'){
$result=mysql("$DBName","SELECT * FROM news WHERE..........

If I lower the level of error reporting, the messages are removed (but I
seem to think this is a false way to resolve the problem)

if I use ' ' arount the vatiable it seems to remove the problem too.
ie:
<? if ('$edit' == 'Y'){
$result=mysql("$DBName","SELECT * FROM news WHERE..........

So, can anyone tell the real reason for the error messages and why I need
the ' ' marks?


Thanks.

Tim.

SORRY - I am quite a newbie at PHP!


Reply With Quote
  #2 (permalink)  
Old 07-11-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: Notice: Undefined variable: edit in.....


"Tim Dixon" <news@tdixon.com> wrote in message
news:3f0e6fcc$0$7730$fa0fcedb@lovejoy.zen.co.uk...
> Hi,
> I have some PHP code working fine on a web site.
> I have installed Apache web server on my local PC with PHP and mySQL
>
> It still works, but I get lots of errors like:
> Notice: Undefined variable: edit in C:\Program Files\Apache
> Group\Apache2\htdocs\schools\aenews.php on line 18
>
> In this particular case the code is:
>
> <? if ($edit == 'Y'){
> $result=mysql("$DBName","SELECT * FROM news WHERE..........
>
> If I lower the level of error reporting, the messages are removed (but I
> seem to think this is a false way to resolve the problem)
>


Keep the level as it is. The isset() function evals whether a variable is
set:

<? if (isset($edit) && $edit == 'Y'){...

> if I use ' ' arount the vatiable it seems to remove the problem too.
> ie:
> <? if ('$edit' == 'Y'){
> $result=mysql("$DBName","SELECT * FROM news WHERE..........
>
> So, can anyone tell the real reason for the error messages and why I need
> the ' ' marks?
>


When you are using single quotes, the expression is taken literal. With
double quotes the expression is parsed.

Example:

$greet = "Hallo";

echo '$greet'; // Displays $greet
echo "$greet"; // Displays Hallo
echo $greet; // Displays Hallo


JW



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:47 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0