Jump to content

cyberRobot

Moderators
  • Posts

    3,145
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by cyberRobot

  1. And when posting the code, please surround it with tags. It will make your post and the code easier to follow.
  2. When I dump the code into Dreamweaver, it doesn't like the following lines: include("connection.php"): $log= echo $_COOKIE['hrcookid']; $pass= echo $_COOKIE['hrcookpass']; You're using a colon in the first line instead of a semi-colon. The other lines have an "echo" after the assignment operator.
  3. Perhaps the following will help: http://www.php.net/manual/en/control-structures.for.php
  4. You could look into the following options: http://www.php.net/manual/en/function.gmmktime.php http://www.php.net/manual/en/datetime.settimezone.php
  5. When including variables within a string, you'll need to use double quotes. For example, this $dir = 'uploads/$username/'; Should be changed to this. $dir = "uploads/$username/";
  6. Just to clarify, the flag I use indicates whether the user has access or not. It's not whether they are logged in or not. That's what the session is for. Basically I use the "active" flag to remove someone's access to the content for an extended period of time. For example, I may have a group of people who manages an aspect of a website. If someone is no longer part of that group for whatever reason, I'll switch the "active" flag to false. That way they can no longer make changes; even if they are currently logged in. As soon as they visit another page, the system logs them out (removes the SESSION) and displays an error. As for your question about wrapping the SESSION variables, it depends. If you're only using a SESSION variable which contains the user's ID and that ID only contains numbers, I would just make sure the ID is valid before running the query. Currently, I prefer to validate numbers with ctype_digit(): http://www.php.net/ctype_digit
  7. Congrats!
  8. The following quote is from the manual for addslashes().
  9. I guess what I meant be re-validate, is to check the flag which indicates whether they have access or not. I'll basically create a column to indicate if a visitor is active. Every time they go to a new page, I'll check that flag before getting the other information like their name. If the flag is set to false, an error message is displayed. Otherwise, the page content displays as normal.
  10. My preference is to store just the user's ID. Whenever the visitor goes to a different page, I'll query the database to re-validate the user and get the rest of the information. That way if the visitor's permissions are ever revoked, they can be kicked out during an active session if necessary.
  11. No problem, glad to help!
  12. The forward slash ("/") is used for XHTML markup. Tags which don't have a closing tag (like <input>, <br>, etc.) need to be closed with the self-closing syntax (<input />, <br />, etc.).
  13. You could read the data into an array and break it apart with array_chunk(). Here's a quick example of how I've used array_chunk(): http://www.cyberscorpion.com/2013-08/build-html-tables-dynamically-with-php-part-2-simplify-with-array_chunk/
  14. Have you looked into the Google Distance Matrix API? https://developers.google.com/maps/documentation/distancematrix/
  15. Welcome! Assuming that you've already tried solving the problem yourself (searching Google, searching this forum, checking the manual, etc.) here are a few pointers: Find a section which most applies to your question, such as the PHP Coding Help Start a new topic When posting code, please surround it with tags. It will make your code and post easier to follow If you are getting any errors, let us know what those errors are If the code is behaving unexpectedly, let us know what the code should be doing Also, if you haven't done so already, be sure to check out the rules for this forum: http://www.phpfreaks.com/page/rules-and-terms-of-service Good luck
  16. It may help if you post the code where the GET variable is being used within the class. To make the code (and your post) easier to follow, please surround the code with tags.
  17. If you are using an ID which is specifically tied to the row containing the episode information, you just need to get the ID using $_GET and run a query like the following: $query = "SELECT * FROM `add_movie` WHERE id={$_GET['id']} LIMIT 1";
  18. Does your movie table have a primary key? If so, it's better to use an ID which directly relates to the movie information that the website should pull up. If your primary key is called "movie_id", for example, you could do something like: echo '<a href="movies_watch.php?movie='.$query_row['movie_id'].'">'; Also, have you tried validating the output? http://validator.w3.org/ Note that the <table> tag isn't supposed to go inside an <a> tag.
  19. This is just a guess, but have you looked closely at the following lines: /* Sets Path for SVG file */ define('DIR_PATH_SVG', '../saved-customer-files/'); $fp = fopen(DIR_PATH_SVG.$file, 'w+'); $temp=fwrite($fp, $contents); /* Sets Path for PNG file */ define('DIR_PATH_PNG', '../../customer-design-proofs/'); $fp = fopen(DIR_PATH_PNG.$file, 'w+'); $temp=fwrite($fp, $contents); It looks like you're writing the contents to a file...and then you write the contents again with file_put_contents() later.
  20. Sorry, I'm not entirely sure I follow. Do you need help with creating the links? If so, what does your code which display the list of episodes look like so far? It might also be helpful to know what the database which contains the episode information looks like. Does it contain the necessary "cat" and "number" information for the links? Or do you already have the links created and you're just looking for help with using the "cat" and "number" variables? If so, are you familiar with $_GET? http://www.php.net/manual/en/reserved.variables.get.php Note that if you post code, please surround it with tags. It will make the code and your post easier to follow.
  21. If you're interested in seeing what's new in PHP5, check out the following link: http://www.php.net/manual/en/migration5.php
  22. OOP was available in previous versions of PHP. It's not the same as it is in PHP5, but OOP was available in PHP4. So to answer your question, you don't need to use OOP to program with PHP5. Use whatever techniques you feel comfortable with to get the job done.
  23. Basically, the code uses the default value ("price") if the sort variable isn't set or is empty. Otherwise, it uses the sort variable as passed. Note that the code could be modified to prevent visitors from using something other than a designated sort value. If these are the only valid options: price, price|d, name, name|d ...the code could be modified as follows (untested): <?php //IF SORT VALUE ISN'T VALID, USE DEFAULT $validSortOptions = array('price', 'price|d', 'name', 'name|d'); if (!isset($_REQUEST['sort']) || !in_array($_REQUEST['sort'], $validSortOptions)) { $_REQUEST['sort'] = 'price'; } //SET SORT ORDER if (strpos($_REQUEST['sort'], '|d') !== false) { $osC_Products->setSortBy(substr($_REQUEST['sort'], 0, -2), '-'); } else { $osC_Products->setSortBy($_REQUEST['sort']); } ?> Of course, your $osC_Products->setSortBy() method may already be performing this type of sanitation.
  24. Ah, I just noticed that last part. You can use a loop to display all 10 images. You could try something like the following: <?php for($i=1; $i<=10; $i++) { if($i == 1) { $simg = of_get_option('lfam_uploader_cimage'); } else { $simg = of_get_option('lfam_uploader_cimage' . $i); } if($simg && $simg['image']) { echo '<li><img src=" '.$simg['image'].' " /></li>'; } else { echo "no entry"; } } ?> Note that the code is untested...and I'm sure it could be cleaned up a bit.
  25. I'm not sure if this is the issue, but there shouldn't be a semicolon after the last curly bracket. Also note that the code is missing a closing curly bracket for the first if. Try something like the following: <?php $simg = of_get_option('lfam_uploader_cimage'); if ( $simg ) { if ( $simg['image'] ) { echo '<li><img src=" '.$simg['image'].' " /></li>'; } else { echo "no entry"; } } ?> If that doesn't fix the issue, please let us know what errors you see. You could also try displaying the $simg variable to see if it contains what you expect. For example, you could add the following after the variable is set: $simg = of_get_option('lfam_uploader_cimage'); print '<pre>' . print_r($simg, true) . '</pre>';
×
×
  • 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.