Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Everything posted by etrader

  1. That is my problem. There are other digits within the string, and I need to delete only the initial digits.
  2. I want to delete (likely by preg_match) the initial digits at the beginning of a string, but no alter to alphabetical characters. The string can contain digit or not. For example: $string="1-words are here"; $string=everything is word"; I want to delete if there is any digits at the beginning of my string. Thanks
  3. No, I do not want to perform search, as they are numbers to define some parameters (even it can be only 0,1). And I never call them separetly, when I get them from mysql database, I need all of them. So you think it is better to store them in a single column to reduce the number of columns?
  4. I want to assign some values for each entry. Which plan is better to assist better mysql performance Plan A: Storing as "value1-value2-value3" in a column created by varchar(50); then I can process the values by explode() or Plan B: Storing values individually in three columns created by int(11) I want to know several small int() is better OR it is better to keep the number of columns lesser by having a larger column of varchar(), as I need to add "-" separator.
  5. Thanks folks, this was exactly what I missed
  6. I insert into mysql table by a simple form. The problem is that I get error when my text contains (') or ("). Dow I need to put a \ before them by php before inserting into mysql or there's another trick to skip (') and (") when storing and calling text into/from mysql database?
  7. I capture a list of my articles from mysql by this command mysql_query("SELECT * FROM Text WHERE Key='$key'") Now I added a column for published and draft to be identified by 1 and 0, respectively. What is the best way to show only published articles? Adding a WHERE condition? What is the most common method in major CMSes? Thanks
  8. Thanks LeadingWebDev, Yes this is an alternative solution, as get_browser will provide [crawler] to be true or false. But I have read some reviews on the internet as the [crawler] is not very accurate, probably because get_browser is not very popular. On the other hand, it gives lots of information which are useless to me. Then, I though using $_SERVER['HTTP_USER_AGENT'] and performing preg_match is a lighter process. What do you think?
  9. I am writing a simple counter, but it counts both visitors and bots. To distinguish between these visits, I use $_SERVER['HTTP_USER_AGENT']. By preg_match I can get which visit is by a bot. The common way in the internet is to define preg_match for each major bot (e.g. googlebot). As I explored, all bots have their official url in the uer_agent. Thus, preg_match by "http://" should consider all bots; as user_agent of a human visitor does not include a url. Right? What's your idea to do so?
  10. Thanks WebStyles, you gave me a brilliant idea
  11. I want to crop a circle in the middle of a photo. To have transparency of the image around the main circle, I need to save it as PNG. Is it possible to write a php code to 1. crop a full circle in the middle of a JPG file 2. then save it with png transparency to show the main circle only?
  12. Thanks premiso, that's exactly what I asked for I use Nginx, thus, I needed to adopt the rule; but it is the easy part. I just needed to have an idea Thanks again!
  13. I search for words in mysql by mysql_query("SELECT * FROM Articles WHERE Tags LIKE '%$q%'", $con); But I have problem with my tags as they are stored as "tag1,tag2,tag3". Now I want to get every article which contains "tag1"; but this does not work as LIKE %tag1% needs space to detect a word; though my tag list is comma separated.
  14. It seems there is no way to do so. I am currently doing what ZulfadlyAshBurn said. I was looking for a way NOT to edit every single php file in my admin folder. I was looking to make a rule for the entire folder, not every single page. WebStyles, I did not ask you to make it work for me. I just asked you to clarify your tip, as apparently you did not get my issue. Anyway, thank folks!
  15. Sorry I didn't get it. Where should I put this code? I am looking for a way to create limited session to avoid access to the entire folder of admin; without putting the code in each single page.
  16. I created a session by a login page, and limited the pages by adding this condition to every page if(!isset($_SESSION['level'])){ echo"You are not authorized to visit this page"; } This works perfectly for every single page, but how I can use it for an entire folder like admin folder ?
  17. I have created a very simple CMS by storing articles in mysql database. Everything is OK for my need; but I have no idea how to handle user management. I have created a table for users and a page to create new accounts. But how I can restrict the article submission page to logged in users? How I can show a widget of profile of logged users? I think there are different ways to do so; define(), cookie, .... What is the best method as CMSes normally use? Thank you in advance
  18. Thanks TeNDoLLA, I prefer the explode trick. It's quite simple, and I am dealing with explode a lot.
  19. brilliant idea, $str2[0] will always return regardless of the existence of the given character. But I am still open to new ideas
  20. I want to delete everything after a given character; e.g. wanna get the first word from this string by deleting everything after first occurrence of "-" $str="word1-word2-word3"; I use this trick to do so $str2=substr($str,0,strpos($str, '-')); This works perfectly, but the problem is when the string is just one word without the given character (i.e. "-"). It will return nothing for $str="word1";
  21. Thanks Doug, it is an important issue. I am interested to know what php modules (in addition to php-common) are really necessary.
  22. Following common tutorials, we usually install selected modules of php. I wonder why not installing all modules (e.g. as yum install php php-*). Are they really useless? We have lots of unused softwares on our servers; do these unnecessary php modules consumes lots of resources? On the other hand, I am curious to know what are the necessary modules of php for a normal usage? P.S. I think that we install most of php modules by php-common!
  23. Thanks for sharing your idea
  24. ACL is a advanced system for creating users and user permissions stored in mysql, right? I am talking about only one admin whose login can be stored in a file too. Do you still think that php-based ACL is the best solution?
×
×
  • 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.