Announcement

Collapse
No announcement yet.

Data Not Populating Column

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Not Populating Column

    As I said, the data from one of my input fields is not getting into the database column. It is a column that I inserted myself. I don't understand what the problem can be, it is formatted the same as other fields that are working, both in the database and the php file. The column is called "time", it is set as: varchar(15), utf8_unicode_ci, Null:Yes, Default: NULL.... The php input code is:

    PHP Code:
    <input type="hidden" id="id" value="<?php echo $_GET['id']; ?>">
                <b>Date?</b>
                <p>
                  <input id="when" name="when" type="text" style="width:80%;" value="<?php echo $event['date']; ?>" /><br /></p>
                  
                  <b>Time?</b>
                  <p>
                 <input id="time" name="time" type="text" style="width:40%;" value="<?php echo $event['time']; ?>" /><br /></p>
                
                <b>What?</b> (Max. 35)
                <p>
                  <input id="why" name="why" maxlength="35"; type="text" style="width:80%;" value="<?php echo $event['why']; ?>" />
                </p>
                
                <?php
                
    if(count($categoryTab)>0) {
                
    ?>
    As I said, all other input works, but not the "time", it leaves the no data is the database. Thank you for your help.

  • #2
    The get and set methods you have programmed in PHP must not be working. Break it down into baby steps, first concentrate on setting the variable first. This involves Posting the form to the PHP script which processes it and inserts it into the DB.

    First you need to add the column into the database manually, then you need to edit the INSERT SQL in order for the correct information to be INSERTed in the DB. Test that the correct data is being picked up. Also make sure you pick the correct data type, as sometimes these have to be casted into the correct type before you INSERT into the DB. Use a tool such as phpmyadmin to verify the data is being entered into the DB correctly.

    Comment


    • #3
      Originally posted by clivejo View Post

      ...then you need to edit the INSERT SQL in order for the correct information to be INSERTed in the DB. Test that the correct data is being picked up. Also make sure you pick the correct data type, as sometimes these have to be casted into the correct type before you INSERT into the DB. Use a tool such as phpmyadmin to verify the data is being entered into the DB correctly.
      First, thank you clivejo for taking the time to help me. Now, I think that I've done every thing you've said, I'm not sure about the " INSERT SQL in order for the correct information to be INSERTed in the DB" part. I have used PHPMyAdmin from the start, and did use the INSERT tab at the top of page to add the column, is that what you're talking about? "time" does seem to be inserted. (The yellow wording says, time.)

      As far as data type goes, I've tried different ones(text, time, etc) as I was troubleshooting the problem and settled on varchar(15) because it seems to be working for the DATE field. As I said, all of the other fields are working. When I used the time data type it just inputted 00:00:00 into the field and not the information sent. As a matter of fact, the time data type is he only one that insert any info/data into the column at all. Info/data is being read correctly, because the info that I put in manually comes up on the queries, and shows on the page.

      The GET works with the other fields such as DATE. I've added a couple of pix to help you see what I'm talking about.

      Click image for larger version

Name:	phpsample1.PNG
Views:	206
Size:	20.5 KB
ID:	60201

      Click image for larger version

Name:	phpsample2.PNG
Views:	225
Size:	18.8 KB
ID:	60202
      Thank you to anyone that may help....

      Comment


      • #4
        Ok so the database seems to be fine.

        Code:
        $event['time']
        $event is an array and should be defined somewhere in the code. There should be a get and set method for date. This is where the database is opened and the data is pulled out (usually by a SELECT SQL statement. It should read something like

        Code:
        SELECT (fb_userid, background, date) FROM events WHERE event_id = id;
        This is where the data is actually read from the DB and the PHP code then copies the data into the $event array.

        Can you send me a link to the PHP script you are using?

        Comment


        • #5
          I found this:
          PHP Code:
          /*
          $m1 = new MySqlTable();
          $sql = 'SELECT * FROM '.$GLOBALS['db_table']['events'].' WHERE 1';
          $results = $m1->customQuery($sql);
          for($i=0; $i<count($results); $i++) {
              $fb_user_id = $results[$i]['fb_user_id'];
              $sql = 'DELETE FROM '.$GLOBALS['db_table']['events'].' WHERE why=""';
              $m1->executeQuery($sql);
          }
          */ 
          Note: The time data that you see was put into the column field manually by me. All other info was inputted by the webpage form.

          Originally posted by clivejo View Post

          Can you send me a link to the PHP script you are using?
          www DOT registeredevents DOT com

          Comment


          • #6
            That is a piece of a get method code. But it is between /* ..... */ which means it is commented out and the code wont be executed.

            I have looked at your site, but I need access to the source code to be able to help you. Im assuming you are using a 3rd party script from somewhere to handle the events. I need to look at the code to be able to help you.

            Comment


            • #7
              clivejo, How can I get the script to you, and yes it was a third party scripts, but I've tried to improve on it. For instance, it was an event script that hat no place to put the event time. LOL



              PS: Most of the changes I made were cosmetic...

              Comment


              • #8
                PM me the link to where you got the code from. The site looks good, but unless I can read the PHP source code, I cant see where the problem is or help you fix it. The fix should be easy enough if I can locate the code to set and get the time info into the DB.

                Comment


                • #9
                  Sent

                  Comment


                  • #10
                    Bump... This issue is still troubling me.... Any help still welcomed...

                    Comment


                    • #11
                      Its troubling me too iads, haven't had a chance to sit down the read it properly yet. I noticed your site seems to be displaying times, have you fixed it or some kind of hack?

                      Comment


                      • #12
                        clivejo,

                        No, it is not fixed. All of the events shown were put there by me while testing the script, and after I went directly into the database record to insert the time into the column. The events are real, taken from Facebook, so I knew what to put there. It also shows that the column/record is being read, just not inputted from the webpage form.

                        Comment


                        • #13
                          Does the $_GET['id'] statement put the info into the record, and does it suppose to do it for $event['date'], $event['time'], and $event['why']? If so, what tells it to do it to those three variables?


                          PHP Code:
                          <input type="hidden" id="id" value="<?php echo $_GET['id']; ?>">
                                      <b>Date?</b> (ex. 01/01/16)
                                      <p>
                                        <input id="when" name="when" type="text" style="width:80%;" value="<?php echo $event['date']; ?>" /><br /></p>
                                        
                                        <b>Time?</b> (ex. 06:30pm or 06:30pm - 08:45pm )
                                        <p>
                                       <input id="time" name="time" type="text" style="width:40%;" value="<?php echo $event['time']; ?>" /><br /></p>
                                      
                                      <b>What?</b> (Max. 35)
                                      <p>
                                        <input id="why" name="why" maxlength="35"; type="text" style="width:80%;" value="<?php echo $event['why']; ?>" />
                                      </p>
                          LOL - I google and read everything that I can find on the subject, but It seems that the more that I try to figure this out the more I mess it up. I've read how to set up a PHP/MySQL form/database, but I still can't seem to figure it out.
                          Last edited by iads; 12-03-2015, 10:15 PM.

                          Comment


                          • #14
                            This is kicking my ****... I still can't figure it out. I bet that it's something very simple that I'm over looking, or just don't understand.

                            Comment


                            • #15
                              Code:
                              [COLOR=#000000][COLOR=#0000BB]<?php [/COLOR][COLOR=#007700]echo [/COLOR][COLOR=#0000BB]$event[/COLOR][COLOR=#007700][[/COLOR][COLOR=#DD0000]'time'[/COLOR][COLOR=#007700]]; [/COLOR][COLOR=#0000BB]?>[/COLOR][/COLOR]
                              This is the code used to output the time, which seems to be working. The input id = "time" is the form collecting the data, so you will see a box to type in the time. But I cant find where the form is being POST/GET to. I just havent had time to sit down and read the code properly.

                              Comment

                              Working...
                              X