Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts

    Not updating database

    However its not posting anything to the DB now and don't know why.

    PHP Code:
    case 3:
                echo $e;
                $query = "SELECT s.hometown, s.height, s.weight,
                     h.kowtitles, h.kowawards,
                     w.nicknames, w.finisher, w.setup, w.music
             FROM `efed_bio_singles`   AS s,
                  `efed_bio_history`   AS h,
                  `efed_bio_wrestling` AS w
             WHERE s.bio_id = '$defaultcharacterid' AND 
               h.bio_id = '$defaultcharacterid' AND
               w.bio_id = '$defaultcharacterid'";
               $result = mysql_query($query);
                $row = mysql_fetch_array($result); 
                $height = mysql_real_escape_string($height);  
                ?>
                <h1 class=backstage>Character Management</h1><br />
                <h2 class=backstage><?php echo $defaultcharactername?> - Personal</h2><br />
                <form name="editcharacter" method="post">
                <input type="hidden" name="action" value="character" />
                    <table width="100%" class="table2">
                        <tr>
                            <td width=120 class=rowheading>Hometown:</td><td class=row3>
                            <input type=text name="hometown" class=fieldtext490 value="<?php echo $row['hometown']; ?>"></td>
                        </tr>
                        <tr>
                            <td width=120 class=rowheading>Height:</td><td class=row3>
                            <input type=text name="height" class=fieldtext40 value="<?php echo htmlspecialchars($row['height']); ?>"></td>
                        </tr>
                        <tr>
                            <td width=120 class=rowheading>Weight:</td><td class=row3>
                            <input type=text name="weight" class=fieldtext80 value="<?php echo $row['weight']; ?>"></td>
                        </tr>
                    </table><br />
                    <h2 class=backstage>KOW Related</h2><br />
                    <table width="100%" class="table2">
                        <tr>
                            <td width=120 class=rowheading>KOW Titles:</td><td class=row3>
                            <input type=text name="kowtitles" class=fieldtext490 value="<?php echo $row['kowtitles']; ?>"></td>
                        </tr>
                        <tr>
                            <td width=120 class=rowheading>KOW Awards:</td><td class=row3>
                            <input type=text name="kowawards" class=fieldtext490 value="<?php echo $row['kowawards']; ?>"></td>
                        </tr>
                    </table><br />
                    <h2 class=backstage>Wrestling</h2><br />
                    <table width="100%" class="table2">
                        <tr>
                            <td width=120 class=rowheading>Nicknames:</td><td class=row3>
                            <input type=text name="nicknames" class=fieldtext490 value="<?php echo $row['nicknames']; ?>"></td>
                        </tr>
                        <tr>
                            <td width=120 class=rowheading>Manager:</td><td class=row3>
                            <select name="managerid" class=dropdown>
                            <option value="0">- Select -</option>
                            <?php
                            $query 
    'SELECT charactername,id FROM `efed_bio` WHERE `style_id`= 3';
                            
    $result mysql_query $query );
                            while ( 
    $manager_row mysql_fetch_assoc $result ) ) 
                            {
                                print 
    "<option value=\"".$manager_row['id']."\" ";
                                if(
    $manager_row['id'] == $row['manager_id']) {
                                    print 
    " SELECTED";
                                }
                                print 
    ">".$manager_row['charactername']."</option>\r";
                            }
                            
    ?>
                            </select></td>
                        </tr>
                        <tr>
                            <td width=120 class=rowheading>Finisher Move:</td><td class=row3>
                            <input type=text name="finisher" class=fieldtext490 value="<?php echo $row['finisher']; ?>"></td>
                        </tr>
                        <tr>
                                <td width=120 class=rowheading>Setup Move:</td><td class=row3>
                                <input type=text name="setup" class=fieldtext490 value="<?php echo $row['setup']; ?>"></td>
                        </tr>
                        <tr>
                            <td width=120 class=rowheading>Entrance Music:</td><td class=row3>
                            <input type=text name="music" class=fieldtext490 value="<?php echo $row['music']; ?>"></td>
                        </tr>
                    </table><br />
                    <input type="hidden" name="defaultcharacterid" value="<?php echo $row['defaultcharacterid']; ?>">
                    <input type="hidden" name="editted2" value="true">
                    <input type=submit value="Update Bio" class=button></form><br />
                <?php
                returnmain
    ();
            break;
    Here's the query I"m running with it.

    PHP Code:
    if ((!empty($_POST['editted2']))) {  
                
    $kowtitles mysql_real_escape_string($_POST['kowtitles']);
                
    $kowawards mysql_real_escape_string($_POST['kowawards']);
                
    $height mysql_real_escape_string($_POST['height']);
                
    $weight mysql_real_escape_string($_POST['weight']);
                
    $hometown mysql_real_escape_string($_POST['hometown']);
                
    $managerid mysql_real_escape_string($_POST['managerid']);
                
    $nicknames mysql_real_escape_string($_POST['nicknames']);
                
    $finisher mysql_real_escape_string($_POST['finisher']);
                
    $setup mysql_real_escape_string($_POST['setup']);
                
    $music mysql_real_escape_string($_POST['music']);
                
    $defaultcharacterid mysql_real_escape_string($_POST['defaultcharacterid']);
                
    $query "UPDATE `efed_bio_history` SET `kowtitles` = '".$kowtitles."', `kowawards` = '".$kowawards."' WHERE `bio_id` = '".$defaultcharacterid."'";  
                if(!
    mysql_query($query)){ echo mysql_error() . "<br />" $query;}
                echo 
    $query;
                
    $query2 "UPDATE `efed_bio_singles` SET `height` = '".$height."', `hometown` = '".$hometown."', `weight` = '".$weight."' WHERE `bio_id` = '".$defaultcharacterid."'";  
                if(!
    mysql_query($query2)){ echo mysql_error() . "<br />" $query2;}
                echo 
    $query2;
                
    $query3 "UPDATE `efed_bio_wrestling` SET `manager_id` = '".$managerid."', `nicknames` = '".$nicknames."', `finisher` = '".$finisher."', `setup` = '".$setup."', `music` = '".$music."' WHERE `bio_id` = '".$defaultcharacterid."'";  
                if(!
    mysql_query($query3)){ echo mysql_error() . "<br />" $query3;}
                echo 
    $query3;
            } 
    With the echoed query it says :

    UPDATE `efed_bio_history` SET `kowtitles` = 'Testing', `kowawards` = 'Testing' WHERE `bio_id` = ''UPDATE `efed_bio_singles` SET `height` = '5\\\'4\\\"', `hometown` = 'Tokoyo, Japan', `weight` = '145 lbs.' WHERE `bio_id` = ''UPDATE `efed_bio_wrestling` SET `manager_id` = '0', `nicknames` = 'Testing', `finisher` = 'Testing', `setup` = 'testing', `music` = 'testing' WHERE `bio_id` = ''

    Which means something is wrong with it getting the defaultcharacterid but I passed it correctly with the hidden field.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    'Cept defaultcharacterid isn't in you're $row. Check you're query again, there is no field name / alias in use to map a column to that name. I do see a standard variable named $defaultcharacterid, but I don't know where it comes from so I assume it to be valid.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    CoolAsCarlito (03-17-2010)

  • #3
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Nothing "wrong" with defaultcharacterid except that it's apparently empty, so the database won't update since there's no bio_id field that's empty.

    Before you submit the form, look at the HTML and see what value is listed for that hidden input. If nothing, the problem is on the form page and your initial query there.
    Are you a Help Vampire?

  • Users who have thanked tomws for this post:

    CoolAsCarlito (03-17-2010)

  • #4
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    I knew this was going to be an issue. The defaultcharacterid is coming from the id of the person that is logged in. Can I use:

    $defaultcharacterid = mysql_real_escape_string($defaultcharacterid);

    and

    <input type="hidden" name="defaultcharacterid" value="<?php echo $defaultcharacterid; ?>">
    Last edited by CoolAsCarlito; 03-17-2010 at 09:14 PM.

  • #5
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Somehow I fixed. Don't know how but I did.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by CoolAsCarlito View Post
    I knew this was going to be an issue. The defaultcharacterid is coming from the id of the person that is logged in. Can I use:

    $defaultcharacterid = mysql_real_escape_string($defaultcharacterid);

    and

    <input type="hidden" name="defaultcharacterid" value="<?php echo $defaultcharacterid; ?>">
    You sure can, there is no issue with using a known variable. My original post was in regards to you're query itself which did not include the 'defaultcharacterid' within it - this is why it passed over an empty value.

    Edit:
    I think we're all looking at different blocks. You cannot just use the $defaultcharacterid within the SECOND block of code you have posted, but you can use it in the first (though you probably don't need to use an escape sequence on it). The problem is the FIRST block of code where it is not actually passing a value for the hidden defaultcharacterid. That one needs to either have the query edited or the $defaultcharacterid provided at this level of the scope given to it as its value.
    Edit:
    Oh nvm, you've corrected the issue I see.

    Last edited by Fou-Lu; 03-17-2010 at 09:33 PM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    CoolAsCarlito (03-17-2010)

  • #7
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    One more issue though:

    PHP Code:
    <tr>
                            <td width=120 class=rowheading>Manager:</td><td class=row3>
                            <select name="managerid" class=dropdown>
                            <option value="0">- Select -</option>
                            <?php
                            $query 
    'SELECT charactername,id FROM `efed_bio` WHERE `style_id`= 3';
                            
    $result mysql_query $query );
                            while ( 
    $manager_row mysql_fetch_assoc $result ) ) 
                            {
                                print 
    "<option value=\"".$manager_row['id']."\" ";
                                if(
    $manager_row['id'] == $row['manager_id']) {
                                    print 
    " SELECTED";
                                }
                                print 
    ">".$manager_row['charactername']."</option>\r";
                            }
                            
    ?>
                            </select></td>
    Its still in continuance with code above. I am trying to have pre-select the existing value from the database.

    I have the query that's in there now but I need to include in there somehow with the table efed_bio_singles because a field in that table is called manager_id and that is equal to efed_bio field called id and then get the charactername from there.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Looks to me like you're initial query there you can just add an s.manager_id. Compare that later from the $row['manager_id']. Unfortunately I don't know you're table structures, so I can't be 100% certain thats where it is, but it sounds to me like that will do it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #9
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Table structure
    efed_bio-id, charactername,style_id
    efed_bio_wrestling-bio_id,manager_id

    Updated:

    PHP Code:
    <tr>
                            <td width=120 class=rowheading>Manager:</td><td class=row3>
                            <select name="managerid" class=dropdown>
                            <option value="0">- Select -</option>
                            <?php
                            $query 
    'SELECT bio.charactername,bio.id,w.manager_id FROM efed_bio AS bio, efed_bio_wrestling AS w WHERE bio.style_id= 3';
                            
    $result mysql_query $query );
                            while ( 
    $manager_row mysql_fetch_assoc $result ) ) 
                            {
                                print 
    "<option value=\"".$manager_row['id']."\" ";
                                if(
    $manager_row['id'] == $row['manager_id']) {
                                    print 
    " SELECTED";
                                }
                                print 
    ">".$manager_row['charactername']."</option>\r";
                            }
                            
    ?>
                            </select></td>
                        </tr>

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Alter you're initial query in the case there to add w.manager_id. That will then be available for use with the comparison inside of the selection menu.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #11
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Its already there in there.

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I don't see it in there:
    Code:
    SELECT s.hometown, s.height, s.weight, 
                     h.kowtitles, h.kowawards, 
                     w.nicknames, w.finisher, w.setup, w.music
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • Users who have thanked Fou-Lu for this post:

    CoolAsCarlito (03-17-2010)

  • #13
    Regular Coder
    Join Date
    Jun 2008
    Posts
    682
    Thanks
    114
    Thanked 2 Times in 2 Posts
    Thank you.


  •  

    Posting Permissions

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