Jump to content

samshel

Members
  • Posts

    837
  • Joined

  • Last visited

Everything posted by samshel

  1. Thanks Kicken. My last option would be to disable APC. However it increases the performance tremendously and i want to keep that Thanks. i will keep looking. Thanks Sameer
  2. $str = 'Year78'; preg_match("/([0-9]+)/", $str, $matches); echo $matches[0];
  3. Thank you for the response. I am sure there are no errors or exit/die since when the page is refreshed it loads correctly without any changes. There is nothing in the error logs. It has something to do with APC caching since this problem was not there before i started using APC. It might be related to the TTL or update file lock, Not sure. Just wanted to check if someone else has had similar issue. I cannot try different things since this is a production environment and this issue is hard to reproduce on dev. Thanks Sameer
  4. Hi All, I am using PHP 5.4.14 along with APC on Linux for my production environment. Every once a while users browsing the website get a blank page on a POST action like searching for orders. Refreshing the page loads the page correctly. any idea? Following are setting for APC: cat apc.ini extension=apc.so apc.shm_size=150M apc.stat=0 Runtime settings: Runtime Settings apc.cache_by_default 1 apc.canonicalize 1 apc.coredump_unmap 0 apc.enable_cli 0 apc.enabled 1 apc.file_md5 0 apc.file_update_protection 2 apc.filters apc.gc_ttl 3600 apc.include_once_override 0 apc.lazy_classes 0 apc.lazy_functions 0 apc.max_file_size 1M apc.mmap_file_mask apc.num_files_hint 1000 apc.preload_path apc.report_autofilter 0 apc.rfc1867 0 apc.rfc1867_freq 0 apc.rfc1867_name APC_UPLOAD_PROGRESS apc.rfc1867_prefix upload_ apc.rfc1867_ttl 3600 apc.serializer default apc.shm_segments 1 apc.shm_size 150M apc.shm_strings_buffer 4M apc.slam_defense 1 apc.stat 0 apc.stat_ctime 0 apc.ttl 0 apc.use_request_time 1 apc.user_entries_hint 4096 apc.user_ttl 0 apc.write_lock 1 Any help is much appreciated. Thanks Sameer
  5. Check out stripslashes() http://php.net/manual/en/function.stripslashes.php
  6. @PFMaBiSmAd Yes. I understand. i am already working on validating the data before i put it in the query. I just want to know if this MySQL behavior is expected. As per your statement, MySQL will convert the variables inside quotes to float while comparing numeric values so that answers my question. Thanks
  7. Here it is. SELECT voos.order_id, po_number, voos.created_datetime, vendors.vendor_name, users.user_name, products.sku, oos.message FROM voos INNER JOIN vendors ON voos.vendor_id = vendors.vendor_id INNER JOIN products ON voos.order_item_id = products.order_item_id LEFT JOIN users ON voos.user_id = users.user_id LEFT JOIN oos ON voos.order_item_id = oos.order_item_id AND voos.vendor_id = oos.vendor_id WHERE voos.po_number = 'S5008044'; CREATE TABLE `voos` ( `id` int(11) NOT NULL auto_increment, `order_id` int(11) NOT NULL default '0', `order_item_id` int(11) NOT NULL default '0', `po_number` int(11) NOT NULL default '0', `vendor_id` int(11) NOT NULL default '0', `reason` varchar(255) default NULL, `created_datetime` datetime NOT NULL default '0000-00-00 00:00:00', `last_modified` datetime default NULL, `user_id` int(11) default NULL, PRIMARY KEY (`id`), KEY `order_id` (`order_id`), KEY `order_item_id` (`order_item_id`), KEY `vendor_id` (`vendor_id`), KEY `created_datetime` (`created_datetime`), KEY `last_modified` (`last_modified`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 the main issue is po_number is INT(11) and when i fire a query on the table with WHERE po_number = 'ALPHANUMERIC' it returns all rows with po_number = 0.
  8. Hi All, I am having a weird problem with a simple select with joins. Example Table Structure: id INT(11) - Primary Key another_id INT(11) - some_text VARCHAR (10) I am firing a SELECT query with WHERE clause SELECT * FROM table_name WHERE another_id = 'S123'; This returns all records from table where another_id = 0. another_id is INT and it converts the S123 to integer which is 0. Shouldn't MySQL return 0 records? this is just an example. Actual implementation has multiple joins. I know that i should be validating the input and convert it into integer. I will be doing that. However what baffles me is why MySQL behave in this way? Why does it treat a varchar input as 0 when comparing to an INT field? Is this normal? Thanks Sam
  9. use mysql_error(); $result=mysql_query($query) or die(mysql_error()); This is the first step that will tell you if your query is getting executed correctly.
  10. Try this. if (!isset($_SESSION['user_id']) && $_SESSION['user_id'] != '') { header ("Location: ../registration.php"); } Removed the () after the ! sign. It was checking for negation of both conditions. If you are logged in $_SESSION['user_id'] != '' will be true.
  11. try putting an exit after readfile. Is there any space at the end of the file after ?> PHP close tags? Manually try downloading the file and see if it opens?
  12. I think the closing of while loop as incorrect. You are doing all your for loops for row column inside your while loop for fetching records. No surprise you see only one record. Try this: <?php // Run a select query to get my letest 6 items // Connect to the MySQL database $min = 1; $max = 4; $sql = mysql_query("SELECT * FROM Products ORDER BY date_added DESC LIMIT $min,$max"); $number_of_products = mysql_num_rows($sql); // count the output amount if ($number_of_products > 0) { while($product = mysql_fetch_array($sql)){ $products_name[] = $product["product_name"]; $products_id[] = $product["product_id"]; $products_price[] = $product["credits"]; $products_added[] = strftime("%b %d, %Y", strtotime($product["date_added"])); } $number_of_rows = $number_of_products/5; $product_index = 0; $the_table = '<table>'; for($row=0; $row < $number_of_rows; $row++){ $the_table .='<tr>'; for($col = 0; $col < 5; $col++){ if($products_index < count($products_name)){ $the_table .= '<td><a href="product.php?id=' .$products_id[$products_index]. '"><img src="inventory_images/' .$products_id[$products_index]. '.jpg" alt="' .$products_name[$products_index]. '" width="77" height="102" border="1" /></a><br /><a href="product.php?id=' .$products_id[$products_index]. '">' .$products_name[$products_index]. '</a><br />' .$products_price[$products_index]. 'pts</td>'; $products_index++; }else{ $the_table .='<td><img src="../../images/noprofile.jpg" width="77" height="102" border="1"> <br />NO PRODUCT <br />NO PRICE</td>'; } } $the_table .='</tr>'; } $the_table .='</table>'; }else { $the_table = "We have no products listed in our store yet"; } mysql_close(); ?>
  13. There is no way you can instantiate a class without "including" the file. Either implicitly or explicitly you will have to include the class file. There would be frameworks which do that for you and support the format you desire, but the only difference is the framework will include the file instead of you doing in explicitly.
  14. $this->directory_list in your directory is not treated like an array but a string. try $this->directory_list = $dir[$i]; //store these
  15. try this not tested... echo '<textarea id="question"'. $questionNo .'" name="'.$qaArray["answerText"].'" cols="60" rows="2">'.(isset($questionNo) ?htmlentities($qaArray["answerText"], ENT_QUOTES) : '') .'</textarea>';
  16. $translate = file_get_contents("https://www.googleapis.com/language/translate/v2?key=MyKey&q=$content&source=es&target=en"); $arr = json_decode($translate, true); var_dump($arr); echo $arr['data']['translations'][0]['translatedText'];
  17. Thats not going to work. If you keep the values same for all options, you will not be able to tell what the user selected from drop down and use it for any decision making in your program.
  18. blah.html resides in the web directory of your server, where your URL is pointing to. It will have exactly what i mentioned in the first post. Yes, it is good idea to keep the question as well in the database so you dont have to prepare a static page for each question. The same page will work for multiple questions and multiple answers. We need it to be "dynamic" right? To identify what question is to be displayed, it will depend on user input either by form or URL www.blah.com/blah.php?id=12 This tells blah.php to fetch question with id = 12 from the database and its respective answer and display it to the user. www.blah.com/blah.php?id=13 will display question 13 and its answers and so on.
  19. If you put it that way, yes PHP interpreter reads the server page, interprets the PHP code inside it, puts the answers in places and outputs a new HTML page... !!!
  20. An Array has 2 parts keys and values. I suppose the one you described above are values. What is the purpose of this form ? Do you want to update these in some database?
  21. Just a hint... you will have to use translations[0] and not translations HTH
  22. These are purely static pages. To make them dynamic, you need to use PHP to display the question and any or all answers it has in the "database". Following is sudo code: <html> <head> <title>Blah</tilte> <link rel = "stylesheet" style = "text/css" href = "blah.css" /> <script type = "text/javascript" src = "blah.js"></script> </head> <body> <div> <?php //fetch question with the id in the URL from the database and display here using PHP/MySQL ?> </div> <?php //fetch all answers to the question from the database for the selected question. //loop on each answer ?> <div id = "answer<?php echo id from current record ?>"><?php echo answer from current record ?></div> <?php //end loop ?> </body> </html> This way the you dont have to touch the page on the server everytime an answer is submitted. On submission of answer you insert the record in the database with appropriate questions id. when you refresh this page you will see the new answer displayed. I could write the entire code for you, but i think you need to read and understand the server side scripting basics first.
  23. array("01", "125","150", "A" => true,"B" => true), This is an associative array. It actually is the same as: array(0=>"01",1=> "125",2=>"150", "A" => true,"B" => true), The keys are numeric for first 3 elements and A and B for 4th and 5th element respectively. do you really want to do this? You code will consider the keys 1,2,3,A,B as drop down values. Also what is the result you are getting now? and what is the result you are expecting?
  24. worth a try. $translate = file_get_contents("https://www.googleapis.com/language/translate/v2?key=MyKey&q=$content&source=es&target=en"); $arr = json_decode($translate, true); var_dump($arr); echo $arr['data']['translations']['translatedText'];
×
×
  • 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.