PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 29th, 2004, 09:12 AM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Undefined Variable Error: I've tried most solutions

Hi everyone!

I have been searching the internet to find my particular problem, but to no avail.

I am running the following script on a WIndows 2003 system and I get the undefined variable error. I was wondering if ayone could help.
I do not want to sound desperate, but this is for a client and I know very little about php. So please review this code it would be greatly GREATLY appreciated!

and YES my register_globals is set to ON

Here is the code.


PHP Code:
if ($ID == "")
{
$id_err "<font color='red'>Please click the back button and enter your ID Number.</font><br>";
$send "no";
}
 
$Pattern ".+@.+\..+";
if (!
eregi($Pattern$Email))
{
$email_err "<font color=red>Your e-mail address appears to be invalid. Click the back button to enter your e-mail address.</font><br>";
$send "no";
}
 
if (
$Name == "")
{
$name_err "<font color=red>Please click the back button and enter your name.</font><br>";
$send "no";
}
 
if (
$Bill_Address == "")
{
$billing_err "<font color=red>Please click the back button and enter your billing address.</font><br>";
$send "no";
}
 
if (
$City_State_Zip == "")
{
$city_err "<font color=red>Please click the back button and enter your City, State, and Zip.</font><br>";
$send "no";
}
 
if (
$Phone == "")
{
$phone_err "<font color=red>Please click the back button and enter your phone number.</font><br>";
$send "no";
}
 
if (
$Ship_Name == "")
{
$shipname_err "<font color=red>Please click the back button and enter the shipping name.</font><br>";
$send "no";
}
if (
$Ship_Address == "")
{
$shipaddress_err "<font color=red>Please click the back button and enter the shipping address.</font><br>";
$send "no";
}
if (
$Ship_City_State_Zip == "")
{
$shipcity_err "<font color=red>Please click the back button and enter the shipping city, state, and zip.</font><br>";
$send "no";
}
 
if (
$send != "no")
{
 
foreach(
$HTTP_POST_VARS as $key => $value)
{
$message .= $key ": " $value;
$message .= "\n";
}
mail("mpsupport@meganspantry.com","$Title","$message","From: $Name <$Email>");
header ("Location: /thanks.php?Name=$Name");
}
 
elseif (
$send == "no")
{
echo 
$id_err//ERROR HAPPENDS HERE
echo $email_err//ERROR HAPPENDS HERE
echo $name_err//ERROR HAPPENDS HERE
echo $billing_err//ERROR HAPPENDS HERE
echo $city_err//ERROR HAPPENDS HERE
echo $phone_err//ERROR HAPPENDS HERE
echo $shipname_err//ERROR HAPPENDS HERE
echo $shipaddress_err//ERROR HAPPENDS HERE
echo $shipcity_err//ERROR HAPPENDS HERE he he
}
 
?> 





Thank you so much!

J.J. Mancini
www.frunder.com

Reply With Quote
  #2  
Old July 29th, 2004, 09:41 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 15
Can you post the error message. Its hard to know which variable without seeing it.

-KM-

Reply With Quote
  #3  
Old July 29th, 2004, 10:46 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to dhouston
And what line does it occur in? Mark the line in your code with "//Error occurs here" or something similar. Is the error a warning/notice or a fatal error? If a warning/notice, you may need to change your error severity threshold in you php.ini in order to suppress the error.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #4  
Old July 29th, 2004, 11:21 AM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here is the error message...


Code:
 
Notice: Undefined variable: id_err in c:\Program Files\Ensim\Site Data\meganspantry\Inetpub\wwwroot\members\shopping  \proc_order.php on line 87

Notice: Undefined variable: email_err in c:\Program Files\Ensim\Site Data\meganspantry\Inetpub\wwwroot\members\shopping  \proc_order.php on line 88

Notice: Undefined variable: name_err in c:\Program Files\Ensim\Site Data\meganspantry\Inetpub\wwwroot\members\shopping  \proc_order.php on line 89

Notice: Undefined variable: phone_err in c:\Program Files\Ensim\Site Data\meganspantry\Inetpub\wwwroot\members\shopping  \proc_order.php on line 92

Notice: Undefined variable: shipname_err in c:\Program Files\Ensim\Site Data\meganspantry\Inetpub\wwwroot\members\shopping  \proc_order.php on line 93
 
etc.....


Thanks for the swift replies! That is awesome!

Reply With Quote
  #5  
Old July 29th, 2004, 11:25 AM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Now one more thing I should make note of, is the fact that I have not set-up any php mailer. Frankly I do not know how php emails stuff anyway. Am I to set-up some php mailer? Or do I need to find someother way? Could that be causing the problem? If this is not causing the problem don't worry about this question. Because the previous one is WAY more important right now.

Reply With Quote
  #6  
Old July 29th, 2004, 01:26 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 15
Ok here it is. This line -

elseif ($send == "no")

You need to use the function strcmp to compare strings not just == (have a look on php.net for function specs).

At the moment it is evaluating to true, running this section and trying to use the variables that won't be defined if the 'if' sections above didn't happen.

Hope this helps,

-KM-

Reply With Quote
  #7  
Old July 29th, 2004, 01:27 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to dhouston
You should be able to get rid of this error in one of two ways. The most likely candidate is to initialize each of the problem variables above your if blocks. Just set each one to "". The second is to edit your php.ini file so that notices/warnings don't print to the screen. This is an example of a non-fatal error that your PHP config prints to the screen, so you can either fix it or change the config so that these errors don't display.

Reply With Quote
  #8  
Old July 29th, 2004, 01:29 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to dhouston
Heh, or there's another way. Kode_monkey jumped in just ahead of me with another, probably better, solution.

Reply With Quote
  #9  
Old July 29th, 2004, 04:56 PM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks both of you for your awesome replies.

Honestly though, I do not know to use the strcmp function. I really do not even know where to begin. This form used to work on the main server, the linux server, but now on the windoes server 2003 and with a newer version of PHP it no longer works. Could either of these solutions be able to explain why on linux and why not on Windows 2k3?

And if you could include a quick code sample, that would help phenominally!

Thanks again! You guys are awesome!

Reply With Quote
  #10  
Old July 29th, 2004, 05:13 PM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I tried this, based off another strcmp code sample....

Code:
else if (strcmp ($send) == 0) {
etc...
}



But it did not work.....

Yet here is an example where what exsists, works.
http://www.phpfreaks.com/phpref/34.php

I don't have any idea I'll keep searching. Any input is welcomed!

Reply With Quote
  #11  
Old July 29th, 2004, 09:10 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to dhouston
Failing that fix, try my idea of initializing the variables, just for kicks.

Reply With Quote
  #12  
Old July 30th, 2004, 02:45 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 15
www.php.net use the function reference to look it up.

-KM-

Reply With Quote
  #13  
Old July 30th, 2004, 04:04 AM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking

It's WORKING!

It was an error reporting problem, just like you said dhouston!

in the php.ini file I had

error_reporting - E_ALL;

I just had to change it to

error_reporting - E_FATAL;

Thank you guys so much! I'm sure you were just thinking way over my head and when really it was just some dumd little fix that you guys would have just assumed I knew. Anyway, Thanks again! This is the best forum ever! And it has the quickest and most complete user group I know!

Thanks again!

J.J. Mancini
www.frunder.com

Reply With Quote
  #14  
Old July 30th, 2004, 05:35 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 15
You are aware that just telling it not to inform you of the problems doesn't mean they have gone away. A quick fix like this is bound to leave you with trouble in the future. You'd do far better to find out why the messages are appearing rather than just turning them off.

-KM-

Reply With Quote
  #15  
Old July 30th, 2004, 07:01 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to dhouston
For the record, I made a reference to this fix in post number 3. Kode_monkey, I think you're right generally speaking, but this error is one that's not really worth bothering with. PHP wants the variables predelcared as in C and other strictly-typed languages, when that really doesn't add anything to the code but overhead. I don't generally have a problem turning off warnings, at least once in production.

Reply With Quote
  #16  
Old July 31st, 2004, 03:26 AM
jjmancini jjmancini is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 7 jjmancini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes I agree that the problem should be fixed, but at the time, all I needed was the form to work, and if I knew that all I had to do was turn off error reporting, I am fine with that.


And yes dhouston, I apologize for not giving you the credit. You made the suggestion that fixed the form! Thanks!
Thank you also Kode Monkey!

And if this was my form, I would make sure to fix it 100%. But I did not create the form so I just needed it working.

Thanks again!

J.J. Mancini

www.frunder.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Undefined Variable Error: I've tried most solutions


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap