Jump to content

kee2ka4

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Posts posted by kee2ka4

  1. Hi, thanks for your reply.. At the moment I am using local host so could you advise me on to do this. Later once the site is done, I can ask the hosting company if I can make the alteration.

     

    I have found the following instruction from the MySql site

    The minimum and maximum lengths of words to be indexed are defined by the ft_min_word_len and ft_max_word_len system variables. (See Section 5.1.3, “System Variables”.) The default minimum value is four characters; the default maximum is version dependent. If you change either value, you must rebuild your FULLTEXT indexes. For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file:

     

    [mysqld]

    ft_min_word_len=3

     

    But I wanted to know were can I locate the option file from?

  2. Hi, I have changed one of my table engine to ISAM from InnoDB so that I can perform full-text searching but the only issue is that any word that is too short is ignored. The default minimum length of words that are found by full-text searches is four characters. This will create a serious limitation of my application, is there any way solution to this problem.

     

    Thanks,

    Zub..

  3. Hi everyone,

     

    I use the following redirect_to($address) function that I use to redirect a user to a page based on the parameter passed. Here is the code:

     

    define('WEBSITE', 'http://domain.com/');
    
    function redirect_to($address)
    {
       header('location:'.WEBSITE.$address);
     exit;
    }

     

    I have a another domain name called http://domain.co.uk/ and hence if a user has come to the site using domain.co.uk then I do not want it to change to domain.com. But whenever the redirect_to function runs it loads http://domain.com since I have definted that in the 'WEBSITE' variable.

     

    Is there any function in php that can get the main domain name that the user has typed in the URL. I only need the main domain, no subfolders, so i.e. http://domain.co.uk or http://domain.com, whatever the user has typed in the URL when they visited the site.

     

    Thanks

    Ket

  4. I am current using the following code to remove the www from the domain name and it works:

     

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^domain.com$

    RewriteRule (.*) http://www.domain.com$1 [R=301]

     

    But I have the same domain name with many country prefix, for example, www.domain.co.uk, www.domain.co.in, www.domain.co.fr etc etc. My question is rather then writing a rewrite rule for all the prefix names, is there a quicker way of removing the "www." from all of the domain names.

     

    Thanks,

    Ket

  5. I have two arrays and I want to add the value of one array into another array. Here is the layout of both the arrays. The first array is called $res['id'], and has the value of 1. The second array is an array within an array and is called $routes, as shown below:

     

    $routes = array(

    array('url' => '/^(posts)?\/?(page\/)?(?P<page>\d?)$/', 'controller' => 'posts', 'view' => 'index'));

     

    I wanted to add $res['id'] (including the keyname) to the end of the $routes array and after adding the frist array, the second array will look like:

     

    $routes = array(

    array('url' => '/^(posts)?\/?(page\/)?(?P<page>\d?)$/', 'controller' => 'posts', 'view' => 'index', 'id' => '1'));

     

    How can I do this in php.

     

    Thanks,

    Ket

  6. Hi everyone,

     

    I want to collect two elements of the URL in a array that is, 1. the domain prefix after the domain name and 2. the name of the first subfolder. So for example if I have the domain name: www.sitename.co.uk/student, I want the collect the co.uk and student in a array. And for example if I have the domain name: www.sitename.com/teacher, in this case I want to collect com and teacher in a array.

     

    How can I implement this.

     

    Thanks,

    Ket

  7. Hi everyone!

     

    I have got two domains with same name but one is .com and the other is .co.uk, lets say www.sitename.com and www.sitename.co.uk for example. When I type in the url www.sitename.com, I want the site to display results that is located in USA and when I type in www.sitename.co.uk, I want the page to display results only in UK.

     

    I am using php and I know displaying the appropriate result is a programming question but I wanted to know what Mod rewrite rule can I use to make it work.

     

    So what I want is

    www.sitename.co.uk/index.php (this displays results in uk)

    www.sitename.com/index.php (this displays results in usa)

     

    How can I achieve this.

    Thanks,

    Zub

  8. Hi, thanks for the reply. I did consider that option at frist but I also need to futher query the database by cities, so if the url is london.site.co.uk it displays results located in london. Sure I can include another case:

     

    case 'london':

            ..

            break;

     

    But I think that will generate a very long switch case statement. I will start off with the switch case method but is there any better way of doing this.

     

    Thanks,

    Zub

  9. Hello everyone,

     

    I need help on implementing the mod rewrite so the database can be queried by the URL name.

     

    So for example if the user types in www.site.co.uk it querys the database and only displays results located in UK and for example if the user types www.site.com it displays results located in USA. Can someone please help me on how I can modify the mod rewrite to acheive that.

     

    Thanks,

    Zub

  10. Hello everyone,

     

    I am a newbie in php and have made a couple of basic applications. Hence I needed some advise on my next project.

     

    I am working on a classified ad site and needed some thought process on the different countries and cities concept.

     

    Basically, I want to make the site load by country prefix. So for example if I type the url www.sitename.co.uk then it loads the site displaying only adverts listed in uk, and further most if someone changes the city to london, then the url location changes to london.sitename.co.uk and only lists adverts in London.

     

    Similarly if the site name is www.sitename.com then it displays adverts listed in USA and the same concept as above for cities so newyork.sitename.com will display adverts in New York city.

     

    Can someone share ideas on the best way to implement this feature.

     

    Thanks,

    Ket

  11. Hi everyone,

     

    I have a field called created_at of type datetime in mysql, and I am passing in a variable $time that holds the time in format 2008-07-09 18:14:54 but for some strange reason when I insert the $time value into create_at field it saves it as 0000-00-00 00:00:00

     

    Here is my php code:

    date_default_timezone_set('Asia/Calcutta');
    function uk_time()
    {
    $time = time();
    
    return date('Y-m-d G:i:s', $time);
    }  
    
    $time = uk_time();
    echo $time;
    
    $post_validations = array('body'  => '/^[[:alnum:][:punct:][:space:]]{1,2000}$/');
    
    /**
     * creates a post
     * @param array $params
     * @return bool
     */
    function create_post($params)
    {
      $connection = db_connect();
    
      $query = sprintf("insert into posts 
                           set 
    										 body = '%s',
    										 user_id = '%s',
    										 created_at ='%s'
                         ", 
    										 safe_output(mysql_real_escape_string($params['body'])),
    										 safe_output(mysql_real_escape_string($params['user_id'])),
    										 $time
    										 );
    
    	$result = mysql_query($query);
    

     

    I am using the uk_time() function and saving the value to variable $time which is then saved to created_at field in the database. The reason I use uk_time function is because I need the indian timezone and my hosting company has a different timezone settings, hence I can't use the mysql now() function.

     

    Can someone please tell me why the correct value is not sored in the database.

     

    Thanks,

    Ket

  12. Hi everyone,

     

    I have a field called created_at of type datetime in mysql, and I am passing in a variable $time that holds the time in format 2008-07-09 18:14:54 but for some strange reason when I insert the $time value into create_at field it saves it as 0000-00-00 00:00:00

     

    Here is my php code:

    date_default_timezone_set('Asia/Calcutta');
    function uk_time()
    {
    $time = time();
    
    return date('Y-m-d G:i:s', $time);
    }  
    
    $time = uk_time();
    echo $time;
    
    $post_validations = array('body'  => '/^[[:alnum:][:punct:][:space:]]{1,2000}$/');
    
    /**
     * creates a post
     * @param array $params
     * @return bool
     */
    function create_post($params)
    {
      $connection = db_connect();
    
      $query = sprintf("insert into posts 
                           set 
    										 body = '%s',
    										 user_id = '%s',
    										 created_at ='%s'
                         ", 
    										 safe_output(mysql_real_escape_string($params['body'])),
    										 safe_output(mysql_real_escape_string($params['user_id'])),
    										 $time
    										 );
    
    	$result = mysql_query($query);
    

     

    I am using the uk_time() function and saving the value to variable $time which is then saved to created_at field in the database. The reason I use uk_time function is because I need the indian timezone and my hosting company has a different timezone settings, hence I can't use the mysql now() function.

     

    Can someone please tell me why the correct value is not sored in the database.

     

    Thanks,

    Ket

  13. Hi,

     

    I have a site that stores user comments and the date/time of when the comments was placed. At the moment I insert comments and store date/time using the Now() as shown below:

    sprintf("INSERT INTO comments 
                      SET
    		  body = '%s',
    		  created_at = now(),
    		  user_id = '%s'
                      ", 
    		  safe_output(mysql_real_escape_string($params['body'])),
    		  safe_output(mysql_real_escape_string($params['user_id'])));
    

    The problem with the above is that the now() stores the date/time according to the hosting server location. I want the site to display and store date/time set to the timezone in London. Hence I have used this php function: date_default_timezone_set('Europe/London'); and used the time() in the insert query rather then the mysql now(), as shown below:

    sprintf("INSERT INTO comments 
                 SET 
    	     body = '%s',
    	     created_at =" .time(). ",
    	     user_id = '%s'
                 ", 
    	     safe_output(mysql_real_escape_string($params['body'])),
    	     safe_output(mysql_real_escape_string($params['user_id'])));

    However, I get 00 for the date value and 00:00 for time value. I think I get these null values because I have the created_at field as type "datetime" in mysql and also may be because time() function is a timestamp? Is that correct!

     

    If I want to use the time() and date() php functions do I have to change the create_at field as type "string" rather then "datetime"? and if I save the timestamp using time() as a string, can I then display the date the comment was left using the date() and passing the timestamp as a parameter?

    I am new to php and need some guidance in correct way to using the php functions time() and date() rather then using the mysql now(). Is there any guide's or tutorial that can make things clear for me.

     

    Thanks,

    Ket

  14. I have a website that displays comment and the date/time of the comments left by users. It currently saves the date and time of the comment into the database using the mysql now() function that uses the server's timezone and hence display the server timezone when showing when the comments was left on the site.

     

    I want to include a drop down field that allows users to select country and city and based on the user's selection it displays the appropriate timezone. Can anyone plz provide me with some guidence as to how I can achieve that.

     

    Thanks,

    Ket

  15. Hey Fenway, Thanks for your reply.. I did read the article but I didn't quite understand it, I guess I am just dumb  :-[. I didn't get the bit on how can I set the session timezone and the global timezone.

     

    Since I use PhpMyAdmin to manage my whole database, I do not know anything abt using the mysql command prompt as shown in the article. I did try using the convert_tz() as mentioned in the end but it didnt work. Actually I am lost lolz. Could you guide me?  ???

     

    Thanks,

    Ket

  16. Hey Fenway,

     

    Thanks for your message

     

    If you set the client timezone differently from the server timezone, mysql will do this for you.

    I am not sure how to do the above in MySql

     

    I have a query that pulls the post.created_at field and formats the day, month and time, using the date_format() function. Here is the query:

    $query = "select posts.id as id, posts.body, date_format(posts.created_at, '%d') as formatday, date_format(posts.created_at, '%b') as formatmonth, date_format(posts.created_at, '%H:%i') as formattime, posts.user_id, users.name 
                  from posts, users
    	      where 
    	      posts.user_id = users.id
    	      order
    	      by posts.id desc"; 

    How do I convert the time to the UK time since the Timezone on the hosting server is CDT, and I need the GMT to display the correct london time. If you think Convert_tz() is the correct function to use, how can I use it in the above query.

     

    Thanks,

    Ket

     

  17. I am thinking of using the CONVERT_TZ(dt,from_tz,to_tz) function of MySql that converts the from-timezone 'from_tz' into the to-timezone 'to_tz', basically I want the convert the hosting companys timezone into the london timezone, so that the NOW() function displays correct value.

     

    Could anyone tell me how can I find out the hosting company's timezone or is there any default timezone I can use. I just want the clerify the values I enter in the variable 'from_tz' and 'to_tz'. I think the values for to_tz is Europe/London or GB, but not sure!

     

    Thanks,

    Ket

  18. Hello everyone,

     

    I need some help with regards to displaying UK TimeZone. I save "user comments and the date and time created" into a MySql database. I use the Now() to save the date and time into the mysql databse. Since my hosting company is based in USA, when my page gets the time infomation from the database it shows the USA timezone, but I need to display the UK time. What do I need to change so I can display the correct UK time. Is there any function or any settings I need to change in the database or server?

     

    Thanks,

    Ket

×
×
  • 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.