www.webdeveloper.com
Results 1 to 5 of 5

Thread: Variable issue

  1. #1
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    1,197

    Variable issue

    Below is the complete code for a page this adds values to a data base and does many other thngs, I having a change with the secion of code that adds the entery to the calendar. for sum reason the value assigned to the variable
    $eventid is being lost when the code gets to the section where the entery is added to the data base.

    I have tryed echoing the variable and nothing is displayed any thoughts why. the table at the bottom of the code does echo the value of the variable



    PHP Code:
    <?php session_start();  // Start Session?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd">

    <html>
    <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; 
    charset=ISO-8859-1">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta NAME="ROBOTS" CONTENT="ALL">
    <title>Days Event</title>

    <style type="text/css" media="all">
        @import "../css/default.css";
        @import "../css/forms.css";

    </style>
    <?php include '../familyConfig.php'?>
        
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit) // if too long...trim it!
    field.value = field.value.substring(0, maxlimit);
    // otherwise, update 'characters left' counter
    else 
    countfield.value = maxlimit - field.value.length;
    }
    // End -->
    </script>


    </head>
    <body>

    <div id="outer">
    <div id="banner">
        <img src="../images/header.jpg" alt="familyclick.ca" name="familyClickbanner" />
    </div>
        <div id="sub">
            <div id="center">


    <form method="POST" name="addEvent" action="<? echo $PHP_SELF?>">
    <table class="eventTable">
    <tr>
    <th class='displayhead' colspan='4'>Enter New Event</th>
    </tr>

      <tr>
        <td class="padding">Details</td>
      </tr>
      <tr>
        <td class="padding"><textarea name=message wrap=physical cols=20 rows=5 onKeyDown="textCounter(this.form.message,this.form.remLen,50);" onKeyUp="textCounter(this.form.message,this.form.remLen,50);"></textarea></td>
                </tr>
                <tr>
                <td><input readonly type=text name=remLen size=3 maxlength=3 value="50">Max</td> 
                </tr>
          <br>
          <input type="hidden" name="<? $_SESSION[user_id]; ?>"></td>
      </tr>
      <tr>
        <td class="padding">Description</td>
      </tr>
      <tr>
        <td class="padding"><input type="text" name="description"></td>
      </tr>
      <tr>
        <td class="padding">Category</td>
      </tr>
      <tr>
        <td class="padding"><select name="category">
          <option></option>
          <option value="Family Event">Family Event</option>
            <option value="Birthday">Birthday</option>
              <option value="Anniversary">Anniversary</option>
              <option value="Family Trip">Family Trip</option>
              <option value="Other">Other</option>
          </select></td>
      </tr>
      <tr>
        <td class="padding"><input type="submit" name="submit" value="Add Event"></td>
      </tr>
    </table>
    </form>


    </div>

    <div id="left">
      
      <?php include("../leftlinks.php"); ?>
          </div>
        </div>
        
        <div id="right">
        
    <?php
    include ('../config/db.php');

    $user_id $_SESSION['user_id'];
    $eventid $_REQUEST['eventid'];

    $del $_POST['del'];
    $delete $_POST['delete'];
    $event_description $_POST['description'];
    $event_category $_POST['category'];
    $event_details $_POST['details'];
    /*$event_date = $_POST['event_date'];*/
    $userid $_POST['userid'];
    $submit $_POST['submit'];


    echo 
    "<form method=\"POST\" action=\"results.php\">";

    if (
    $del) {
    $array explode(",",$delete);

    $sql "DELETE FROM calendar WHERE userid='$array[0]' AND event_id='$array[1]'";
    $result mysql_query($sql) or die ("Invalid query".mysql_error());
    }


    if (
    $submit) {

    if(
    $event_description == ""){

    echo 
    'Description is a required field';
    exit();
    }


    $sql = ("INSERT INTO calendar
    (event_date, event_description, event_category, event_details, userid, add_date) VALUES('
    $eventid', '$event_description', '$event_category', '$event_details', '$user_id', 
    now())"
    );

    $result mysql_query($sql) or die ("Insert ERROR: Invalid query" .mysql_error());

    }

    $sql "SELECT * FROM calendar C WHERE  C.event_date LIKE '$eventid%' AND C.userid = '$user_id' ORDER BY C.event_date";
    $result mysql_query($sql) or die ("Invalid query");

    ?>

    <table class="righttable">
    <tr><th class="displayhead" colspan="4">Events for <?php echo $eventid?></th></tr>

    <tr><td class="right">Description</td>
    <td class="right">Category</td><td class="right">details</td>
    <td class="right">Delete</td>
    </tr>
    <?PHP
    while ($row mysql_fetch_array($result)){

    echo 
    "<tr><td class='right'>";
    echo 
    "$row[event_description]</td><td class='right'>";
    echo 
    "$row[event_category]</td><td class='right'>";
    echo 
    "$row[event_details]</td><td class='right'>";

    echo 
    "<input type='radio' value='$row[userid],$row[event_id]' name='delete'></td></tr>";

             }

    $newid substr($eventid04);

    ?>

    <?PHP include 'getfamilybdays.php'?>

    </table>
    <div>
    <input type="hidden" name="event_date" value="<?php echo $eventid;?>">
    <input type="submit" name="del" value="Delete Event"></div>
    </form>
        </div>
       
        <div id="footer">
            <p>Copyright &copy; familyclick.ca</p>
             </div>
    </div>
    </body>
    </html>
    Last edited by kproc; 10-18-2006 at 07:04 PM.
    Kevin

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    How do you know it was set to anything to begin with?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    1,197
    the form that displays the result in the table at this section of the code

    the format is set to 2006-10-18 if that helps

    PHP Code:
    <table class="righttable">
    <tr><th class="displayhead" colspan="4">Events for <?php echo $eventid?></th></tr>
    Kevin

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    You might want to take a look at getfamilybdays.php and see if it's doing something with that variable, perhaps?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Mar 2006
    Location
    Canada
    Posts
    1,197
    the code for getfamilybdays

    i don't see any issues


    PHP Code:
    <?php

    while ($row mysql_fetch_array($result)){

    echo 
    "<tr><td class='right'>";
    echo 
    "$row[event_description]</td><td class='right'>";
    echo 
    "$row[event_category]</td><td class='right'>";
    echo 
    "$row[event_details]</td><td class='right'>";

    echo 
    "<input
    type='radio' value='
    $row[userid],$row[event_id]' name='delete'></td></tr>";

    }

    $newid substr($eventid04);

    $get_Children_Birthdays = ("SELECT * FROM children WHERE owner_id = '$user_id'");

    $children_birthdays mysql_query($get_Children_Birthdays) or die ("Invalid query"mysql_error());

    while (
    $child_R mysql_fetch_array($children_birthdays)){

    $childdob $child_R['childdob'];
    $childfirstname $child_R['childfirstname'];
    $childlastname $child_R['childlastname'];
    $child_array explode("-",$childdob);
    $child_birthday = ($newid."-".$child_array[1]."-".$child_array[2]);

    if(
    $child_birthday == $eventid){

    echo 
    "<tr>";
    echo 
    "<td class='right'>$childfirstname $childlastname</td>";
    echo
    "<td class ='right'>Birthday</td>";
    echo 
    "<td class ='right'></td>";
    echo 
    "<td class ='right'></td></tr>";

    }else{
    }
        }
    // Spouse Date of birth

    $get_spouse_Birthdays = ("SELECT * FROM users WHERE user_id = '$user_id'");

    $spouse_birthdays mysql_query($get_spouse_Birthdays) or die ("Invalid query"mysql_error());

    while (
    $spouse_R mysql_fetch_array($spouse_birthdays)){

    $spousedob $spouse_R['spousedob'];
    $spousefirstname $spouse_R['spousefirstname'];
    $spouselastname $spouse_R['spouselastname'];
    $spouse_array explode("-",$spousedob);
    $spouse_birthday = ($newid."-".$spouse_array[1]."-".$spouse_array[2]);

    if(
    $spouse_birthday == $eventid){

    echo 
    "<tr>";
    echo 
    "<td class='right'>$spousefirstname $spouselastname</td>";
    echo
    "<td class ='right'>Birthday</td>";
    echo 
    "<td class ='right'></td>";
    echo 
    "<td class ='right'></td></tr>";

    }else{
    }
        }
        
    // add siblings date of birth

    $get_sibling_Birthdays = ("SELECT * FROM sibling WHERE owner_id = '$user_id'");

    $sibling_birthdays mysql_query($get_sibling_Birthdays) or die ("Invalid query"mysql_error());

    while (
    $sibling_R mysql_fetch_array($sibling_birthdays)){

    $siblingdob $sibling_R['siblingdob'];
    $siblingfirstname $sibling_R['siblingfirstname'];
    $siblinglastname $sibling_R['siblinglastname'];
    $sibling_array explode("-",$siblingdob);
    $sibling_birthday = ($newid."-".$sibling_array[1]."-".$sibling_array[2]);

    if(
    $sibling_birthday == $eventid){

    echo 
    "<tr>";
    echo 
    "<td class='right'>$siblingfirstname $siblinglastname</td>";
    echo
    "<td class ='right'>Birthday</td>";
    echo 
    "<td class ='right'></td>";
    echo 
    "<td class ='right'></td></tr>";

    }else{
    }
        }
    // Add Parent Date of birth

    $get_parent_Birthdays = ("SELECT * FROM parent WHERE owner_id = '$user_id'");

    $parent_birthdays mysql_query($get_parent_Birthdays) or die ("Invalid query"mysql_error());

    while (
    $parent_R mysql_fetch_array($parent_birthdays)){

    $parentdob $parent_R['parentdob'];
    $parentfirstname $parent_R['parentfirstname'];
    $parentlastname $parent_R['parentlastname'];
    $parent_array explode("-",$parentdob);
    $parent_birthday = ($newid."-".$parent_array[1]."-".$parent_array[2]);

    if(
    $parent_birthday == $eventid){

    echo 
    "<tr>";
    echo 
    "<td class='right'>$parentfirstname $parentlastname</td>";
    echo
    "<td class ='right'>Birthday</td>";
    echo 
    "<td class ='right'></td>";
    echo 
    "<td class ='right'></td></tr>";

    }else{
    }
        }
    ?>
    Last edited by pcthug; 10-18-2006 at 10:11 PM. Reason: Wrapped PHP in [PHP][/PHP] tags.
    Kevin

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles