?
Solved

mysql / php form works on internet but not on intranet

Posted on 2011-09-18
3
Medium Priority
?
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
acbxyz earned 2000 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

801 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