cyber_alchemist Posted October 3, 2013 Share Posted October 3, 2013 before i a had a bit of problem with MySQL but now i dont know what went wrong the script works fine , in genral but its first post is always double ..??? why so ?? i haven't repeated any thing .. did I ?? any guidance will be helpful. codes: index.php <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/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 slideslide() { $('#slider-inner').bjqs({ height : 400, width : 620, responsive : true }); $('#dest-thumb-nail').bjqs({ height : 200, width : 250, responsive : true }); $('#dest-thumb-nail-2').bjqs({ height : 200, width : 250, responsive : true }); }); $(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-inner"> <div class="header-top"> <div class="head-left"><a href="index.html" ><img src="img/site-logo.png" /></a></div> <div class="contact"><div class="head-left"><img height="50" width="55" src="img/telephone.png" /></div><div class="head-right">+919830042523</div></div> <div class="contact"><div class="head-left"><img height="50" width="55" src="img/email.png" /></div><div class="head-right">support@excitetrips.com</div></div> </div> <div class="cleaner"></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('_class/tourCMS.php'); $obj = new tourCMS(); /* SETTINGS FOR DATABASE */ $obj->host = 'localhost'; $obj->username = 'sim'; $obj->password = 'simptech'; $obj->table = 'sim'; $obj->connect(); if ( $_POST ) { /* printf('<pre>POST %s</pre>', print_r($_POST, true)); echo 'post initiated !!'; */ $obj->write($_POST); } /* if ( $_SERVER['REQUEST_METHOD'] == 'POST') { echo 'Request initiated for post !'; if($obj->write($_POST) === false) { echo 'Sorry, no data added to database'; } else { echo 'data has been added to database'; } } */ echo ( $_GET['admin'] == 1 ) ? $obj->display_admin() : $obj->display_public(); ?> </div> <div class="package-part-right" > <div class="international-tours-panel"> <div class="international-packages-header"> International Tour Packages </div> <a class="international-tour-box-element" href="#">Singapore Tour Packages</a> <a class="international-tour-box-element" href="#">Malasiya Tour Packages</a> <a class="international-tour-box-element" href="#">Thailand Tour Packages</a> <a class="international-tour-box-element" href="#">Japan Tour Packages</a> </div> <div class="domestic-tours-panel" > <div class="domestic-packages-header"> Holidays In India </div> <a class="domestic-tour-box-element" href="#">Kashmir Tour Packages</a> <a class="domestic-tour-box-element" href="#">Kerela Tour Packages</a> <a class="domestic-tour-box-element" href="#">West Bengal Tour Packages</a> </div> <div class="insta-deals-panel" > <div class="insta-deals-packages-header"> Insta Holidays Deals </div> <a class="insta-deals-box-element" href="#">Cheap Mauritius </a> <a class="insta-deals-box-element" href="#">Amazing Thailand</a> </div> <!-- <div class="international-tour-box" > <h3>International Tour Packages</h3> <div class="international-tour-element" > <a href="#">Singapore Tour Packages</a> </div> </div> <div class="domestic-tour-box" > <h3>Holidays In India</h3> </div> <div class="insta-deals-box" > <h3>Insta deals </h3> </div> --> </div> <!--container end --> </div> <div class="cleaner" ></div> <div class="cleaner"></div> <div class="ms_bottomWrap" ><div class="ms_bottomWrap_inner"><div class="hk_default00"> <div class="lfta"> <ul> <li><a href="#">Home</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Blog</a></li> </ul> </div> <div class="lfta"> <ul> <li><a href="#">Car Rentals</a></li> <li><a href="#">Kolkata City tour</a></li> <li><a href="#">Gangasagar Day Tour</a></li> </ul> </div> <div class="lfta"> <ul> <li><a href="#"> Terms and Conditions</a></li> <li><a href="#"> Privacy Policy</a></li> <li><a href="#">Terms of Use</a></li> <li><a href="#">FAQ</a></li> </ul> </div> and tourCMS.php file : <?php class tourCMS { var $host; var $username; var $password; var $table; public function display_public() { $show = $_GET['show'] + 5; $q = "SELECT * FROM tourDB ORDER BY tour_id DESC LIMIT $show"; $r = mysql_query($q); if ($r !== false){ echo 'r is not false !'; } if ( $r !== false && mysql_num_rows($r) > 0 ) { while ( $a = mysql_fetch_assoc($r) ) { $tour_id = stripslashes($a['tour_id']); $tour_type = stripslashes($a['tour_type']); $tour_name = stripslashes($a['tour_name']); $day = stripslashes($a['day']); $nights = stripslashes($a['nights']); $tour_price = stripslashes($a['tour_price']); $overview = stripslashes($a['overview']); $itinerary = stripslashes($a['itinerary']); $terms_conditons = stripslashes($a['terms_conditons']); $inclusions = stripslashes($a['inclusions']); $exclusions = stripslashes($a['exclusions']); $twin_triple_sharing = stripslashes($a['twin_triple_sharing']); $single_occcupancy = stripslashes($a['single_occcupancy']); $child_with_no_bed = stripslashes($a['child_with_no_bed']); $inf_below = stripslashes($a['inf_below']); $pricing_details = stripslashes($a['pricing_details']); $url = stripslashes($a['url']); $entry_display .= <<<ENTRY_DISPLAY <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" class="dest-thumb-nail"> <ul class="bjqs"> <li><img src="img/bangkok/1.jpg" /></li> <li><img src="img/bangkok/2.jpg" /></li> <li><img src="img/bangkok/3.jpg" /></li> <li><img src="img/bangkok/4.jpg" /></li> <li><img src="img/bangkok/5.jpg" /></li> <li><img src="img/bangkok/6.jpg" /></li> <li><img src="img/bangkok/6.jpg" /></li> </ul> </div> --> <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">Book Now !</button> <button id="call" >call your travel expert</button> </div> </div> </div> <div class="price-tag-domestic"><span class="pricy-price" >` $tour_price</span></div> <div class="cleaner"></div> ENTRY_DISPLAY; } } else { $entry_display = <<<ENTRY_DISPLAY <div class="domestic-tours"> <ul> <li><a href="#notice">Notice</a></li> </ul> <div id="notice" > <h2> This Page Is Under Construction </h2> <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> ENTRY_DISPLAY; } $entry_display .= <<<ADMIN_OPTION </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> --> ADMIN_OPTION; return $entry_display; } public function display_admin() { return <<<ADMIN_FORM <form action="{$_SERVER['PHP_SELF']}" method="post" > <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"> <div class="package-element"> <p><span class="left" >Tour Name: <input type="text" name="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" checked="checked" >Select Tour Type</option> <option value="international" >International Tours</option> <option value="domestic" > Domestic Tours </option> <option value="insta_deals" >Insta Deals</option> </select> </p> </div> <div class="package-element"> <p>No. of Days: <input type="text" size="2" id="day" name="day" /> </p> </div> <div class="package-element"> <p> No. of Nights: <input type="text" name="nights" id="nights" size="2" /> </p> </div> <div class="package-element" > <p> Sub categories <input type="text" name="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" id="overview" 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="right"><input type="file" accept ="image/gif, image/jpeg" name="pic1" id="pic1" /></span> </div> <div class="chavi-element" > <span class="left">2nd Image</span><span class="right"><input type="file" accept ="image/gif, image/jpeg" name="pic2" id="pic2" /></span> </div> <div class="chavi-element"> <span class="left" > 3rd Image</span><span class="right"><input type="file" accept ="image/gif, image/jpeg" name="pic3" id="pic3" /></span> </div> <div class="chavi-element" > <span class="left" >4th Image</span><span class="right"><input type="file" accept ="image/gif, image/jpeg" name="pic4" id="pic4" /></span> </div> <div class="chavi-element" > <span class="left" >5th Image</span><span class="right"><input type="file" accept ="image/gif, image/jpeg" name="pic5" id="pic5" /></span> </div> </div> <div class="meta-info"> <div class="package-element-head" > <p>Title:</p> </div> <div class="package-element" > <input type="text" size="30" id="title" name="title" /> </div> <div class="package-element-head-2" > Keywords: </div> <div class="package-element" > <textarea rows="5" cols="28" id="keywords" name="keywords" ></textarea> </div> </div> <div class="meta-info" > <div class="package-element-head" > Description: </div> <div class="package-element" > <textarea rows="5" cols="30" name="description" id="description"></textarea> </div> <div class="package-element-head-2" > URL of the page: </div> <div class="package-element" > <input type="text" size="30" 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"></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"></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"></textarea> </div> <div class="cleaner"></div> </div> <!--<div id="availability">availibility</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" 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" /> </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" 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" size="7" name="inf_below" id="inf_below" /> </div> </div> <div class="package-element-head-2">Pricing Details:</div> <div class="cleaner"></div> <div class="package-element" > <textarea rows="10" cols="70" id="pricing_details" name="pricing_details" ></textarea> </div> <input type="submit" id="submit" value="Create This Entry!" /> <div class="cleaner" ></div> </div> </div> </div> </form> <!-- <form action="{$_SERVER['PHP_SELF']}" method="post"> <label for="title">Title:</label><br /> <input name="title" id="title" type="text" maxlength="150" /> <div class="clear"></div> <label for="bodytext">Body Text:</label><br /> <textarea name="bodytext" id="bodytext"></textarea> <div class="clear"></div> --> </form> <br /> </div> ADMIN_FORM; } public function write($p) { 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 ( 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)) { $sql = "INSERT INTO tourDB (tour_name, tour_type, day, nights, overview, itinerary, inclusions, exclusions, twin_triple_sharing, single_occcupancy, child_with_no_bed, inf_below, keywords, title, description, url) VALUES ('$tour_name', '$tour_type', '$day', '$nights', '$overview', '$itinerary', '$inclusions', '$exclusions', '$twin_triple_sharing', '$single_occcupancy', '$child_with_no_bed', '$inf_below', '$keywords', '$title' , '$description', '$url')"; return mysql_query($sql) or die(mysql_error()); } else { return false; } } public function connect() { mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error()); mysql_select_db($this->table) or die("Could not select database. " . mysql_error()); return $this->buildDB(); } private function buildDB() { $sql = <<<MySQL_QUERY CREATE TABLE IF NOT EXISTS tourDB ( tour_id INTEGER NOT NULL AUTO_INCREMENT, tour_type VARCHAR(11) NOT NULL, tour_name VARCHAR(255) NOT NULL, day INTEGER NOT NULL, nights INTEGER NOT NULL, tour_price VARCHAR(25) NOT NULL, overview TEXT NOT NULL, itinerary TEXT NOT NULL, terms_conditons TEXT NOT NULL, inclusions TEXT NOT NULL, exclusions TEXT NOT NULL, twin_triple_sharing INTEGER NOT NULL, single_occcupancy INTEGER NOT NULL, child_with_no_bed INTEGER NOT NULL, inf_below INTEGER NOT NULL, pricing_details TEXT, keywords VARCHAR(155) NOT NULL, title VARCHAR(25) NOT NULL, description VARCHAR(136) NOT NULL, url VARCHAR(500) NOT NULL, PRIMARY KEY (tour_id) ) ENGINE="MyISLAM" MySQL_QUERY; return mysql_query($sql) or die(mysql_error()); } } ?> Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 3, 2013 Share Posted October 3, 2013 i'm going to assume you mean it is displaying the first entered data twice. what have you done to debug the problem and pin down exactly where your code and data isn't doing what you expect? is the data in the database table correct? is the problem only in the display logic? what's the HTML output in your browser's 'view source'? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 3, 2013 Share Posted October 3, 2013 here's some general points about the code you posted - you need to narrow down the problem and just post the relevant code. your page works, but one part is displaying incorrectly. if your entire page wasn't working as expected, posting the code for the entire page would be useful, but that's not the case and posting a wall of hundreds of lines of non-relevant code will just get your post ignored. the only relevant information for your problem in this thread would be what your actual data is (the inputs), the code retrieving that data and outputting it (the processing), and what's wrong with that output (the actual output.) $obj->table = 'sim'; that's actually your database name and the variable/property name should reflect the actual meaning. $obj->connect(); your tourCMS class should not create its own database connection. you should have one connection in your main code and any class that needs to use it should have it passed into the instance of that class. also, you should not be trying to create your database table each time you make the database connection/each time the page gets requested. attempt to create the database table once, during an installation routine. echo ( $_GET['admin'] == 1 ) ? $obj->display_admin() : $obj->display_public(); that line implies that anyone could set admin=1 in the url and access the admin functions (i.e. post information to your database table.) you cannot rely on a simple value in a url/link to determine access restrictions. your login/authentication code is what needs to determine access restrictions. $r = mysql_query($q); your code is using the mysql_ database library. that is depreciated starting in php5.5 and should not be used for any new code. you should use the mysqli or PDO database library. $tour_id = stripslashes($a['tour_id']); if you find yourself using stripslashes on data being retrieved from a database, it's likely the data wasn't properly escaped when being put into the database. the \ characters should not be in the actual data in the database table. if they are, given your ->write() method code that is escaping the data, it means that magic_quotes_gpc is on. you need to test if it is on and use stripslashes on the data, then escape it yourself before using it in your insert query. $tour_id = stripslashes($a['tour_id']);$tour_type = stripslashes($a['tour_type']); ... you have 17 lines of code that are making a copy of one variable into another variable. given the limited scope of this code (one function/method), simply use extract() to replace all those lines of code with one statement. also, if you did have a need to run a function on all elements of an array, you can just use array_map(). } else { $entry_display = <<<ENTRY_DISPLAYENTRY_DISPLAY; if you set $entry_display = ''; (an empty string) before the start of your while(){} loop, you can eliminate this else{} statement and prevent an error at the first use of $entry_display .= .... Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted October 3, 2013 Share Posted October 3, 2013 you have 17 lines of code that are making a copy of one variable into another variable. given the limited scope of this code (one function/method), simply use extract() to replace all those lines of code with one statement. also, if you did have a need to run a function on all elements of an array, you can just use array_map(). Or instead of duplicating variables, you could just use the array. Instead of <span class="overview-heading">$tour_name</span><br /><br /> ...you could use the value from $a: <span class="overview-heading">{$a['tour_name']}</span><br /><br /> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.