SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    while loop works on local server but not on the production server

    the following works perfectly on the local wamp server but when i'm uploading it to the server used by the client it doesnt do nothing and gives a blank page.
    also enabling errorr reporting doesnt help - the page stays blank
    (
    PHP Code:
    error_reporting(E_ALL);
    ini_set("display_errors"1); 
    require (
    "security.php"); 
    any ideas?

    PHP Code:

    require "conf.inc";
    mysql_connect($host$username$password);
    mysql_select_db($database) or die("Unable to select database");
    mysql_query("SET NAMES 'utf8'");

    $sss=0;
    $user unserialize($_SESSION['user']);
    $uid=$user->get_user_id();
    $result2 mysql_query("SELECT first_name,last_name FROM users WHERE id='".intval($uid)."'");
    $row2 mysql_fetch_array($result2MYSQL_ASSOC);
    $first_name$row2['first_name'];
    $last_name=$row2['last_name'];
    $managername=$first_name .  " " $last_name;
    $aid mysql_real_escape_string($_POST["aid"]);
    $aname $_POST["aname"];

    $start_date mysql_real_escape_string($_POST["start_date"]);
    $end_date mysql_real_escape_string($_POST["end_date"]);
    $PaiedByAgent mysql_real_escape_string($_POST["paied"]);

    if(
    $PaiedByAgent==""){die ("יש לרשום כמה שולם על ידי סוכן");}
    $recepit mysql_real_escape_string($_POST["recepit"]);
    if(
    $recepit==""){die("יש לרשום מספר חשובנית");}
    $debt_sum mysql_real_escape_string($_POST["DebtSum"]);
    if (
    $PaiedByAgent $debt_sum)
    {
        echo 
    "הסכום שהסוכן משלם גבוהה יותר מהחוב, אין אפשרות לצבור יתרה";
        die;
    }
    $query "select * FROM payments WHERE agentID='$aid' AND TourDate BETWEEN '$start_date' AND '$end_date'";
    $result mysql_query($query); 

    if(!
    $result){echo mysql_error();}


    while (
    $PaiedByAgent 0)


        while (
    $row mysql_fetch_array($resultMYSQL_ASSOC))
        {
            
    $pid $row['id'];
            
    $orderID $row['orderID'];
            
    $AgentId $row['AgentId'];
            
    $Debt $row['Debt'];
            echo 
    "pid: ".$pid."<br>";
            echo 
    "orderid: ".$orderID."<br>";
            echo 
    "AgentId: ".$AgentId."<br>";
            echo 
    "debt: ".$debt."<br>";
            }}


            if (
    $Debt $PaiedByAgent)
            {
                
    $Cpay $PaiedByAgent;
                
    $Cdebt $Debt $Cpay;
    $query1 "UPDATE payments SET " "Paid = (Paid + " $Cpay "), Debt='" $Cdebt .
                    
    "', receipt = CONCAT_WS('<br/>', receipt," $recepit .
                    
    "), PayDate =CONCAT_WS('<br/>', PayDate, CURDATE()), ManagerName = CONCAT_WS('<br/>', ManagerName, '".addslashes($managername) ."') WHERE id = '" .
                    
    mysql_real_escape_string($pid) . "' ";
                
    $result1 mysql_query($query1);
                if (!
    $result1)
                {
                    echo 
    "error: " mysql_error();
                } else
                {
               
    $sss=$sss+1;
                }

                
    $PaiedByAgent $PaiedByAgent $Cpay;
                if (
    $PaiedByAgent == "0")
                {
                    break;
                }

            }
            if (
    $PaiedByAgent $Debt)
            {
                
    $Cpay $Debt;
                
    $Cdebt 0;
                
    $query1 "UPDATE payments SET " "Paid = (Paid + " $Cpay "), Debt='" $Cdebt .
                    
    "', receipt = CONCAT_WS('<br/>', receipt," $recepit .
                    
    "), PayDate =CONCAT_WS('<br/>', PayDate, CURDATE()), ManagerName = CONCAT_WS('<br/>', ManagerName, '".addslashes($managername) ."') WHERE id = '" .
                    
    mysql_real_escape_string($pid) . "' ";
                
    $result2 mysql_query($query1);
                if (!
    $result2)
                {
                    echo 
    "error: " mysql_error();
                } else
                {

                   
    $sss=$sss+1;
                }
                
    $PaiedByAgent $PaiedByAgent $Cpay;
                if (
    $PaiedByAgent == "0")
                {
                break;
                }
               continue 
    1;
              }
              
            if (
    $PaiedByAgent == $Debt)
            {
                
    $Cpay $PaiedByAgent;
                
    $Cdebt $Debt $Cpay;
        
               
    $query1 "UPDATE payments SET " "Paid = (Paid + " $Cpay "), Debt='" $Cdebt .
                    
    "', receipt = CONCAT_WS('<br/>', receipt," $recepit .
                    
    "), PayDate =CONCAT_WS('<br/>', PayDate, CURDATE()), ManagerName = CONCAT_WS('<br/>', ManagerName, '".addslashes($managername) ."') WHERE id = '" .
                    
    mysql_real_escape_string($pid) . "' ";
                
    $result3 mysql_query($query1);
                if (!
    $result3)
                {
                    echo 
    "error: " mysql_error();
                } else
                {
            
    $sss=$sss+1;
                }

                
    $PaiedByAgent $PaiedByAgent $Cpay;
                if (
    $PaiedByAgent == "0")
                {
                    break;
                }
            }

        }
    }


    if(
    $sss>0){
        
    $start_date implode('-'array_reverse(explode('-'$start_date)));
        
    $end_date implode('-'array_reverse(explode('-'$end_date)));
        
    htmls(1,$aid,$start_date,$end_date,$aname);
    }else{
    htmls(0,$aid,$start_date,$end_date,$aname);}

    function 
    htmls($res,$aid,$start_date,$end_date,$aname){
    echo 
    "
    <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
    <html xmlns=\"http://www.w3.org/1999/xhtml\">
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
    <title> דוח תשלומים</title>
    <link rel=\"stylesheet\" href=\"css/style.css\"  />
    <link rel=\"stylesheet\" href=\"css/menu_style.css\" type=\"text/css\" />

    </head>
    <body>

    "
    ;
    display_menu_by_level();

    if(
    $res=='1'){
        echo(
    "<div class='content'><h2>פרטי התשלום עודכנו</h2>" );
        echo 
    "<form  method='post' action='report_by_payment2.php'>";
        echo 
    "<input type='hidden' value='$aid' name='aid' />";
        echo 
    "<input type='hidden' value=$aname name='aname' />
        <input type='hidden' value='
    $start_date' name='start_date' />
    <input type='hidden' value='
    $end_date' name='end_date' />'
    <button type='submit'>חזור</button>
    "
    ;
        
    }
    else{
        echo 
    "<div class='content'><h2>"."שגיאה בעדכון פרטי התשלום"."</h2>";
       
    }
    echo
    "
    </div>
    </body>
    </html>

    "
    ;


  2. #2
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Have you tried to echo/var_dump()/print_r() statements starting after each line to see where the script is dying? You say that the While loop is not working but are you sure that it is even making it to the While loop?

    Steve
    ictus==""

  3. #3
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    A blank page usually indicates there is a fatal PHP error in the script.

    Make the first line of the script echo __LINE__. ' : ' __FILE__;die;

    If that show the line and file then cut the line and paste it halfway down the script.

    If that show then post it in the remaining line half of the script otherwise paste it the previous half of the script.

    Repeat until the error is found



    http://php.net/manual/en/errorfunc.configuration.php

    Note:

    Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by John_Betong
    Make the first line of the script echo __LINE__. ' : ' __FILE__;die;
    SB
    PHP Code:
    echo __LINE__ ' : ' .  __FILE__; die; 
    Missing a dot.

    Nice idea, like that one.

  5. #5
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    apperntley you were right - i didnt check if it go inside the loop.
    it didnt get the values it need from the previous page because i closed the mysql connection and still used the mysql_real_escape wich resulted in an empty vars.

    thank you all for fast replays and the will to help!

  6. #6
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    genia,

    Glad you found the problem.

    John_Betong: Yes that is a nice way to report where a script is making its' way. Thanks.

    Steve
    ictus==""

  7. #7
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,883
    Mentioned
    74 Post(s)
    Tagged
    6 Thread(s)
    @genia , @ServerStorm and especially @Cups for spotting the syntax error.

    Necessity is the Mother of Invention

    I devised the method after struggling with a PHP framework where all pages are derived from a common index.php file... biggest problem is to find which file has the error.
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Wolfshade on earning Member of the Month for August 2014


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •