Solved

mysql / php form works on internet but not on intranet

Posted on 2011-09-18
3
369 Views
Last Modified: 2012-08-14
I am continuing my attempt to port an established web site with mysql backend to an intranet site.  To date I have established the database and web site, with tables and data, on a stand-alone Windows 7/Wamp setup.

The intranet web site functions correctly.  I can access the database from phpmyadmin however, when I attempt to use the intranet form (php/html) to access the database I am getting an "Undefined index" error returned.

I have made several corrections based on the "Experts" feedback.  I now need some additional assistance


Specifics:

      Internet:      MySQL 5.0, PHP 5, Apache on Linux Server

      Intranet:      MySQL 5.0.7, PHP 5.3.5, Apache 2.2.17, on Windows 7


Error:

      Notice: Undefined index: eMail in C:\wamp\www\part\edit_pprq1.php on line 62

      Notice: Undefined index: Dateother1 in C:\wamp\www\part\edit_pprq1.php
                                 on line 216

      Notice: Use of undefined constant FirstAidTrainingOther -  
                                   assumed 'FirstAidTrainingOther' in
                                   C:\wamp\www\part\edit_pprq1.php on line 262

Code:

      62.      <p><font size="2" face="Arial">4.&nbsp; Occupation:<input        
                                            type="text" name="Occ" value="<?php echo $data2["Occ"]?>"
                                            size="30"> email:<input type="text" name="eMail" value="<?php
                                             echo $data2['eMail']?>" size="40"></font></p>

      216.      <td width="64"><input type="text" name="Dateother1" value="<?php
                                            echo $data2["Dateother1"]?>" size="8"></td>      

      262.      <p><font size="2" face="Arial">16. First Aid Training;     Red Cross
                                            Advance:<input type="checkbox" name="FirstAidTrainingRCA" <?
                                             php if ($data2['FirstAidTrainingRCA']=="ON"){echo "checked";}?
                                             >>&nbsp;&nbsp;&nbsp; CPR:<input type="checkbox"
                                             name="FirstAidTrainingCPR" <?php if       ($data2['FirstAidTrainingCPR']
                                              =="ON"){echo "checked";}?>>&nbsp;&nbsp;&nbsp; EMT:<input       
                             type="checkbox" name="FirstAidTrainingEMT" <?php if ($data2
                                            ['FirstAidTrainingEMT']=="ON"){echo "checked";}?
                                            >>&nbsp;&nbsp;&nbsp;Other:<input type="text"
                                               name="FirstAidTrainingOther" value="<?php echo $data2
                                             ['FirstAidTrainingOther']?>" size="20"></font></p>

0
Comment
Question by:dibrandt
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
acbxyz earned 500 total points
ID: 36557427
These first two are warnings, which tell you the used array items doesn't exist.
One option is to declare them before use
if (!isset($data2['Occ'])) $data2['Occ'] = '';
if (!isset($data2['Dateother1'])) $data2['Dateother1'] = '';

Open in new window

Another is to check everytime when used
<p><font size="2" face="Arial">4.&nbsp;
Occupation:<input type="text" name="Occ" value="<?php if (isset($data2['Occ'])) echo $data2["Occ"]; ?>" size="30">
email:<input type="text" name="eMail" value="<?php if (isset($data2['eMail'])) echo $data2['eMail']; ?>" size="40">
</font></p>

Open in new window


The third warning tells you, you used a constant instead of a string as Dave told you in #27309891 before, but it seems to be already fixed in your code. Please use code tags to avoid strange line feeds in this posting.
0
 

Author Comment

by:dibrandt
ID: 36557517
acbxyz,

Does "array items doesn't exist" mean that:

    1.  The field does not exist
or
     2. The field is empty

0
 
LVL 10

Expert Comment

by:acbxyz
ID: 36559588
Your first, if you assign null to an array field you won't get this error.
To check it, you can use array_key_exists(), while isset returns false if the value of a field is null.
http://php.net/manual/en/function.array-key-exists.php
Everythime, this function returns false you get an error if you want to use it.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now