Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,354
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. you need to determine which php.ini file is being loaded. create a php script with a phpinfo statement in it and browse to the php script. the Loaded Configuration File line is the php.ini that is being loaded. i'm pretty sure the command line version - development server of php will load the php.ini in the same folder where the php.exe file is at. if that that doesn't work, it should load the php.ini file it finds along the windows path statement, which should have the path to the php.exe file anyway.
  2. your method doesn't add any extra security. the person most likely to be attempting to log in as someone else will be doing it from the same wired or wireless network as the actual person and would have the same ip address as the actual person. your method of using the sequential database id as the value in the cookie will allow someone to quickly cycle through a range of valid ids. depending on what your server side logic is checking, at best this will allow them to log out all your actual visitors and at worst it will let them eventually find any ids that correspond to the ip address and log in. the value you store in the cookie to identify someone must be a hard to guess value, like a session id is, which would not allow someone to simply cycle through a range of integers to come up with values to try.
  3. your function code is fetching a row from the result set, but not doing anything with it, then trying to fetch and return the next row, but since there's likely only one matching row from the query in question, you are actually returning a false value to the calling code.
  4. the only ways to supply values to a page are - imbedded in the url as hostname, path, or filename information or as $_GET, $_POST, $_FILES, $_COOKIE, or $_SESSION data. since you are generating a list of urls, you would need to pass some unique identifier as part of each url.
  5. as a continuation of the above reply - i just duplicated your var_dump of the $_POST output. after hitting the submit button on the first row - array(11) { ["ddsub_sector_id"]=> string(0) "" ["tbtickersearch"]=> string(0) "" ["ddcurrency_id"]=> string(13) "None Selected" ["ddcountry_id"]=> string(13) "None Selected" ["tbenterticker"]=> string(0) "" ["tbenterlevel"]=> string(0) "" ["ddquote_convention_id"]=> string(13) "None Selected" ["ddbenchmark_id"]=> string(13) "None Selected" ["tbentermaturity"]=> string(0) "" ["bonddescription"]=> array(1) { [0]=> string(0) "" } ["issueid"]=> array(1) { [0]=> string(0) "" } } after hitting the submit button on the 2nd row - array(2) { ["bonddescription"]=> array(1) { [0]=> string(0) "" } ["issueid"]=> array(1) { [0]=> string(0) "" } } this is due to the mess of nested form tags. TAKE A LOOK AT THE URL IN YOUR BROWSER'S ADDRESS BAR when you submit the first and other row's forms. you will see that the first row submits to reduced_view_issues.php. the remainder of the rows submit to select_issue3.php you need to make sure that the html you produce is valid and it wouldn't hurt to learn some css so that you can clean up and reduce all the styling in the markup.
  6. there's only one $issueid variable in the posted code, in some commented out code. its not an array. it cannot be what your var_dump output is from. you also never stated in which code the var_dump output is being done at. the very first piece of posted code isn't identified either. i'm guessing its reduced_view_issues.php. if that's the case, your select_issue3.php file is producing more invalid html, with two complete html documents in it. the issue isn't all the code, it's that you haven't provided accurate information about the code and the problem that pins down where to look in it. i'm guessing the above statement is referring to the nested form tags? no one said they wouldn't do anything, they will - in the very first piece of posted code, you have an initial form tag with action=reduced_view_issues.php. all the other opening form tags inside of that form tag, at least up to the first closing </form> tag (which just might be why your first row doesn't work) will be ignored and any (at least the first one) of the submit buttons should submit to reduced_view_issues.php instead of select_issue3.php.
  7. nested forms are invalid. you need to fix that before you can fix anything else your code might be doing. to help yourself and anyone else you might be asking to help you, you should also elimiate all the commneted out code and since you are creating a database connection in the functions.php file, elimiate the variables and connections you also creating in the individual files.
  8. and in which file? i've looked at some of the code more and you have nested form tags that are invalid. the first opening form tag is what will be submitted to, so I don't even think your form is submitting to the file you think it is. you need to clean up all your code and validate the resulting html. there's problems with form tags and table tr/td tags. i also see one = sign in an if() test that is assiging a value instead of comparing a value.
  9. the symptom is that of a variable being reused. since you have posted a book-load of double-spaced code, it would help if you identified which variable name you are var_dump'ing and in which piece of code it is to pin down where to even start looking. without knowing which variable you are talking about, the only apparent problem is you have an extra </form> tag at the end of the select_issue.php code file that is messing with all the forms being output in that file.
  10. code snippets that implement the suggestions - <?php session_start(); // simple form process controller - $action = isset($_POST['action']) ? $_POST['action'] : ''; switch($action){ case 'add': // add/increment item to cart (quantity one) // inputs: 'add to cart' flag, item id // processing: add new or increment existing item id in the cart $id = (int)$_POST['id']; if($id > 0){ // valid submitted id if(!isset($_SESSION['item'][$id])){ // not already in cart $_SESSION['item'][$id] = 0; // create entry } $_SESSION['item'][$id]++; // increment quantity } break; case 'delete': // delete item from cart // inputs: 'delete from cart' flag, item id // processing: remove item id entry from the cart $id = (int)$_POST['id']; if($id > 0){ // valid submitted id unset($_SESSION['item'][$id]); } break; } // display the cart if(empty($_SESSION['item'])){ echo "Your cart is empty!<br>"; } else { echo "Your cart has ".array_sum($_SESSION['item'])." item(s) in it.<br>"; // get the item ids from the cart $ids = implode(',',array_keys($_SESSION['item'])); echo "ids are: $ids<br>"; // code to get and display the product infomration for the list of ids is left as a programming exercise } // display what's going on echo '<pre>','cart:',print_r($_SESSION,true),'post:',print_r($_POST,true),'</pre>'; ?> Add some items -<br> id: 123<form method='post' action=''> <input type='hidden' name='action' value='add'> <input type='hidden' name='id' value='123'> <input type='submit' value='Add to cart'> </form> id: 456<form method='post' action=''> <input type='hidden' name='action' value='add'> <input type='hidden' name='id' value='456'> <input type='submit' value='Add to cart'> </form> Delete some items -<br> id: 123<form method='post' action=''> <input type='hidden' name='action' value='delete'> <input type='hidden' name='id' value='123'> <input type='submit' value='Remove from cart'> </form> id: 456<form method='post' action=''> <input type='hidden' name='action' value='delete'> <input type='hidden' name='id' value='456'> <input type='submit' value='Remove from cart'> </form>
  11. this is just my opinion, but the defintion of your cart is resulting in extra code and data, and even results in security problems because you are passing unneeded data through the form that must be validated once it reaches the server. your cart should use the item id from the product database as the first level key and the only real data you need to store in the cart for each item is the quantity. the only thing the add to cart form needs to submit is the item id and a quantity (assuming you want to allow more than one of anything to be bought.) to delete the item from the cart, just use the item id to unset it like you are doing now. there's no need to move or renumber the indexes. what's with the $_SESSION['count_cart']? you can just use the php array count() function to get a count of the items in the cart at any time or if you are storing a quantity of each item, use array_sum(). no need for any extra code to set the count_cart variable or to increment and decerment it. to display the cart, just get all the item ids out of the cart and use them to fetch the display information from the database.
  12. you must be escaping the actual query statement insted of just the data going into the query statement. the syntax of the query, quotes and such that you add around the data to produce the query, don't get escaped.
  13. this is a chicken and egg age problem. the age value is calculated in the select term for the rows that have been selected. the where term determines which rows to select. the easiest, not fastest, way would be to use a HAVING age BETWEEN 30 AND 40 term. the fastest way would be to put the calculation into the WHERE term.
  14. the mysqi extension that is listed in the phpMyAdmin output is just the extension that phpMyAdmin is using to connect to the database server. in order to profile your application to find out where the problem lies, it would be ncessary to know everything your appliction is doing. nothing can be told from a few snippetts of code.
  15. your load time is slow because doing this all client side requires all the data to be sent to the client. to do what you ask would require that you use ajax to submit the selected filter to the server and the server just returns the selected product data. look at some ajax examples for your appliction.
  16. or you can pass the selected search filters in the url so that someone can create a bookmark or shortcut to the page and return to the same point later or share the search result with someone else via a link.
  17. apache and iis are both web servers. you can use either one. unless you are doing something that requires iis, there's no good reason to mess around trying to install php under iis. you will probably get more uptodate installation help if using apache. you can also use one of the allinone win/apache/php packages if your goal is to just get php running as easy as possible on a computer. you don't need to install the mysql server if you don't want or need it. afaik, for iis, you should install php as a fastcgi app. there are current installation instructions in the php.net manual. you would use php-cgi.exe. php.exe is the command line intrepeter.
×
×
  • 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.