Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. Mysql Reserved Words - OUT is on that list. Change your alias name, or surround it with backticks.
  2. Since you're talking about Javascript, I've moved your topic to the Javascript Help forum. The PHP help forum was the wrong place to post. Two things: 1) It's $.post(), not $.POST. Case sensitive. 2) $.post is not a native javascript function, it is part of the jQuery library so make sure you have included that library into your page if you want to use it.
  3. Nothing worth worrying about.
  4. If all the dates are in that same format, you can use the STR_TO_DATE function to convert them to a mysql date then use a range check. That probably won't help with your speed issue though as by doing the conversion at query time you prevent mysql from optimizing the query using indexes, as far as I am aware. SELECT * FROM table WHERE user_name='whatever' and STR_TO_DATE(Session_Date, '%m/%d/%Y') BETWEEN '2012-1-1' AND '2012-1-5'
  5. If you're looking to generate the base URL, eg http://example.com/ or https://example.com, something like this should be fine: $baseurl = sprintf("%s://%s/", !empty($_SERVER['HTTPS'])?'https':'http', $_SERVER['HTTP_HOST']); That will use the same protocol and hostname/port that the page was requested with to generate the base url.
  6. Your logic is not as one would expect, it is incorrect. Using your above template as an example, the correct logic flow would be something like: function randomSentenceGenerator () { php script } if(isset($_POST['submit']) { if(question != answer) { tell user to enter a correct answer } Include the HTML } else { $question_and_answer_array = randomSentenceGenerator(); include the HTML } You generate a question only if the form was not submitted (or, optionally, if they answer incorrectly). When the form has been submitted you compare the post'ed answer with the answer in the session.
  7. You have to use conditionals to determine what to do, you can't just concatenate things together and expect PHP to figure it out. if ($gWithdrawDeposit == '+') $mathShit = $listAddupAmount + $gAmount else if ($gWithdrawDeposit == '-') $mathShit = $listAddupAmount - $gAmount
  8. Generally the easiest way to handle form validation/errors is to have the same script do both present the form and process the form. You can use the include function to separate these steps into separate physical files, but have it be one file for the purposes of the request. Then you would structure the code like this: <?php if ($form_is_submitted){ //Something to check if it was submitted $Defaults=$Errors=array(); //Validate form fields if (count($Errors)==0){ //No errors so process the form doSomething(); } } ?> ... <input type="text" name="fname" value="<?php echo htmlentities(isset($Defaults['fname'])?$Defaults['fname']:''); ?>"> <span class="errorMessage"><?php echo isset($Errors['fname'])?$Errors['fname']:''; ?></span> If for some reason you don't want to structure things into one file like that though, storing the errors in $_SESSION and redirecting back would work fine.
  9. You would have to offer the files up in a format where they don't get parsed by your server, such as a .txt file. The entire idea is a bit pointless though. Since the decryption script has to be readable for it to be executed, someone could always just download it and run it on their own rather than contact your site all the time. They could also have it just go through and decrypt everything then save a copy of the decrypted source.
  10. The variable containing the product ID is $row['product_id'], so just use that as your if condition. <?php if ($row['product_id'] == 10): ?> something <?php else: ?> something else <?php endif; ?>
  11. No, you can't do it either way. Using CRYPT_BLOWFISH as the salt parameter results in an invalid salt value since it doesn't match any of the specified algorithm salts. What happens in the case of an invalid salt is crypt() uses some default settings which is dependent on the platform PHP is running on (ie, not portable and will likely break if you move from one system to another). If you want to use a specific algorithm such as blowfish, you have to give it the proper salt value in the correct format for it to work.
  12. CRYPT_BLOWFISH is a constant that will indicate if the blowfish algorithm is available for use or not. It is not something you pass into the crypt() function. You have to generate a specific salt string for the second parameter, and the format of that string indicates which algorithm you want to use. For blowfish that salt string needs to be in the format of: EG: $2y$19$abcdefghij1234567890ab
  13. kicken

    Curl

    By default no, but you can configure it to. See the CURLOPT_COOKIEFILE and CURLOPT_COOKIEJAR options for details.
  14. It's not outputting any redundancies, it might just look that way because of what you're asking it to do. Your initial array looks like this: array( 0 => 1 1 => 4 2 => 17 3 => -9 ) Notice your index values are 0-3. Now when you run the function array_keys() you're asking PHP to tell you what the index values of the given array are. PHP returns these indexes in a new simple list array. That new array has indexes 0-n where n is the number of items contained in the source array. The values in the new array are the indexes from the source array. Since the indexes from your source array are just a simple 0-3, you end up with your seemingly redundant array output of array( 0 => 0 1 => 1 2 => 2 3 => 3 ) If you had a source array with varying indexes, you might better see what is going on and why you get what you are getting. Eg, given a source array of: array( 'a' => 1 'b' => 4 0 => 17 1 => -9 ) running array_keys($source) would result in a returned array that looks like: array( 0 => 'a' 1 => 'b' 2 => 0 3 => 1 ) Itegrated Development Evironment An IDE is all about making it easier for a person to write code and fix bugs in their software. It does things like provide autocompletion suggestions as you write code, allow you to quickly reference any relevant documentation for the function you're trying to use, manage and organize your applications source files and easily search/replace within them, provide integrated debugging tools to let you run through your code and view(maybe even change) the values of variables as it runs, and much more usually. They don't really have anything to do with making it easier to tell a computer what to do (except maybe in a round-about way by helping the human). Programming languages themselves (ie, C, PHP, Java, etc) are what allow humans to tell a computer what to do easier. The IDE's just help you write the code for a given language by consolidating all the tools you might use in one easy to use package.
  15. Given that information, then most likely your $DOCUMENT_ROOT is defined as: /Applications/XAMPP/xamppfiles/htdocs/ This is the folder the web server treats as the root when resolving URL paths, eg http://localhost/blah would resolve to /Applications/XAMPP/xamppfiles/htdocs/blah Now, the parent of that would then be /Applications/XAMPP/xamppfiles which is where the .. takes you to. Then you add on the rest of the path information to end up with a final path of: /Applications/XAMPP/xamppfiles/orders/orders.txt That is where it is attempting to find the file at. If the directory /Applications/XAMPP/xamppfiles/orders does not exist, you will need to create it before running the script.
  16. clearRect()
  17. You'd be getting up to a few million rows before you notice any real slow down. If you get to that point then you can look into partitioning to spread the data out for quicker access.
  18. You'd need to store a map of items the user has viewed and compare that to the list of items. Then grab a count of the unviewed items. You can do this with a map table and a left-join, eg: create table user_items_viewed ( userId INT NOT NULL, itemId INT NOT NULL); Whenever the user views an item, add that item's ID and the user's ID into the above table as a new row. To do a count of the unread items, you select from the items table, left-join the above table, and then count the rows where there is no entry in the above table (ie the columns are null) SELECT COUNT(*) as unviewed FROM items i LEFT JOIN user_items_viewed v ON i.itemId=v.itemId AND v.userId=123 WHERE v.userId IS NULL
  19. You can always just store your results into an array and then use them later, eg: $queryResults = array(); while ($data=mysql_fetch_assoc($results)){ $queryResults[] = $data; } //Now $queryResults holds all the rows/columns returned. If you just want the one column in an array by itself, then do that. $columnValues = array(); while ($data=mysql_fetch_assoc($results)){ $columnValues[] = $data['column']; } //Now $columnValues holds all the values from the specified column.
  20. When you load an image directly, some browsers may end up making the request twice for various reasons. For instance firefox will request it twice under certain conditions to use the image as an icon for the window on the task bar. edit: https://bugzilla.mozilla.org/show_bug.cgi?id=583351 - The firefox bug
  21. You need to enclose your '-' symbols in quotes. What you are doing right now is converting $StudentID2, $StudentID3, #ICNumber2, and $ICNumber4 to negative numbers, then concatenating them together. Eg, you're going from the string value "00018" to the numeric value 18, converting that to a negative (-18) then back to a string "-18" and concatenating them. Corrected it would look like this, with the - in quotes. $FStudentID=$StudentID1.'-'.$StudentID2.'-'.$StudentID3;
  22. Do not set display:none in your CSS at all. Apply that style later with JS after the dom has loaded. One generic way to accomplish this is to define a css class called .has-js or similar which gets applied to the body on dom ready, then use that to apply your hidden styles. for example: <style type="text/css"> .has-js .hide-if-js { display: none; } </style> <script type="text/javascript"> //Use jquery to run a function on dom ready and add the has-js class. $(function(){ $('body').addClass('has-js'); }); </script> <div> <h1>Some title here</h1> <p class="hide-if-js">blah blah blah</p> </div> With the above, the P tag will only get the display:none if one of it's parent's has the .has-js class applied to it. The .has-js class will then be applied to the body tag, but because it is applied via JS, it is only applied if JS is enabled.
  23. Well, for one the code you've posted is not even valid PHP code. You're missing several closing brackets ( } ). Rather than echo, use var_dump for testing so you can get a better idea of what information is contained within a variable. For instance if the variable contained false or null then echo would show you nothing, var_dump would show you which. Copy and paste your actual code here if you want help.
  24. If you just want the image there for visual effect and not have it clickable, then you can just apply a background-image to the input element that is positioned on the right hand side. If you want it clickable then you'd use two input's side-by-side in a div element. Apply a background to the div that looks like a form field, then style the inputs to not have any borders on them.
×
×
  • 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.