Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. It's on a paid webhosting Then you will not have access to the server. You will have to set the timezone in the code. phpMyadmin is a database admin utility, nothing to do with the server. <?php date_default_timezone_set('Europe/London'); // should print current date / time print date('d-m-Y H:i:s'); ?> http://php.net/manual/en/function.date-default-timezone-set.php
  2. <?php // logout.php session_start(); unset($_SESSION['loggedIn']); header('Location:/index.php'); exit(); ?>
  3. <?php // pages that require login session_start(); if(!$_SESSION['loggedIn']) { header('Location:/login.php'); exit(); } ?>
  4. Is it a linux box? Change the server timezone: http://www.wikihow.com/Change-the-Timezone-in-Linux
  5. The source file is on the webserver. In a web browser scenario a user may upload a file to the webserver via a submission form. Once the file has been uploaded a script may be called (best as a forked process) that takes the uploaded file and ftp's it to another server (could be for backup).
  6. Not needed as a shared object. Just include the PEAR library include('Services/JSON.php');
  7. I think pear install is yum install php-devel
  8. <?php // array of images $images[1] = "promospace2.gif"; $images[2] = "anotherimage.gif"; if(is_numeric($_GET['image']) && array_key_exists($_GET['image'],$images)) { $image = $images[$_GET['image']]; } else { // image does not exist $image = "middle_highlights.gif"; } // display image print "<img src=\"pic/".$image."\" />"; ?>
  9. <?php session_start(); $users['FantasticHam'] = array('password' => 'iop123', 'redirect' => '/fantasticham/upload.php'); $users['JohnDoe'] = array('password' => 'abc123', 'redirect' => '/john/index.php'); if(array_key_exists($_POST['username'],$users)) { if($_POST['password'] == $users[$_POST['username']]['password']) { $_SESSION['loggedIn'] = true; // redirect header('Location:'.$users[$_POST['username']]['redirect']); exit(); } else { // invalid password } } else { // invalid username } ?> <?php // pages that require login if(!$_SESSION['loggedIn']) { header('Location:/login.php'); exit(); } ?>
  10. You need a C compiler as the error states. yum install gcc
  11. This will update all records greater than 10 credits in one go. You do not require any loop (this is your current error, there is no loop. Only one record returned)! UPDATE users_details SET credits = credits-10 WHERE credits > 10
  12. You could store the values in a config database table and then load them in via a config.inc.php. Or you could write them to the file config.inc.php I usually set config values as constansts i.e define(UPLOAD_IMAGE_SIZE_W, 300); define(UPLOAD_IMAGE_SIZE_H, 100); so if I save to a database I store the key and the value. Then when it comes to creating the config file: <?php // config.inc.php $result = mysql_query("SELECT configkey, configval FROM config"); while($row = mysql_fetch_object($result)) { define($row->configkey, $row->configval); } ?>
  13. There is no free version I am aware of. Single user licence is only $30
  14. Download the tool RegexBuddy. It will make life a lot easier. http://www.regexbuddy.com/
  15. Here is a basic tutorial to get you started http://www.spoono.com/php/tutorials/tutorial.php?id=12 However do not use this in a live website. This tutorial does not explain how to sanitize (make safe) any user inputted data prior to using in a database query. Here are some pages on this topic: http://www.phpro.org/tutorials/Filtering-Data-with-PHP.html http://uk2.php.net/strip_tags http://uk2.php.net/mysql_real_escape_string
  16. Also, team development on long-living projects with constantly changing members can lead to issues with coding standards. CodeSniffer is a tool that can help maintain a coding standard. Worth a look. http://pear.php.net/package/PHP_CodeSniffer
  17. This is not an issue. Having indexes on latitude, longitude will be fast. Indexes should also exist for zipcode as there is a join on the field. The returned result set should not be large as you are limiting to a given distance. You should not use code to manipulate data that can be done from an initial query and return the correct data. More code, more parse time and more issues when it comes to updating the program. This is good practice for any language. Geo data is best stored as a float. I have sites running maps using these queries from millions of records without issue. Read up on geocoding with mysql. It is very efficient.
  18. Absolutely not. It could be broken in seconds. There are plenty of captchas that are perfectly readable.
  19. http://uk.php.net/opendir
  20. Of course. There will always be a way, however making things a little bit more difficult will deter some. People who use windows apps for web scraping etc should be put off.
  21. Look at my prev post on this page. It has an example
  22. absolutely
  23. Where you connect to the db run the following query prior to any other mysql_query("SET NAMES UTF8")
×
×
  • 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.