Jump to content

Vikas Jayna

Members
  • Posts

    121
  • Joined

  • Last visited

Everything posted by Vikas Jayna

  1. You can convert the above string into date format by using the below query:- select str_to_date('August 2, 2010 11:04 pm','%M %e, %Y %h:%i %p'); output is 2010-08-02 23:04:00 Now you can apply other date functions on this to get the desired result. For eg. select Month(str_to_date('August 2, 2010 11:04 pm','%M %e, %Y %h:%i %p')), day(str_to_date('August 2, 2010 11:04 pm','%M %e, %Y %h:%i %p')), year(str_to_date('August 2, 2010 11:04 pm','%M %e, %Y %h:%i %p')) This will give the desired output of month=8, day=2 and year=2010
  2. You'll have to create a recursive procedure to find all the subcategories within a category and then use this list in the IN clause of the SQL query to find all the products within these categories
  3. Think this is the best solution possible. As such the difference between mediumtext and text is only the extra byte used by mediumtext to store the length of the string and hence there is hardly any overhead of declaring the column as mediumtext
  4. We'll need to know the encoding algorithm to be able to decode it. Look like hexadecimal codes - every couple of bytes have been picked and then changed to hexadecimal code. Just guessing!!
  5. I need a deployer that's easy to use and can deploy PHP applications on multiple servers simultaneously since the traffic of the website is getting distributed across all the servers using LVS. Any suggestions?
  6. Try using regexp - http://dev.mysql.com/doc/refman/5.0/en/regexp.html
  7. Issue is not related to PHP. Hotmail could be treating mails from your server as spam. Check the messages in your server maillogs or ask the system administrator to do the same, see if the mails are bouncing and if yes - check why the recipient server is rejecting them. Generally the bounced message will be containing a diagnostic message explaining the same.
  8. To restore the database the mysql command is to be used. mysqldump cannot restore.
  9. I've recently upgraded from PHP 4.3.2 (cgi) to PHP 5.2.4 (cli). As a result I'm facing the following issue while running php from the command line: I execute a file a.php in my home directory as php -q a.php the file a.php includes a php file like this include ("/var/www/html/b.php") the file b.php further has includes like include("c.php") now the file c.php is located within /var/www/html but the newer php version looks for the file in my home directory while the older version looks for it in /var/www/html A workaround for this that I've used is to change the current directory using the chdir function to /var/www/html and it works but this process becomes quite cumbersome if the script is having a number of includes this way from separate directories. Is there any configurational change that can be done in php to avoid these issues?
  10. I am trying to make a middle layer for interaction between the database and the applications Hence I created a function _db_query() that is to be called to execute any query throughout the application on our site. This function does some decision making about which server the query should go to. The function uses mysql_query() function then to execute the query on that server. The issue is that I need to restrict the use of mysql_query() function from anywhere else in the application and force them to use the function _db_query() so as to avoid mistakes in case a programmer forgets to call _db_query() and instead calls mysql_query() Any ideas about implementing this?
  11. A javascript file can be served through php also. The php file can simply process and decide what should be the javascript code and simple throw that code to the browser. The following line will have to be added to the top of the php file in order to tell the browser that the content is javascript: header("Content-type: application/x-javascript"); Also, the file extension can be kept .js and mod_rewrite can be used in apache to direct the file to a php file like this: RewriteRule ^abc.js$ abc.php [T=application/x-httpd-php] The above line cab be used in .htaccess. This way the browser will call file "abc.js" but actually "abc.php" will be executed on the server.
  12. There is no need of adding any php files. Here is the crontab code for executing the command at 00:00 hrs everyday 00 00 * * * /bin/rm -rf <foldername> And yes the complete path to the folder has to be given.
  13. You can use a two table structure wherein there is one table is used to store categories i.e. the table will contain exactly one record for each category. The second table will then be used to represent a parent-child relationship between the categories. For e.g. in the above case "software" is a parent of "computer games" and "computer games" is a parent of "strategy".
  14. How about using a simple linux command in cron: rm -rf <foldername>/*
  15. addslashes is used to put back slashes in front of quotes so as to avoid syntax errors in sql queries in case the query contains some values that are taken from a text field. Stripslashes would be used to remove the slashes in case we don't want them. For e.g. quite often magic_quotes_gpc is set to On in php.ini so that slashes are automatically added in from of quotes and there is no need to explicitly use addslashes. It is good to keep magic_quotes_gpc On so as to avoid SQL Injection attacks. But in this case if the values taken from the text field is to be displayed somewhere then the extra slash would appear in the output and hence stripslashes is used to remove the same.
  16. Try this code: Order allow,deny deny from all This would work if mod_access is loaded in apache configuration
  17. Yes! I will have to split the tables vertically. But is there a way out to avoid searching each of the split tables? I know it can be done if we are searching on only one field, but what if we are searching on multiple fields?
  18. Hi, I'm working for a matrimonial site and have been trying to find an optimal solution for the following problem: I need to store the details of all the profile views happening on the site i.e. the id of the person who views the profile and the id of the person whose profile was viewed along with the date and a flag depicting whether the other person viewed back the profile of the person. Here's the table structure: `VIEW_LOG` ( `VIEWER` mediumint( unsigned NOT NULL default '0', `VIEWED` mediumint( unsigned NOT NULL default '0', `DATE` date NOT NULL default '0000-00-00', `VIEWED_MMM` char(1) NOT NULL default 'N', UNIQUE KEY `UNI1` (`VIEWER`,`VIEWED`), INDEX `UNI2` (VIEWED) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 The problem is that with around 300,000 views happening daily this table now has around 80 million records and inserts and updates on this table start getting stuck frequently increasing the load on the servers and slowing down the site. One solution to above problem could be to partition the table into a number of small tables thereby reducing the cost of inserts but I need to run separate select queries on both the columns VIEWER as well as VIEWED and if I partition the table on VIEWER then the query on VIEWED will have to scan all the partitions which would be slower. Any suggestions on how to manage such kind of tables? Thanks for reading!
  19. Yes! unless the php file does some sort of authentication and only let authorized users watch the video, there should be no problem copying it.
  20. Here's a great class PHPExcel that provides a lot of features: http://www.codeplex.com/PHPExcel
  21. by referring them as tablename.id
  22. This does not depend on the way php is being run but depends on the php configuration. More specifically, you need to check the error_reporting option in php.ini. Probably you had notices disabled in your previous configuration and have them enabled in the new one. Just change the value of error_reporting so as to disable notices and restart IIS server so that the changes reflect in online applications.
  23. Well, I'm not stumped! Here's why:- Mysql makes use of temporary files while doing a sort or a group by operation and these temporary files are created at a location specified by the tmpdir variable in mysql. Check the output for the "show variables" query and u should get "/var/tmp" in this variable. Now why mysql is unable to create the temporary table will have to be explored. There could be many reasons:- 1) mysql may not have write permissions on this directory. 2) probably this directory does not exist. 3) problem of disk space? Go through the following link to know more: http://dev.mysql.com/doc/refman/5.0/en/temporary-files.html
  24. Write a simple left join query and use "<columname> is null" in the where clause to get the records that are not there in the table on the right. http://dev.mysql.com/doc/refman/5.0/en/join.html
  25. Well The following things are to be looked at:- 1) the function name is delete_cookie but the call to the function is deleteCookie. 2) also the function requires a parameter cookie_to_delete and no parameter is being passed to the function.
×
×
  • 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.