Jump to content

samshel

Members
  • Posts

    837
  • Joined

  • Last visited

Posts posted by samshel

  1. 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

  2. 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

  3. @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 :)

  4. 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.

  5. 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

  6. 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.

  7. 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();
    
    
    ?>
    

  8. 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.

  9. 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.

  10. 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.

  11. 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?

     

×
×
  • 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.