Jump to content

php_guest

Members
  • Posts

    98
  • Joined

  • Last visited

Everything posted by php_guest

  1. Hi everybody, I am wondering if there exist any good compiler or something like that to write code for mobile phones. Is it possible to write a good mobile application with php? Any helpful information will be great. tnx
  2. You mean filter_input_array()? Because if not, than won't solve my problem which is how to pass $method
  3. tnx, but if(empty(${"_$var"}[trim($field)])){ doesn't work. Seems "_$var is not ok because if I put instead of $var a string "GET", than works.
  4. Hi everybody, I need some help about how to convert string to array name. I have the following function which pass $_REQUEST type as parameter. It is not working because I don't know how to convert $method to $_GET or $_POST in a proper way. Do anybody know how? function validateIfFilled($method, $fields) { $exploded=explode(",",$fields); foreach($exploded as $field){ if(empty($method[trim($field)])){ return false; } } return true; }; if(!validateIfFilled('$_GET', "email, password, address")) ... Thank you!
  5. but without class, the only way to access $db object inside function is to use global $db every time in each function, right?
  6. I use $db object to handle database function like $db->get_row for example. Is there any way that I don't need to put into every function global $db or do I actually need to repeat in every function global $db? function example(){ global $db //Do I need to repeat this in each function? }
  7. I have mysql but the question is not how to store variables but how to print them. So to print as option a) as whole html or as b) as closing and opening for each translation php. Regarding JSON, is there any other option since I am not familiar with JSON?
  8. I am developing a multilingual site. I use array to save translations in one file which I include it inside settings.php. //Example of english $LANG['welcome']="Welcome"; $LANG['status']="Status"; I am wondering about two things: 1. How would be the best option to print those arrays? a) Echo all html and inside html I use echo " <body> <div> <p>{$LANG['welcome']}</p> </div> "; b) Close php and write html and inside html I open and close php for each time <div><p><?php echo $LANG['welcome']; ?></p></div> Each one has own downsides. Option a) spends extra resources to print html. Option b) spends extra resources to close and open php each time (could means that single script needs to open and close php even 30 times per script). Is that bad or is the ammount of resources spend for this negligible? 2. Also how do you translate words inside javascript? I was thinking to put all translation that are need for javascript into $LANG['js'] array. Then I would use at the head of the script foreach $LANG['js'] to print html to assign javascript language variables. <script type="javascript"> <?php foreach($LANG['js'] as $keyword => $translation){ echo "var ".$keyword."= ".$translation.";\n"; } ?> </script> Is there any better way? Thank you!
  9. I have a business social network site on hosting server. I am wondering if sessions are enough secure. ini_set('session.use_only_cookies', 1); //this prevent Session Fixation? session_start(); if($_SESSION['loggedIn'] && $_SESSION['userIP']==$_SERVER["REMOTE_ADDR"]) // extra security //user is logged in, assign all data to this profile from session else //user is not logged in, no data are assigned Would you consider that as enough secure?
  10. But in which way are not the same? With values beeing $var=""; $var=0; $var=false; $var="0"; $var=1; $var="string" the following statements output the same if($var)... if(!empty($var))... So in which example would they output different?
  11. Is if($variable) the same as if(!empty($variable)), just different syntax?
  12. I am wondering how Back, Forward browser button works for iframes. Does it bring back/forward iframe or top window? I remember I had before a problem because I wanted to bring back iframe and not top window as it did. But today I tested my Facebook app and was surprised to see it works as I need which means it brings back/forward iframe window and not top. Is it possible that Facebook has some javascript code which does that or is this normall behaviour? Thank you
  13. I am wondering if zend framework is used also in the biggest companies. Is comes to be helpfull or is it more professional to use own framework?
  14. I tried now to use RewriteRule ^/?(.*)/([-a-zA-Z_&0-9&,!]+)$ /article.php?url=$1 [L] www.domainname.com/الشباكيةالمغربية/articleId (articleid as number) instead of www.domainname.com/الشباكيةمربية This is a bit closer and works, but I need then to include article id in url. Than I tried also www.domainname.com/الشباكيةالمغربية/ (no need to include articleId, just /) RewriteRule ^/?(.*)/(.*)$ /article.php?url=$1 [L] which is the nearest solution. This also display a page without error, excepting css (I don't know why). Anyway I am not enough familier to replace second .* with a rule nothing but just /. I hope anybody can help with this. Tnx a lot!
  15. I have a site in "exostic" language. For SEO purposes, I have in url special characters. I don't want to change url because than I would loose SEO benefit of having title in url. Example: www.imedomene.com/ποδόσφαιρο => www.imedomene.com/%CF%80%CE%BF%CE%B4%CF%8C%CF%83%CF%86%CE%B1%CE%B9%CF%81%CE%BF which is actually www.imedomene.com/article.php?title=%CF%80%CE%BF%CE%B4%CF%8C%CF%83%CF%86%CE%B1%CE%B9%CF%81%CE%BF I would like to make rewrite_rule ^/?(/anything)$ /article.php?url=$1 [L] The problem is when inside everything is %. I tried RewriteRule ^/?(.*)$ /article.php?url=$1 [L], I have googled half day and checked hundreds of sites and still didn't find solution. Is even possible without any server configuration (I don't have access as I use sharing hosting) solve this with .htaccess? I hope anybody can help me!
  16. I have try almost everything and I have no idea what would be the correct sytax for the following line: <a style="margin:10px;" href="javascript:void(0);" onclick="javascript: jQuery.facebox('<img src=\"/image.php/imagename.png?width=130&height=130&cropratio=1:1&image=/userimages/company_images/imagename.png\"/>');"> Please could you help me with this problem. tnx
  17. I have DB password and other important information stored in settings.php. I will put settings.php outside public directory. But what I am not sure about is that I use to require_once settings.php into every page (index.php, users.php, profile.php, login.php, ...). Is that safe? I was thinking that if somebody came into any single main file, he will find out where I store setttings. If this file wouldn't be included in this way, than this won't be happen in any file. So for example file users.php starts like this: require_once(thePathName/settings.php'); checkLogIn(1); require_once $_SERVER['DOCUMENT_ROOT'].'/languages/lang_'.$language.'.php'; ...
  18. thanks, I realized it was varbinary. I changed it in phpmyadmin to varchar and now it is utf8_general_ci as it should be.
  19. I set my tables to utf8_general_ci but still queries with LIKE are case sensitive. How I can make queries case insensitive? I was thinking to use WHERE LOWER( fullName ) LIKE '%Jessica White%' but the problem is that won't use indexes. Is any other solution? tnx
  20. I decided to put it in functions.php. But is it ok to have all functions in functions.php? Does it make any slower if you include in each page functions.php where you have all functions? Or it doesn't effect since I don't call all those functions but only 1? thank you
  21. I am wondering if I need to use mysql_real_escape_string in SELECT sentences or is this needed only in INSERT and UPDATE sentences? Do I need to be carefull in search form where only select sentences are used?
  22. I have a list of countries and categories which are not in database. What is the best way to display them when I need them if I don't use object programming? Let's say I have 30 categories. $country_list = array( '1'=>"category1", '2'=>"category2", '3'=>"category3" ... ); Is the best way to create file lists.php and then I put into this file all lists? Than I require_once this file in every page. Or is better to create function show_lists($listsName) and store inside all lists?
  23. What are the correct ways to make mysql queries? a) 1. mysql_query("UPDATE inbox SET `city` = '1'... 2. mysql_query("UPDATE inbox SET `city` = 1... 3. mysql_query("UPDATE inbox SET `city` = $_POST[city]... 4. $city=$_POST[city]; mysql_query("UPDATE inbox SET `city` = $city 5. mysql_query("UPDATE inbox SET `city` = ".$_POST[city]."... and b) the same examples but if data is varchar and not numeric. I hope there is any body who can take a look to those queries. I would really like to finall clerify what is correct way. Thank you!
  24. I have the following function: ... $.ajax({ type: "POST", url: showresults.php, data: "clickedPage=" + clickedPage + "&id=" + id, error: function(){ alert('Error loading XML document'); }, success: function(msg){ //put results received from ajax call to div } }); ... Then I have in showresults.php lines if(!empty($_POST[clickedPage])){ $clickedPage=$_POST[clickedPage]; } Everything is fine, but I don't know how I can use this with GET. I tried to replace type: "POST", with type: "GET", and then if(!empty($_GET[clickedPage])){... but it doesn't work. What would be the correct syntax in function to get in showresults.php data with GET? Thanks a lot
×
×
  • 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.