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
    22,326
    How do you know it was set to anything to begin with?
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  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
    22,326
    You might want to take a look at getfamilybdays.php and see if it's doing something with that variable, perhaps?
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.17607 seconds
  • Memory Usage 2,977KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates