-
Posts
5,449 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
lol (about the php.net site) if there are only two parameters and someone told you they were in the wrong order, can't you guess, infer, or deduce what the correct order should be?
-
d) have you profiled the php code so that you know how much time is taken up on the server to generate the page? it's likely, given the amount of html markup, that the transmission time from the server to the browser is where the bottleneck is at or in the browser rendering that much markup on the page.
-
a) what is your current code and the current issue? b) as stated a number of times, you only need to have rows in the database table that have data values - boat, chest, miss, hit.. c) the only time you should be drawing the entire grid is at the start of a game. you should use ajax to update the display during the game play, edit: because you are only concerned with changes that occur in the data due to a guess.
-
PHP Newbie Upload Link Scripting/Folder Question
mac_gyver replied to graphxsman's topic in PHP Coding Help
your code is still not testing if the upload worked before trying to use the uploaded file information. when an upload fails, generally due to the size of the file, the ['type'] element will be empty and for some of the possible reasons an upload can fail, the ['name'] element will be empty. your lumped together conditional logic testing the ['type'] and $extension will be false and your generic "Invalid file." message will be displayed. your current code is testing some of the possible uploaded errors in the ['error'] element AFTER you have tried to test the ['type'] and $extension. your code will never reach that point and report an upload error because if there is a detected error in the ['error'] element, the ['type'] or $extension won't be valid and your first logic test will go to the "Invalid file." message. the code you have now is based on the w3schools site and it is ass-backwards. YOU MUST CORRECT THE LOGIC IN YOUR CODE BEFORE IT WILL TELL YOU WHY IT IS FAILING. so two things, as previously mentioned - 1) you must test if the upload worked before you use any of the uploaded file information, since the uploaded file information will not exist to test if the upload didn't work. 2) you should output unique and verbose messages for each different thing that can cause your code to fail so that your code is self troubleshooting. to debug what exactly might be happening after you submit your form, you can dump the $_FILES array using the following code, put in before the start of your conditional logic - echo "<pre>"; echo "FILES:"; print_r($_FILES); echo "</pre>"; -
have you researched what services paypal provides? when using them as your payment gateway/processor, the visitor can pay using credit cards or by using a paypal account.
-
that error message is coming from some other query.
-
programming is an exact science. so far in this thread, your table definition, query, and error message don't match up and due to typos on your part no one here knows which name for the column is correct. you should be copy/pasting actual information if you want someone in a help forum to be able to help you.
-
what url are you entering in your browser? it should be something like http://localhost/your_file_name.php beyond that, how exactly did you obtain php and install it to run on your localhost web server? what is your localhost web server type?
-
you cannot just make random changes to code unless you know the change produces the intended result. the php5.4 syntax $balanceQ->fetch_row()[0]; calls the ->fetch_row() method and references the zeroth element of the array that was returned. the replacement code must perform that same operation. you could use either of the following - $row = $balanceQ->fetch_row(); $balance = $row[0]; or list($balance) = $balanceQ->fetch_row();
-
the php mail() function is not a mail server. it does not send emails (though when using smtp there's small chance that some mail servers may accept an unauthenticated email for delivery.) it is an interface function that lets php communicate with your sending mail server that has been configured to accept emails from your web server. do you have a mail server installed that will accept emails from php on your web server and is a correctly configured public mail server that can then send those emails to the receiving mail server at the to: address? if you are trying to use your ISP's mail server or a mail server like gmail, or to send to your mail account on some mail server, you will need to use smtp authentication to do so and php's mail() function doesn't support smtp authentication. you will need to use a mailer class like phpmailer to use smtp authentication to send through your mail account on a mail server or to send to your account on a mail server.
-
@Irate, please read and understand the thread before posting replies. it turns out the OP wants someone to be able to visit a page, but only by first visiting a preceding page.
-
Destroy sessions upon leaving page, but not refreshing
mac_gyver replied to ash992's topic in PHP Coding Help
you should store the cart contents in a database, so that you have a record of what is in a potential order to compare against what you receive back from paypal. just because a visitor reaches the 'review' page, doesn't mean they ever submit the form on that page or complete the payment process once they are on the paypal site. you should persistently 'remember' the cart/order with a status value that indicates it reached the review step, along with the current date/time. you should then use the IPN information you get back from paypal to conform that the order was completed and the correct payment amount was processed. you would change the status value stored with the order to indicate it is an actual order and has been paid for. for orders that are never completed, you would delete them from the database a reasonable amount of time after the date/time they were stored. -
Destroy sessions upon leaving page, but not refreshing
mac_gyver replied to ash992's topic in PHP Coding Help
i think this is probably a case where describing the overall goal/purpose would help. what are you trying to accomplish or prevent by doing this? -
PHP Newbie Upload Link Scripting/Folder Question
mac_gyver replied to graphxsman's topic in PHP Coding Help
it's likely that the upload is failing and the $_FILES['myfile']['name'] element is empty. your code needs to test if the upload worked at all before you can access any of the uploaded file information. the ['name'], ['type'], ['size'], and ['tmp_name'] elements of the $_FILES['myfile'][...] array are only 100% valid when the ['error'] element is set and is a zero value. if you use the advanced search on the forum, for the word 'upload' and by me as an author, you will find a number of posts showing/stating how to detect that an upload form has been submitted and how to detect if the upload worked before using any of the uploaded file information. i also notice you have two type='file' fields in your form with the same name. that won't work. only the values from the last field with the same name will be submitted. when uploading multiple files, it's easiest to use an array name for the form field so that you can simply iterate/loop over the data. i'm pretty sure the forum search i suggested above will return results showing how to do this as well. -
PHP Newbie Upload Link Scripting/Folder Question
mac_gyver replied to graphxsman's topic in PHP Coding Help
echo "The file extension you supplied is: $extension, the allowable types are: " . implode(', ',$allowed_ext); -
PHP Newbie Upload Link Scripting/Folder Question
mac_gyver replied to graphxsman's topic in PHP Coding Help
when validating user supplied information, you need to provide verbose messages why something the user did didn't work and what if anything he can do to fix it. rather than a generic message - "Invalid file type.", you should output what the type value the user supplied is and what the valid type values are. this will make your code 'self troubleshooting'. during development, your code will tell you why it didn't work. -
i back tracked to this script's site and the author of this script is using php5.4 syntax. removing the [0] that was on the ->fetch_xxxxx()[0] statements may have eliminated some error messages, but won't cause the script to work unless you add code that fetches/references the correct element of the arrays. you will need to go through all the code making modifications (or upgrade to at least php5.4.) the author is also using the short form of array syntax. this will need to be changed to the long/full array syntax (didn't php learn that putting in short-cuts wasn't a good idea.)
-
this code seems familiar. someone else just posted problems with the same. a) you need to have php's error_reporting set to E_ALL and display_errors set to ON when debugging php code to get php to help you by reporting and displaying the errors it detects. b) the ->fetch_row() method, unless you have written your own database class, returns an array. comparing an array with an integer isn't going to produce the result you expect. you need to reference the zeroth element of the fetched array to access the value the query selected. assigning the fetched row to a php variable, then referencing the zeroth element of that array in the if() comparison would be the best method as it will work regardless of php version (the latest php5.4 has a short-cut method, but will break on earlier php versions.) c) if the code setting $balance, about 10 lines above the code you posted, is also just using a ->fetch_xxxxx() method, without referencing the correct element in the fetched array to access the balance value, the comparisons using $balance are also not working.
-
different users interfering with each other
mac_gyver replied to rghollenbeck's topic in PHP Coding Help
actually, you could store the values in a file, which would require that you write a bunch of code, with file locking,... - you would need to identify the visitor, using a unique token instead of an actual username, but this is what the session id is, so yes, it's easier to just use session variables. -
different users interfering with each other
mac_gyver replied to rghollenbeck's topic in PHP Coding Help
each request to a server for a web page is completely separate from all other requests for that same (or a different) page and session data is separate for each different browser. the only way of getting a mixing of data is if there is more than one instance or tab of a single browser running on the same computer. all instances/tabs of the same browser on any one computer would use the same session id and access the same session data. it would take knowing what your code is in order to determine what it is doing that could account for the symptom. best guess, your code is storing something on the server in a file or database and is not retrieving the correct values based on who the the visitor is. edit: i did just think of a way of two separate computers interfering, but this would require that the session id be passed in the url and you somehow sent the url containing a session id from one computer to the other. -
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.
-
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.
-
unfortunately, the OP in this thread has another thread where problems abound with putting data into the wrong columns and not using the same processing to check the password that was used when originally hashing it.
-
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.
-
you need to stop creating new threads for the same problem. did you look at what your registration code is doing or at what data it is inserting when you were testing this? your fields and data are mixed up. you are putting the wrong values into the name , surname , password, and email fields, so of course when you try to use the password value to authenticate the user, it's never to going work because it's actually the $name.