Jump to content

Can't Update my tables ?


Go to solution Solved by Ch0cu3r,

Recommended Posts

continuing discussion from http://forums.phpfreaks.com/topic/283080-cant-update-my-tables/

 

I was making a programme on updating the values of the database,

 

here is the file where post is made.

 

edit.php

$con=mysql_connect("127.0.0.1","username","password");
mysql_select_db("database")  or die( "Could not select database. " . mysql_error() );
// Check connection
$_GET['id'] = $id;
                if ( $_POST['tour_id'] )
                        $tour_id = mysql_real_escape_string( $_POST['tour_id']);
                if ( $_POST[ 'tour_name' ] )
                        $tour_name = mysql_real_escape_string( $_POST[ 'tour_name' ] );
                if ( $_POST[ 'tour_type' ] )
                        $tour_type = mysql_real_escape_string( $_POST[ 'tour_type' ] );
                if ( $_POST[ 'day' ] )
                        $day = mysql_real_escape_string( $_POST[ 'day' ] );
                if ( $_POST[ 'nights' ] )
                        $nights = mysql_real_escape_string( $_POST[ 'nights' ] );
                if ( $_POST[ 'twin_triple_sharing' ] )
                        $twin_triple_sharing = mysql_real_escape_string( $_POST[ 'twin_triple_sharing' ] );
                if ( $_POST[ 'overview' ] )
                        $overview = mysql_real_escape_string( $_POST[ 'overview' ] );
                if ( $_POST[ 'itinerary' ] )
                        $itinerary = mysql_real_escape_string( $_POST[ 'itinerary' ] );
                if ( $_POST[ 'inclusions' ] )
                        $inclusions = mysql_real_escape_string( $_POST[ 'inclusions' ] );
                if ( $_POST[ 'exclusions' ] )
                        $exclusions = mysql_real_escape_string( $_POST[ 'exclusions' ] );
                if ( $_POST[ 'single_occcupancy' ] )
                        $single_occcupancy = mysql_real_escape_string( $_POST[ 'single_occcupancy' ] );
                if ( $_POST[ 'child_with_no_bed' ] )
                        $child_with_no_bed = mysql_real_escape_string( $_POST[ 'child_with_no_bed' ] );
                if ( $_POST[ 'inf_below' ] )
                        $inf_below = mysql_real_escape_string( $_POST[ 'inf_below' ] );
                if ( $_POST[ 'keywords' ] )
                        $keywords = mysql_real_escape_string( $_POST[ 'keywords' ] );
                if ( $_POST[ 'title' ] )
                        $title = mysql_real_escape_string( $_POST[ 'title' ] );
                if ( $_POST[ 'description' ] )
                        $description = mysql_real_escape_string( $_POST[ 'description' ] );
                if ( $_POST[ 'url' ] )
                        $url = mysql_real_escape_string( $_POST[ 'url' ] );
                if ( $_POST[ 'categories' ] )
                        $categories = mysql_real_escape_string( $_POST[ 'categories' ] );
                if ( $_POST[ 'alt1' ] )
                        $image_alt_1 = mysql_real_escape_string( $_POST[ 'alt1' ] );
                if ( $_POST[ 'alt2' ] )
                        $image_alt_2 = mysql_real_escape_string( $_POST[ 'alt2' ] );
                if ( $_POST[ 'alt3' ] )
                        $image_alt_3 = mysql_real_escape_string( $_POST[ 'alt3' ] );
                if ( $_POST[ 'alt4' ] )
                        $image_alt_4 = mysql_real_escape_string( $_POST[ 'alt4' ] );
                if ( $_POST[ 'alt5' ] )
                        $image_alt_5 = mysql_real_escape_string( $_POST[ 'alt5' ] );
                if ( $_POST['tour_id'] )
                        $tour_id = mysql_real_escape_string( $_POST['tour_id']);
                if ( $_POST[ 'tour_name' ] )
                        $tour_name = mysql_real_escape_string( $_POST[ 'tour_name' ] );
                if ( $_POST[ 'tour_type' ] )
                        $tour_type = mysql_real_escape_string( $_POST[ 'tour_type' ] );
                if ( $_POST[ 'day' ] )
                        $day = mysql_real_escape_string( $_POST[ 'day' ] );
                if ( $_POST[ 'nights' ] )
                        $nights = mysql_real_escape_string( $_POST[ 'nights' ] );
                if ( $_POST[ 'twin_triple_sharing' ] )
                        $twin_triple_sharing = mysql_real_escape_string( $_POST[ 'twin_triple_sharing' ] );
                if ( $_POST[ 'overview' ] )
                        $overview = mysql_real_escape_string( $_POST[ 'overview' ] );
                if ( $_POST[ 'itinerary' ] )
                        $itinerary = mysql_real_escape_string( $_POST[ 'itinerary' ] );
                if ( $_POST[ 'inclusions' ] )
                        $inclusions = mysql_real_escape_string( $_POST[ 'inclusions' ] );
                if ( $_POST[ 'exclusions' ] )
                        $exclusions = mysql_real_escape_string( $_POST[ 'exclusions' ] );
                if ( $_POST[ 'single_occcupancy' ] )
                        $single_occcupancy = mysql_real_escape_string( $_POST[ 'single_occcupancy' ] );
                if ( $_POST[ 'child_with_no_bed' ] )
                        $child_with_no_bed = mysql_real_escape_string( $_POST[ 'child_with_no_bed' ] );
                if ( $_POST[ 'inf_below' ] )
                        $inf_below = mysql_real_escape_string( $_POST[ 'inf_below' ] );
                if ( $_POST[ 'keywords' ] )
                        $keywords = mysql_real_escape_string( $_POST[ 'keywords' ] );
                if ( $_POST[ 'title' ] )
                        $title = mysql_real_escape_string( $_POST[ 'title' ] );
                if ( $_POST[ 'description' ] )
                        $description = mysql_real_escape_string( $_POST[ 'description' ] );
                if ( $_POST[ 'url' ] )
                        $url = mysql_real_escape_string( $_POST[ 'url' ] );
                if ( $_POST[ 'categories' ] )
                        $categories = mysql_real_escape_string( $_POST[ 'categories' ] );
                if ( $_POST[ 'alt1' ] )
                        $image_alt_1 = mysql_real_escape_string( $_POST[ 'alt1' ] );
                if ( $_POST[ 'alt2' ] )
                        $image_alt_2 = mysql_real_escape_string( $_POST[ 'alt2' ] );
                if ( $_POST[ 'alt3' ] )
                        $image_alt_3 = mysql_real_escape_string( $_POST[ 'alt3' ] );
                if ( $_POST[ 'alt4' ] )
                        $image_alt_4 = mysql_real_escape_string( $_POST[ 'alt4' ] );
                if ( $_POST[ 'alt5' ] )
                        $image_alt_5 = mysql_real_escape_string( $_POST[ 'alt5' ] );

$sql = "UPDATE tourDB
                        SET
                         tour_name = '$tour_name', 
                         tour_type = '$tour_type', 
                         nights  = '$nights',
                         overview = '$overview',
                         itinerary = '$itinerary', 
                         inclusions = '$exclusions', 
                         twin_triple_sharing = '$single_occcupancy', 
                         child_with_no_bed = '$child_with_no_bed',
                         inf_below = '$inf_below',
                         keywords = '$keywords',
                         title = '$title',
                         description = '$description',
                         url = '$url',
                         categories = '$categories'
                         WHERE 
                         tour_id = '$id'";
                        return mysql_query( $sql ) or die( mysql_error() );

mysql_query($con, $sql);

mysql_close($con);

i havent wrote the full values, the mysql query yet but it will do for checking, i hope...?

 

here is the form, (left out most the javascript, and jquery etc....)

<?php
    $id = $_GET[ 'id' ];
    $q  = "SELECT * FROM tourDB WHERE tour_id = '$id' ";
    $r  = mysql_query( $q );
    if ( $r !== false && mysql_num_rows( $r ) > 0 ) {
      while ( $mfa = mysql_fetch_assoc( $r ) ) {
        $tour_id             = stripslashes( $mfa[ 'tour_id' ] );
        $tour_type           = stripslashes( $mfa[ 'tour_type' ] );
        $tour_name           = stripslashes( $mfa[ 'tour_name' ] );
        $day                 = stripslashes( $mfa[ 'day' ] );
        $nights              = stripslashes( $mfa[ 'nights' ] );
        $tour_price          = stripslashes( $mfa[ 'tour_price' ] );
        $overview            = stripslashes( $mfa[ 'overview' ] );
        $itinerary           = stripslashes( $mfa[ 'itinerary' ] );
        $terms_conditons     = stripslashes( $mfa[ 'terms_conditons' ] );
        $inclusions          = stripslashes( $mfa[ 'inclusions' ] );
        $exclusions          = stripslashes( $mfa[ 'exclusions' ] );
        $twin_triple_sharing = stripslashes( $mfa[ 'twin_triple_sharing' ] );
        $single_occcupancy   = stripslashes( $mfa[ 'single_occcupancy' ] );
        $child_with_no_bed   = stripslashes( $mfa[ 'child_with_no_bed' ] );
        $inf_below           = stripslashes( $mfa[ 'inf_below' ] );
        $pricing_details     = stripslashes( $mfa[ 'pricing_details' ] );
        $url                 = stripslashes( $mfa[ 'url' ] );
        $keywords        = stripslashes( $mfa['keywords']);
        $title         = stripslashes( $mfa['title']);
        $description       = stripslashes( $mfa['description']);
        $categories = stripslashes( $mfa['categories']);
        $image_alt_1 = stripslashes( $mfa['image_alt_1']);
        $image_alt_2 = stripslashes( $mfa['image_alt_2']);
        $image_alt_3 = stripslashes( $mfa['image_alt_3']);
        $image_alt_4 = stripslashes( $mfa['image_alt_4']);
        $image_alt_5 = stripslashes( $mfa['image_alt_5']);
        $pic_1_name = stripslashes( $mfa['pic_1_name']);
        $pic_2_name = stripslashes( $mfa['pic_2_name']);
        $pic_3_name = stripslashes( $mfa['pic_3_name']);
        $pic_4_name = stripslashes( $mfa['pic_4_name']);
        $pic_5_name = stripslashes( $mfa['pic_5_name']);
        $pic_1_file_size = stripslashes( $mfa['pic_1_file_size']);
        $pic_2_file_size = stripslashes( $mfa['pic_2_file_size']);
        $pic_3_file_size = stripslashes( $mfa['pic_3_file_size']);
        $pic_4_file_size = stripslashes( $mfa['pic_4_file_size']);
        $pic_5_file_size = stripslashes( $mfa['pic_5_file_size']);
        $pic_1_file_type = stripslashes( $mfa['pic_1_file_type']);
        $pic_2_file_type = stripslashes( $mfa['pic_2_file_type']);
        $pic_3_file_type = stripslashes( $mfa['pic_3_file_type']);
        $pic_4_file_type = stripslashes( $mfa['pic_4_file_type']);
        $pic_5_file_type = stripslashes( $mfa['pic_5_file_type']);
        $image_date_1 = stripslashes( $mfa['image_date_1']);
        $image_date_2 = stripslashes( $mfa['image_date_2']);
        $image_date_3 = stripslashes( $mfa['image_date_3']);
        $image_date_4 = stripslashes( $mfa['image_date_4']);
        $image_date_5 = stripslashes( $mfa['image_date_5']);
        if ( $tour_type == 'international' ) {
          $option1 = 'checked="checked"';
        } //$tour_type == 'international'
        elseif ( $tour_type == 'domestic' ) {
          $option2 = 'checked="checked"';
        } //$tour_type == 'domestic'
          elseif ( $tour_type == 'insta_deals' ) {
          $option3 = 'checked="checked"';
        } //$tour_type == 'insta_deals'
        else {
          $option = 'checked="checked"';
        }
        $edit_package = <<<EDIT_PACKAGE
<form action="edit.php?id=$id" method="post" enctype="multipart/form-data">
<script type="text/javascript" >
          $(function new_editor() {
           $('#transportation_$tour_id').wysiwyg({
              autoGrow: true,
              initialContent: "<p>Transportation Content</p>",
              maxHeight: 600
           });
          $('#payment-norms_$tour_id').wysiwyg({ 
              autoGrow: true,
              initialContent: "<p>Payment Content</p>",
              maxHeight: 600
          });
          $('#overview_$tour_id').wysiwyg({
              autoGrow: true,
              initialContent: "$overview",
              maxHeight: 600
          });
          $('#inclusions_$tour_id').wysiwyg({
              autoGrow: true,
              initialContent: "$inclusions",
              maxHeight: 600
          });
          $('#exclusions_$tour_id').wysiwyg({
              autoGrow: true,
              initialContent: "$exclusions",
              maxHeight: 600
          });
          $('#itinerary_$tour_id').wysiwyg({
              autoGrow: true,
              initialContent: "$itinerary",
              maxHeight: 600
          });
          $('#pricing_details_$tour_id').wysiwyg({
              autoGrow: true,
              initialContent: "$pricing_details",
            maxHeight: 600
          });
      });
          </script>
            <div id="tour-package" >
              <ul>
                <li><a href="#genral">General Information</a></li>
                <li><a href="#picture">Picture And Meta Info</a></li>
                <li><a href="#tour-inclusions">Tour Inclusions</a></li>
                <li><a href="#tour-feature">Itinerary</a></li>
                <!--<li><a href="#availibility">Availability and Others</a></li>-->
                <li><a href="#billing">Billing And Prices</a></li>
              </ul>
              <div id="genral">
                <input type="hidden" name="tour_id" value="$id" />
                <div class="package-element">
                  <p><span class="left" >Tour Name: <input type="text" name="tour_name" value= "$tour_name" id="tour_name" /></span></p>
                </div>
                <div class="package-element">
                  <p>Tour Type:
                    <select id="tour_type" name="tour_type" >
                      <option value="null-category" $option >Select Tour Type</option>
                      <option value="international" $option1 >International Tours</option>
                      <option value="domestic" $option2 > Domestic Tours </option>
                      <option value="insta_deals" $option3 >Insta Deals</option>
                    </select>
                  </p>
                </div>
                <div class="package-element">
                  <p>No. of Days: 
                    <input type="text" size="2" id="day" value="$day" name="day" />
                  </p>
                </div>
                <div class="package-element">
                  <p> No. of Nights:
                    <input type="text" name="nights" value="$nights" id="nights" size="2" />
                  </p>
                </div>
                <div class="package-element" >
                  <p> Sub categories 
                    <input type="text" name="categories" value="$categories" id="categories" size="5" />
                  </p>
                </div>
                <div class="package-element">
                  <div class="package-element-head">
                    <p>Overview of the package :</p>
                  </div>  <br />
                  <div class="package-element">
                    <textarea rows="10" cols="70" value="" id="overview_$tour_id" name="overview" ></textarea>
                  </div>
                </div>
                <div class="cleaner"></div><br />
              </div>
              <div id="picture" >
                <div class="chavi" >
                  <div class="package-element-head" >
                    <p>Pictures To upload (.jpg, .png) :</p>
                  </div>
                  <div class="cleaner"></div>
                  
                    <div class="chavi-element" >
                      <span class="left"> 1st Image </span>
                      <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic1" id="pic1" /></span>
                      <span class="right" ><input  value="$image_alt_1" id="alt1" name="alt1" type="text" size="20" />
                      </span><span class="right">Alt of 1st image  </span>
                    </div>
                  <div class="chavi-element" >
                    <span class="left">2nd Image </span>
                    <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic2" id="pic2" /></span>
                    <span class="right"><input value="$image_alt_2" name="alt2" id="alt2" type="text size="20" /></span>
                    <span class="right">Alt of 2nd image  </span>
                  </div>
                  <div class="chavi-element">
                    <span class="left" > 3rd Image</span>
                    <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic3" id="pic3" /></span>
                    <span class="right" ><input value="$image_alt_3" name="alt3" id="alt3" type="text" size="20" /></span>
                    <span class="right" >Alt of 3rd image  </span> 
                  </div>
                  <div class="chavi-element" >
                    <span class="left" >4th Image</span>
                    <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic4" id="pic4" /></span>
                    <span class="right"><input name="alt4" value="$image_alt_4" id="alt4" type="text" size="20" /></span>
                    <span class="right">Alt of 4th image  </span>
                  </div>
                  <div class="chavi-element" >
                    <span class="left" >5th Image</span>
                    <span class="left"><input type="file" accept ="image/gif, image/jpeg" name="pic5" id="pic5" /></span>
                    <span class="right"><input type="text" value="$image_alt_5" name="alt5" id="alt5" size="20" /></span>
                    <span class="right">Alt of 5th image  </span>
                  </div>
                </div>
                <div class="meta-info">
                  <div class="package-element-head" >
                    <p>Title:</p>
                  </div>
                  <div class="package-element" >
                    <input type="text" value="$title" size="30" id="title" name="title" />
                  </div>
                  <div class="package-element-head-2" >
                  Keywords:
                  </div>
                  <div class="package-element" >
                    <textarea rows="5" value="$keywords" cols="28" id="keywords" name="keywords" >$keywords</textarea>
                  </div>
                </div>
                <div class="meta-info" >
                  <div class="package-element-head" >
                    Description:
                  </div>
                  <div class="package-element" >
                    <textarea rows="5" cols="30" value="$description" name="description" id="description">$description</textarea>
                  </div>
                  <div class="package-element-head-2" >
                    URL of the page:
                  </div>
                  <div class="package-element" >
                    <input type="text" size="30" value="$url" name="url" id="url" onblur="this.value=removeSpaces(this.value);" />
                  </div>
                </div>
                <div class="cleaner"></div>
              </div>
              <div id="tour-inclusions">
                <div class="inclusions-exclusions">
                  <div class="package-element-head" >
                  Inclusions:
                  </div>
                  <div class="package-element" >
                    <textarea rows="10" cols="70" name="inclusions" id="inclusions_$tour_id"></textarea>
                  </div>
                </div>
                <div class="inclusions-exclusions">
                  <div class="package-element-head" >
                  Exlcusions:
                  </div>
                  <div class="package-element">
                    <textarea rows="10" cols=70" name="exclusions" id="exclusions_$tour_id"></textarea>
                  </div>
                </div>
                <div class="cleaner"></div>
              </div>
              <div id="tour-feature">
                <div class="package-element-head">
                  Itinerary:
                </div>
                <div class="package-element" >
                  <textarea rows="30" cols="75" name="itinerary" id="itinerary_$tour_id"></textarea>
                </div> 
                <div class="cleaner"></div>
              </div>
              <div id="billing">
                <div class="price-tab" >
                        <div class="price-tab-row" >
                            <div class="price-tab-element">
                              <b>Pax Type</b>
                            </div>
                            <div class="price-tab-element">
                              <b>Tour Price Total in INR</b>
                            </div>
                        </div>
                        <div class="price-tab-row" >
                            <div class="price-tab-element" >
                              Twin/Triple Sharing
                            </div>
                            <div class="price-tab-element" >
                              <span class="rupee">`</span> <input typ="text" value="$twin_triple_sharing" size="7" name="twin_triple_sharing" id="twin_triple_sharing" />
                            </div>
                        </div>
                        <div class="price-tab-row" >
                            <div class="price-tab-element" >
                              Single Occupancy 
                            </div>
                            <div class="price-tab-element" >
                              <span class="rupee">`</span> <input type="text" size="7" name="single_occcupancy" id="single_occcupancy" value=" $single_occcupancy "/>
                            </div>
                        </div>
                        <div class="price-tab-row">
                            <div class="price-tab-element" >
                              Child With No Bed
                            </div>
                            <div class="price-tab-element">
                              <span class="rupee" >`</span> <input type="text" size="7" value="$child_with_no_bed" name="child_with_no_bed" id="child_with_no_bed" />
                            </div>
                        </div>
                        <div class="price-tab-row">
                            <div class="price-tab-element">
                              Infant below 2 years
                            </div>
                            <div class="price-tab-element" >
                              <span class="rupee" >`</span> <input type="text" value="$inf_below" size="7" name="inf_below" id="inf_below" />
                            </div>
                        </div>
                        <div class="package-element-head-2">Terms And Conditions:</div>
                        <div class="cleaner"></div>
                        <div class="package-element" >
                          <textarea rows="10" cols="70" value="$terms_conditions" id="pricing_details_$tour_id" name="terms_conditions" ></textarea>
                        </div>
                        <input type="submit" name="submit" id="submit" value="Create This Entry!" />
                        <div class="cleaner" ></div>
                      </div> 
              </div>
            </div>
          </form>
    <br />
    </div>

EDIT_PACKAGE;
      } //$mfa = mysql_fetch_assoc( $r )
    } //$r !== false && mysql_num_rows( $r ) > 0
    else {
    $edit_package = <<<EDIT_PACKAGE
    <div class="domestic-tours">
    <ul>
    <li><a href="#notice">Notice</a></li>
    </ul>
    <div id="notice" > 
    <h2> The tour does not exist </h2>
    </div>
    <div class="cleaner" ></div>
    </div>
    EDIT_PACKAGE;   
    }
    echo $edit_package;
