Jump to content

birbal

Members
  • Posts

    2,543
  • Joined

  • Last visited

Everything posted by birbal

  1. The best book i found for in depth javascript is Proffesional javascript for web developer by wrox publication. It is not cookbook style book where it shows many real world examples but it is good for core language and it covers every topic from the basic. Along with this mozilla and opera developer network has large and good resource about JS.
  2. make an 2d array like $fields[]=['name'=>'cnf_upload','value'=>'Update success'];$fields[]=['name'=>'err_upload','value'=>'Update failed']; now you can loop through $fields array and can make divs dynamically. you can also take value of 'name' and can explode by character '_'to get two part of string 'cnf' and 'upload' and check the first chunk to determine if it is 'error' or 'confirm' message and act accordingly. You can also set up a xml file in same way and use simplexml to parse the file and get values and names fron the file to do the same thing. this way you will have a centralised one source of message which you can moderate indinpendantly.
  3. Focusing on Java

  4. birbal

    filter_var function

    escaping is different than sanitinzing or filtering sanitinizing: Removing unwanted characters from input and return the result string validation: Check for existance of unwanted characters and pass if it matches otherwise not, returns like boolean escape: marking some character so that in particular context it will have different meaning than usual meaning of charcter. eg echo "hello world \n"; we use '\' to escape 'n' which is distinct from ordinary 'n' and represents new line. another eg echo "it is \" quoted \" string";
  5. birbal

    filter_var function

    It is best to use inbuilt validation function. it has common validation like URL,email in built without any use of regex. also it have facility for regex based validation and even custom rule validation using callable function. more over that it is native code of php so it is faster. One advantage of it is you can built an array of validation rules and use it in form generation and validation in one place.
  6. birbal

    Multisite login

    you need to use http://php.net/manual/en/function.session-set-cookie-params.php to set domain of your site and rest of your subdomain will have same same session. Apart from using this on each script you can also change corresponding field in php.ini to do the same thing.
  7. especially if the variables are meant to be used in conditional structure it is best to explicitly initalize variable as default value before you use them.
  8. birbal

    Damn you Charset....

    this one too looks fine. is your problem solved yet?
  9. in val_price() you have declared $pricelist as global. where as you have declared $pricelist as an array in the first line $pricelist['price1']=$_POST['price1']; it is actually creating an array $pricelist and assigning the $_POST['price1'] to $pricelist element "price1".In val price when you use global it is overwriting the local variable of $pricelist (which you have used as parameter). so at the time you are using trim() you are using $pricelist array.You should use var_dump() just before the problemetic line so that you can examine the variable well.
  10. birbal

    Damn you Charset....

    No, it looks fine to me
  11. birbal

    Damn you Charset....

    have you restarted the server?
  12. $pricelist itself is an array. in val_price() you are passong $pricelist. $pricelist['price'] is an element of array $pricelist which is itself a string, thus var dumping it shows you the string in other function.
  13. birbal

    Damn you Charset....

    Have you checked the default Charset of it in php.ini?
  14. check the data of var_dump() closely the "0" is refering to two different array. you can specify the index to point out particular data to work on each iteration.
  15. birbal

    if...else

    http://www.google.co...357700187,d.bmk <=replace http://www.google.co...357700187,d.bmk <=insert on duplicate REPLACE and INSERT ON DUPLICATE are work in same ways. They both need one query to do the job.but if you use insert and update separately it will need two query to do it. every query makes a transaction over network. so reducing those transaction helps to optimize the performance.
  16. Why not swithching to OOP from modular programming? this is the purpose of it. There is also "Programming Design patterns" which also helps with organizing codes and managing codes. You may also look into namspaces too.
  17. Manual has lot of example with them . Start with the DomDocument constrcutor. Check the examples there. in that example they will have use more function to do a certain job. keep on checking them. with studying each of example recusrively you will cover up the most common methods and usage of domDocument. Also each of function has list at bottom of the page which consists of similar methods which is helpfull. PHP manual is very verbose and easy to use manual i have ever seen with.DomDocument use common DOM API which is very similar like JS DOM.Also the link DD provided have list of methods and their usage in one page. I use those pages as summary cheatsheet. Reading alone those page gives the idea of poteniality and usage of class and function. If you know what you are doing seeking for appropiate function(s) from that page to solve the problem would not be hard. It is not only for DomDocument it applies to other classes too. PHP manual is very consistent. If everything fails or you still need other tutorial or examples you can google them. there is plenty of them around the web.
  18. birbal

    if...else

    Set an primary key or unique constraint to one of your field to determine each of them as unique after than you can use "REPLACE" (google it) to insert data. it will try to insert data first if it fails in PK or unique column it will try to update it.
  19. Instead of using browser button for interactivity of your application you should use html markup to create the next previous button. you can append the question number or id in each next or previous link. each time a page is loaded you can manipulate next and previous button id/number from the current page and then you can print it dynamically. previous page will never be less than 1 and next link will not be greater than total questions or highest question id ("Depening upon implementation of your application)
  20. birbal

    PHP Config edit

    You can also use simplexml to parse config files in XML which is more readable and covenient for complex config files (nested config)http//php.net/simplexml
  21. birbal

    qoute form

    It is not showing anything because you did not tell it to. neither you are returning any data or printing them in those function
  22. birbal

    PHP help

    you need to loop through (eg while loop) the mysql result set to get all the data. now it is just showing the first results. please check the tutorials regarding this. there is example of it. also in page.php you need to check the $var before you use it otherwise it will show errors anyway.
  23. birbal

    PHP help

    Post your code please.
  24. Also you can put the files in outside of web root which also means cant access publically.
  25. birbal

    CSV Feature

    you mean parsing csv files.you can use http://php.net/fgetcsv to parse csv file
×
×
  • Create New...