Jump to content

Recommended Posts

why I am getting this error ???

 

Warning: Missing argument 1 for manage::new_package(), called in /home/content/52/11446152/html/excitetrips/session/admin-logged.php on line 214 and defined in/home/content/52/11446152/html/excitetrips/session/core/core-management.php on line 1245

 

 

this is script i was working on...

admin-logged.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="apple-touch-icon-precomposed" href="../img/logo.png" />
<meta name="viewport" content="width=400, initial-scale=1.0" />


<title>Excite trips , your best travel trips</title>
    <link rel="shortcut icon" type="image/x-icon" href="../img/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="css/bjqs.css" />

    <link rel="stylesheet" type="text/css" media="only screen and (max-device-width: 990px)" href="css/mobile.css" />
    <link rel="stylsheet" type="text/css" media="print" href="../css/print.css" />
    <link rel="stylesheet" type="text/css" href="../css/jquery-ui-1.10.3.custom.css" />
    <link href="../style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="../css/jquery.wysiwyg.css" type="text/css"/>

<script type="text/javascript" src="js/mobile-redirection-2.js" ></script>


    <script type="text/javascript" src="../js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="../js/bjqs-1.3.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.10.3.custom.js"></script>
    <script type="text/javascript" src="../js/jquery.validate.js" ></script>
    <script type="text/javascript" src="../js/jquery.wysiwyg.js"></script>
    <script type="text/javascript" src="../js/wysiwyg.image.js"></script>
    <script type="text/javascript" src="../js/wysiwyg.link.js"></script>
    <script type="text/javascript" src="../js/wysiwyg.table.js"></script>

    <script type="text/javascript">

      $(function domestic_boxes(){
        $('.domestic-tours').tabs();
        /*
        $('#book-now').button();
        $('#call').button();
        */
        $('#submit').button();
      });

      $(function icons(){
            // Hover states on the static widgets
    $( "#dialog-link, #icons li" ).hover(
      function() {
        $( this ).addClass( "ui-state-hover" );
      },
      function() {
        $( this ).removeClass( "ui-state-hover" );
      }
    );
      });
     $(function icon() {
      // hover states on static images
        $( "#dialog-link, #icons li" ).hover(
          function() {
            $( this ).addClass( "ui-state-hover" );
          },
          function() {
             $( this ).removeClass( "ui-state-hover" );
          }
        );
    });
    $(function TourInput(){
      $('#tour-package').tabs();
        $('#days').keyup(function pickdays() {
          if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                this.value = this.value.replace(/[^0-9\.]/g, '');
            }
        });
        $('#nights').keyup(function picknights() {
          if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                this.value = this.value.replace(/[^0-9\.]/g, '');
            }
        });
        $('#twin_triple_shareing').keyup(function picknights() {
          if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                this.value = this.value.replace(/[^0-9\.]/g, '');
            }
        });
        $('#single_occupancy').keyup(function picknights() {
          if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                this.value = this.value.replace(/[^0-9\.]/g, '');
            }
        });
        $('#child_no_bed').keyup(function picknights() {
          if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                this.value = this.value.replace(/[^0-9\.]/g, '');
            }
        });
        $('#infbelow').keyup(function picknights() {
          if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                this.value = this.value.replace(/[^0-9\.]/g, '');
            }
        }); 

/*
        $('#transportation').wysiwyg({
          autoGrow: true,
          maxHeight: 600
        });
        $('#payment-norms').wysiwyg({ 
          autoGrow: true,
          maxHeight: 600
        });
        $('#overview').wysiwyg({
          autoGrow: true,
          maxHeight: 600
        });
        $('#inclusions').wysiwyg({
          autoGrow: true,
          maxHeight: 600
        });
        $('#exclusions').wysiwyg({
          autoGrow: true,
          maxHeight: 600
        });
        $('#itinerary').wysiwyg({
          autoGrow: true,
          maxHeight: 600
        });
        $('#pricingdetails').wysiwyg({
          autoGrow: true,
          maxHeight: 600
        });
*/
      });
    </script>
    <script type="text/javascript">
      function removeSpaces(string) {
         return string.split(' ').join('');
        }
    </script>

</head>

<body>
<!--Header End -->
<div id="header">
  <div class="header-top">
    <div class="head-left"><a href="index.html" ><img alt="Car hire Kolkata" src="../img/site-logo.png" /></a></div>
    <div class="contact"><div class="head-left"><img height="50" width="55"  alt="telephone" src="../img/telephone.png" /></div><div class="head-right">+919830042523</div></div>
    <div class="contact"><div class="head-left"><img height="50" width="55" alt="email" src="../img/email.png" /></div><div class="head-right">support@excitetrips.com</div></div>
  </div>
  <div class="cleaner"></div>
    <div class="navbar">
       <ul class="nav">
            <li><a href="admin-logged.php"><strong>Dashboard</strong></a></li>
            <li><a href="admin-logged.php?tour_type=international"><strong>International</strong></a></li>
            <li><a href="admin-logged.php?tour_type=domestic"><strong>Domestic</strong></a></li>
            <li><a href="admin-logged.php?tour_type=insta_deals"><strong>Insta Deals</strong> </a></li>
            <li><a href="#"><strong>Add Package</strong> </a></li>
           	<li><a href="insta-deals.html"><strong>Log Out</strong> </a></li>
        </ul>
    </div>
</div>

<!--Header End -->
    <!--Container -->
    <div id="container">
      <div class="cleaner"></div>
      <div class="package-part-left" >
      <div class="domestic-tour-lists"> 

         <?php
include_once( 'core/core-management.php' );
$tour_type = $_GET['tour_type'];
$package_edit = $_GET['package_edit'];
$manage           = new manage();
/* SETTINGS FOR DATABASE */
$manage->manage_host     = 'localhost';
$manage->manage_username = 'username';
$manage->manage_password = 'pass';
$manage->manage_table    = 'table';
$manage->connect_core();




if (isset($update)) {
  $manage->update_pic_1( $_POST );
  $manage->update_pic_2( $_POST );
  $manage->update_pic_3( $_POST );
  $manage->update_pic_4( $_POST );
  $manage->update_pic_5( $_POST );
  $manage->update_text( $_POST );
}
/*
if ( $_POST ) {
        
        printf('<pre>POST %s</pre>', print_r($_POST, true));
        echo 'post initiated !!';
      
        $manage->write( $_POST );
}

if ( $_SERVER['REQUEST_METHOD'] == 'POST') {
echo 'Request initiated for post !';}

if($manage->write($_POST) === false) {
echo 'Sorry, no data added to database';
} else {
echo 'data has been added to database';
}
*/
if ( isset($tour_type)) {
	switch ($tour_type) {
    case "international":
        echo $manage->packages_international();
        continue;
    case "domestic":
        echo $manage->packages_domestic();
        continue;
    case "insta_deals":
        echo $manage->packages_insta_deals();
        continue;
    default:
    	echo 'internal error !! stop messing with my url !!!';
    }
}elseif(isset($package_edit)) {
  switch ($package_edit) {
    case "new_package":
      echo $manage->new_package($new_package);
      break;
    case "edit_package":
      echo $manage->edit_package();
      break;
    case "delete_package":
      echo $manage->delete_package();
    break;
  }
} 
else {
    	echo $manage->display_all();
  }
?>

and the core-management.php is attached to this post

core-management.php

Link to comment
https://forums.phpfreaks.com/topic/283043-missing-argument-1-error/
Share on other sites

Look at edit below

 

You are passing the new_package() method an undefined variable $new_package

echo $manage->new_package($new_package);

You cannot call new_package with an undefined variable.

 

 

EDIT. 

 

Looking at the source for the new_package method it doest need anything passed to it. Change line  1245 in core-management to

	public function new_package() {

Call new_package using

echo $manage->new_package();
Edited by Ch0cu3r

sorry to pick on your code again (i see in a previous thread i tried to point out some things that would improve and reduce your code.) reducing your code will make it easier and faster for you to complete your task, even if you would need to spend some time initially rearranging the code.

 

you have a 2400+ line class that is full of copy/pasted code that only differs by a type value. you probably only have about 800 lines of code that are unique in that class. i copied two of the repeated blocks of code into files to do a difference on them and i also see some typo's/markup in the code that is probably not doing what you expected. the inconstancies between the blocks of code are a result of you having a huge wall of code where you cannot keep track of what is going on or what changes you need to make in each similar block.

 

so, DRY (Don't Repeat Yourself). you should not be repeating huge blocks of code. the code method you are using creates a lot of extra work for you in modifying/correcting anything since you must make the same modification/correction in multiple places.

 

you need to re-factor/reduce your code and pull out the common part from the repetitive blocks so that the code only exists once.

 

the only real difference in the repetitive blocks are the tour_type value they are using. so, just make one (private) function in your class that accepts the tour_type value as a call time parameter. the existing functions would just call this new function and pass it the appropriate tour_type value.

as a continuation of the above, i looked at your code more, and you basically have code, used in multiple places, that is displaying information retrieved by a query, that only differs in the actual query statement and if it should display some admin links/logic.

 

so, why not make a function that takes that information (the query, an admin indicator) as its inputs and then reuses just one instance of the display code?

 

the following is only the part of your class that uses this common display function and is untested and may contain typos or other problems, but shows how you can eliminate the repetition in your code -

class manage {

// ===================================================================================================
    public function display_all( ) {
        $show = $_GET[ 'show' ] + 5;
        $query = "SELECT * FROM tourDB ORDER BY tour_id DESC LIMIT $show";
        return $this->display_packages($query);
    }
    
// ===================================================================================================
    public function international_list_manage( ) {
        $categories = $_GET[ 'international-tours' ];
        $query = "SELECT *
          FROM tourDB
          WHERE categories LIKE '$categories'";
        return $this->display_packages($query,true); // second parameter true causes admin menu to be displayed
    }
    
// ===================================================================================================
    public function domestic_list_manage( ) {
        $categories = $_GET[ 'india-tourism' ];
        $query = "SELECT *
          FROM tourDB
          WHERE categories LIKE '$categories'";
        return $this->display_packages($query,true); // second parameter true causes admin menu to be displayed
    }
    
// ===================================================================================================
    public function insta_deals_list_manage() {
        $categories = $_GET[ 'travel-deals' ];
        $query = "SELECT *
          FROM tourDB
          WHERE categories LIKE '$categories'";
        return $this->display_packages($query,true); // second parameter true causes admin menu to be displayed
    }

// ===================================================================================================
    public function packages_international( ) {
        $query = "SELECT *
          FROM tourDB
          WHERE  tour_type LIKE 'international'";
        return $this->display_packages($query);
    }

// ===================================================================================================
    public function packages_domestic( ) {
        $query = "SELECT *
          FROM tourDB
          WHERE  tour_type LIKE 'domestic'";
        return $this->display_packages($query);
    }

// ===================================================================================================
    public function packages_insta_deals( ) {
        $query = "SELECT *
          FROM tourDB
          WHERE  tour_type LIKE 'insta_deals'";
        return $this->display_packages($query);
    }
    
// ===================================================================================================
    private function display_packages($query,$admin=false){
        // common code to use the input paramters
        $result = mysql_query( $query ) or die( mysql_error() );
        if ( $result !== false && mysql_num_rows( $result ) > 0 ) {
            while ( $nlist = mysql_fetch_assoc( $result ) ) {
                $tour_id             = stripslashes( $nlist[ 'tour_id' ] );
                $tour_type           = stripslashes( $nlist[ 'tour_type' ] );
                $tour_name           = stripslashes( $nlist[ 'tour_name' ] );
                $day                 = stripslashes( $nlist[ 'day' ] );
                $nights              = stripslashes( $nlist[ 'nights' ] );
                $tour_price          = stripslashes( $nlist[ 'tour_price' ] );
                $overview            = stripslashes( $nlist[ 'overview' ] );
                $itinerary           = stripslashes( $nlist[ 'itinerary' ] );
                $terms_conditons     = stripslashes( $nlist[ 'terms_conditons' ] );
                $inclusions          = stripslashes( $nlist[ 'inclusions' ] );
                $exclusions          = stripslashes( $nlist[ 'exclusions' ] );
                $twin_triple_sharing = stripslashes( $nlist[ 'twin_triple_sharing' ] );
                $single_occcupancy   = stripslashes( $nlist[ 'single_occcupancy' ] );
                $child_with_no_bed   = stripslashes( $nlist[ 'child_with_no_bed' ] );
                $inf_below           = stripslashes( $nlist[ 'inf_below' ] );
                $pricing_details     = stripslashes( $nlist[ 'pricing_details' ] );
                $url                 = stripslashes( $nlist[ 'url' ] );
                $insta_deals_list_cat .= <<<INSTA_DEALS_LIST_CAT
<div class="domestic-tours">
        <ul>
            <li><a href="#overview_$url">Overview</a></li>
            <li><a href="#itinerary_$url">Itinerary</a></li>
            <li><a href="#inclusions_$url">Inclusions</a></li>
            <li><a href="#terms_$url">Terms And Conditions</a></li>
            <li><a href="#price_$url">Tour Price</a></li>
        </ul>
        <div id="overview_$url">
    
            <div id="dest-thumb-nail_$tour_id" class="dest-thumb-nail">
              <ul class="bjqs">
                <li><img alt="$image_alt_1" src="image-display.php?image=1&id=$tour_id" /></li>
                <li><img alt="$image_alt_2" src="image-display.php?image=2&id=$tour_id" /></li>
                <li><img alt="$image_alt_2" src="image-display.php?image=3&id=$tour_id" /></li>
                <li><img alt="$image_alt_4" src="image-display.php?image=1&id=$tour_id" /></li>
                <li><img alt="$image_alt_5" src="image-display.php?image=1&id=$tour_id" /></li>
              </ul>
            </div>
            <script type="text/javascript" >
              $(function slideslide_$tour_id() {
                  $('#dest-thumb-nail_$tour_id').bjqs({
                    height     : 200,
                    width      : 250,
                    responsive : true
                  });
                });
            </script>

            <div class="overview">
              <span class="overview-heading">$tour_name</span><br /><br />
              <span class="overview-duration">$nights Nights , $day Days</span><br /><br />
                $overview
            </div>
        </div>
        <div id="itinerary_$url">
          <div class="itin-content">
            <span class="overview-heading">$tour_name</span><br /><br />
            <span class="overview-duration">$nights Nights, $day Days</span><br /><br /><br />
            $itinerary
          </div>
        </div>
        <div id="inclusions_$url">
          <div class="inclusions-exclusions">
            <span class="inclusions">Inclusions</span><br /><br />
              $inclusions
            <br />
            <br />
            <span class="exclusions">Exclusions</span><br /><br />
              $exclusions
            <br />
            <br />
          </div>
        </div>
        <div id="terms_$url">
          <div class="terms" >
            <span class="terms-and-conditions" >Terms And Conditions </span><br /><br />
            $terms_conditons
          </div>
        </div>
        <div id="price_$url">
          <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> $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> $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> $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" >
                FREE
              </div>
            </div>
            <button id="book-now_$tour_id">Book Now !</button>
            <button id="call_$tour_id" >call your travel expert</button>
            <script type="text/javascript">

                  $(function domestic_buttons(){
                       $('#book-now_$tour_id').button();
                     $('#call_$tour_id').button();
                  });
          </div>
        </div>
      </div>
      <div class="price-tag-domestic"><span class="pricy-price" >` $tour_price</span></div>
      <div class="cleaner"></div>
      <a href="admin-logged.php?package_edit=delete_package&id=$tour_id" id="delete_$tour_id" >Delete Tour</a>
      <a href="admin-logged.php?package_edit=edit_package&id=$tour_id" id="edit_$tour_id">Edit Tour</a>
      <script type="text/javascript" >
          $(function edit_package_$tour_id(){
              $('#delete_$tour_id').button();
              $('#edit_$tour_id').button();
          });
      </script>
      <div class="cleaner"></div>
      <br />
      <br />
      <div class="cleaner"></div>
INSTA_DEALS_LIST_CAT;

    if($admin){ // show admin menu
        $insta_deals_list_cat .= <<<EOT
      <a href="admin-logged.php?package_edit=delete_package&id=$tour_id" id="delete_$tour_id" >Delete Tour</a>
      <a href="admin-logged.php?package_edit=edit_package&id=$tour_id" id="edit_$tour_id">Edit Tour</a>
      <script type="text/javascript" >
          $(function edit_package_$tour_id(){
              $('#delete_$tour_id').button();
              $('#edit_$tour_id').button();
          });
      </script>
      <div class="cleaner"></div>
      <br />
      <br />
      <div class="cleaner"></div>
EOT;
    }
            } //$ilist = mysql_fetch_assoc( $result )
        } //$result !== false && mysql_num_rows( $result ) > 0
        else {
            $insta_deals_list_cat = <<<INTERNATIONAL_LIST_CAT

<div class="domestic-tours">
<ul>
  <li><a href="#notice">Notice</a></li>
</ul>
  <div id="notice" >
    <h2> This Page Is Under Construction </h2>
    <p>$international_categories</p>
    <p>
      No entries have been made on this page.
      Please check back soon, or click the
      link below to add an entry!
    </p>
  </div>
  <div class="cleaner" ></div>
</div>

INTERNATIONAL_LIST_CAT;
        }
        $insta_deals_list_cat .= <<<INTERNATIONAL_LIST_CAT
</div>
<div class="pager-items" >
  <div class="pager-display-element">
    <ul id="icons" class="ui-widget ui-helper-clearfix">
      <li class="ui-state-default ui-corner-all">View more Excite Trips</li>
      <li class="ui-state-default ui-corner-all"><a href="{$_SERVER['PHP_SELF']}?show=0">5</a></li>
      <li class="ui-state-default ui-corner-all"><a href="{$_SERVER['PHP_SELF']}?show=5">10</a></li>
      <li class="ui-state-default ui-corner-all"><a href="{$_SERVER['PHP_SELF']}?show=15">20</a></li>
      <li class="ui-state-default ui-corner-all"><a href="{$_SERVER['PHP_SELF']}?show=45">50</a></li>
    </ul>
  </div>
</div>
<!--
    <p class="admin_link">
      <a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a>
      <a href="{$_SERVER['PHP_SELF']}?show=0">Show 5</a>
      <a href="{$_SERVER['PHP_SELF']}?show=5">Show 10</a>
      <a href="{$_SERVER['PHP_SELF']}?show=15">Show 20</a>
      <a href="{$_SERVER['PHP_SELF']}?show=35">Show 40</a>
      <a href="{$_SERVER['PHP_SELF']}?show=45">Show 50</a>
      <a href="{$_SERVER['PHP_SELF']}?next_end=2">Next</a>
    </p>
    -->
INTERNATIONAL_LIST_CAT;
        return $insta_deals_list_cat;
    } // end of international_list_display();

}
?>

the above changes reduced your file size to 1280 lines and i only changed the display code, you have other repetitive code in that file that can be reduced.

slight fix on the above posted, untested, example code, the admin links section in the output are both unconditionally listed and inside of a conditional statement. the first unconditional set should not be there and is leftover from the block of code i started with vs the intended posted code.

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.