?>

The whole script is bit big so, if needed i will attach the files ... some of it are in functions within a class...

Edited by cyber_alchemist
Link to comment
https://forums.phpfreaks.com/topic/283080-cant-update-my-tables/
Share on other sites

post is being initiated... it is showing in array , and even it says that data is added to database

if ( $_SERVER['REQUEST_METHOD'] == 'POST') {
echo 'Request initiated for post !';
if($obj->edit($_POST) === false) {
echo 'Sorry, no data added to database';
} else {
echo 'data has been added to database';
}
}

but the data stays the same ..???? :confused:

----------------

 

 

edited: oops sorry , no data has been added to database..

 

:sweat: here is the function

public function edit( $p ) {
                $id = 7;
                if ( $_POST['tour_id'] )
                        $tour_id = mysql_real_escape_string( $_POST['tour_id']);
                if ( $_POST[ 'tour_name' ] )
                        $tour_name = mysql_real_escape_string( $_POST[ 'tour_name' ] );
                if ( $_POST[ 'tour_type' ] )
                        $tour_type = mysql_real_escape_string( $_POST[ 'tour_type' ] );
                if ( $_POST[ 'day' ] )
                        $day = mysql_real_escape_string( $_POST[ 'day' ] );
                if ( $_POST[ 'nights' ] )
                        $nights = mysql_real_escape_string( $_POST[ 'nights' ] );
                if ( $_POST[ 'twin_triple_sharing' ] )
                        $twin_triple_sharing = mysql_real_escape_string( $_POST[ 'twin_triple_sharing' ] );
                if ( $_POST[ 'overview' ] )
                        $overview = mysql_real_escape_string( $_POST[ 'overview' ] );
                if ( $_POST[ 'itinerary' ] )
                        $itinerary = mysql_real_escape_string( $_POST[ 'itinerary' ] );
                if ( $_POST[ 'inclusions' ] )
                        $inclusions = mysql_real_escape_string( $_POST[ 'inclusions' ] );
                if ( $_POST[ 'exclusions' ] )
                        $exclusions = mysql_real_escape_string( $_POST[ 'exclusions' ] );
                if ( $_POST[ 'single_occcupancy' ] )
                        $single_occcupancy = mysql_real_escape_string( $_POST[ 'single_occcupancy' ] );
                if ( $_POST[ 'child_with_no_bed' ] )
                        $child_with_no_bed = mysql_real_escape_string( $_POST[ 'child_with_no_bed' ] );
                if ( $_POST[ 'inf_below' ] )
                        $inf_below = mysql_real_escape_string( $_POST[ 'inf_below' ] );
                if ( $_POST[ 'keywords' ] )
                        $keywords = mysql_real_escape_string( $_POST[ 'keywords' ] );
                if ( $_POST[ 'title' ] )
                        $title = mysql_real_escape_string( $_POST[ 'title' ] );
                if ( $_POST[ 'description' ] )
                        $description = mysql_real_escape_string( $_POST[ 'description' ] );
                if ( $_POST[ 'url' ] )
                        $url = mysql_real_escape_string( $_POST[ 'url' ] );
                if ( $_POST[ 'categories' ] )
                        $categories = mysql_real_escape_string( $_POST[ 'categories' ] );
                if ( $_POST[ 'alt1' ] )
                        $image_alt_1 = mysql_real_escape_string( $_POST[ 'alt1' ] );
                if ( $_POST[ 'alt2' ] )
                        $image_alt_2 = mysql_real_escape_string( $_POST[ 'alt2' ] );
                if ( $_POST[ 'alt3' ] )
                        $image_alt_3 = mysql_real_escape_string( $_POST[ 'alt3' ] );
                if ( $_POST[ 'alt4' ] )
                        $image_alt_4 = mysql_real_escape_string( $_POST[ 'alt4' ] );
                if ( $_POST[ 'alt5' ] )
                        $image_alt_5 = mysql_real_escape_string( $_POST[ 'alt5' ] );
                if ( isset( $tour_name ) && isset( $day ) && isset( $nights ) && isset( $twin_triple_sharing ) && isset( $overview ) && isset( $itinerary ) && isset( $inclusions ) && isset( $exclusions ) && isset( $single_occcupancy ) && isset( $child_with_no_bed ) && isset( $inf_below ) && isset( $keywords ) && isset( $title ) && isset( $description ) && isset( $categories ) ) {
                        $sql = "UPDATE tourDB
                        SET
                         tour_name = '$tour_name', 
                         tour_type = '$tour_type', 
                         nights  = '$nights',
                         overview = '$overview',
                         itinerary = '$itinerary', 
                         inclusions = '$exclusions', 
                         twin_triple_sharing = '$single_occcupancy', 
                         child_with_no_bed = '$child_with_no_bed',
                         inf_below = '$inf_below',
                         keywords = '$keywords',
                         title = '$title',
                         description = '$description',
                         url = '$url',
                         categories = '$categories'
                         WHERE 
                         tour_id = '$id'";
                        return mysql_query( $sql ) or die( mysql_error() );
                } //isset( $tour_name ) && isset( $day ) && isset( $nights ) && isset( $twin_triple_sharing ) && isset( $overview ) && isset( $itinerary ) && isset( $inclusions ) && isset( $exclusions ) && isset( $single_occcupancy ) && isset( $child_with_no_bed ) && isset( $inf_below ) && isset( $keywords ) && isset( $title ) && isset( $description ) && isset( $categories )
                else {
                        return false;
                }

as for id is set 7.

Edited by cyber_alchemist
  • Solution

edited: oops sorry , no data has been added to database..

Update queries don't add new entries to the database. Your update query only modifies records where the  tour_id matches the value of $id

 

EDIT

 

Also with update queries you need to check to see if the query modified any records with mysql_affected_rows, not by checking what mysql_query returns.

 

Change

	        return mysql_query( $sql ) or die( mysql_error() );
	    } //isset( $tour_name ) && isset( $day ) && isset( $nights ) && isset( $twin_triple_sharing ) && isset( $overview ) && isset( $itinerary ) && isset( $inclusions ) && isset( $exclusions ) && isset( $single_occcupancy ) && isset( $child_with_no_bed ) && isset( $inf_below ) && isset( $keywords ) && isset( $title ) && isset( $description ) && isset( $categories )
	    else {
	            return false;
	    }

to

	        $result = mysql_query( $sql ) or die( mysql_error() );

	        if($result && mysql_affected_rows($result) != 0)
	        {
	        	return true;
	        }
	    }
	    
	    return false;
Edited by Ch0cu3r

Update queries don't add new entries to the database. Your update query only modifies records where the  tour_id matches the value of $id

 

so how do i check where the database is updating my request ???

 

I am checking through phpMyAdmin and the data stays the same. :confused:

Edited by cyber_alchemist
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.