LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 05-26-2015, 04:14 AM   #1
branddonchau
Member
 
Registered: Mar 2013
Posts: 36

Rep: Reputation: Disabled
Question Cron job error "PHP Notice: Undefined variable:.........."


Hi all,

I'm getting an error

"PHP Notice: Undefined variable: customerid in /var/www/html/cli_updatenew.php on line 65"

on centos7 with cron job, but no any error when the same .php running on window XP (via browser)...

Someone can help? Thanks.

Brgds/Brandon Chau
 
Old 05-26-2015, 06:05 AM   #2
af7567
Member
 
Registered: Nov 2012
Posts: 291

Rep: Reputation: 104Reputation: 104
When you run the script via the browser are you passing the customerid variable to it from a form on another page? Or are you going directly to the cli_updatenew.php page?

If the php script is expecting variables to be passed to it from a web form then it won't work if you just run it from the command line unless you are giving it the variables somehow using some php options.
 
Old 05-26-2015, 10:49 PM   #3
branddonchau
Member
 
Registered: Mar 2013
Posts: 36

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by af7567 View Post
When you run the script via the browser are you passing the customerid variable to it from a form on another page? Or are you going directly to the cli_updatenew.php page?

If the php script is expecting variables to be passed to it from a web form then it won't work if you just run it from the command line unless you are giving it the variables somehow using some php options.
Hi ,

Thank you the reply.

Actually , the customerid value get from the mysql command result,
the script as below code, thanks.

p.s The error line is line 65 , you can search by keywords ==> "$insert_customerid=$customerid[$i];"

PHP Code:

<?php
include("db_connection.php");

$sql_get_CLItmp="SELECT customerid,CLI,country,startdate FROM incomingCLItmp";

$result_get_CLItmp=mysql_query($sql_get_CLItmp,$conn_re);

//get CLItmp error if(!$result_get_CLItmp) {mysql_error()}

$numOfRow_get_CLItmp=mysql_num_rows($result_get_CLItmp);

if(
$numOfRow_get_CLItmp >0)    
    
{
    
    
    while(
$row=mysql_fetch_assoc($result_get_CLItmp))
    {
        
        
$customer[]=$row['customerid];       
        $temp_cli[]=$row['
CLI'];
        $country[]=$row['
country'];
        $startdate[]=$row['
startdate'];
        
    }
    
for($i=0;$i<100;$i++) //$numOfRow_get_CLItmp
    {
    
        $numOfRow_check_CLI='';
        
        $sql_check_CLI="Select CLI from incomingCLI where CLI= '
$temp_cli[$i]'";
        
        $result_check_CLI=mysql_query($sql_check_CLI, $conn_re);
        
        ////get CLI error  if(!$result_get_CLItmp) {}
        
        $numOfRow_check_CLI = mysql_num_rows($result_check_CLI);
        
        //record existed
        if($numOfRow_check_CLI > 0)
        
        {
            
                            //delete duplicated cli from CLItmp table
            $sql_delete_CLItmp="delete from incomingCLItmp where CLI='
$temp_cli[$i]'";
            
            $result_delete_CLItmp=mysql_query($sql_delete_CLItmp, $conn_re);
            
                            //delete succeed
                            // if($result_delete_CLItmp===TRUE){}
                            
                            //else {mysql_error()}
            //echo "Duplicated CLI, need delete from CLItmp ".$temp_cli[$i]."<br>";        
        }
        
        else //new incoming CLI , need insert into database 
        {
            
            $insert_customerid=$customerid[$i];
            $insert_cli=$temp_cli[$i];
            $insert_country=$country[$i];
            $insert_startdate=$startdate[$i];
            
            $sql_insert_CLI="INSERT INTO incomingCLI (customerid, CLI, country, startdate) 
                                VALUES ('
$insert_customerid','$insert_cli','$insert_country','$insert_startdate')";
                                
            $result_insert_CLI=mysql_query($sql_insert_CLI, $conn_re);
                                        
                                        //if(!$result_insert_CLI){mysql_error()}
                                        
                                        //insert succeed
                                        //else {};
            $sql_delete_CLItmp = "delete from incomingCLItmp WHERE CLI='
$insert_cli'";
            $result_delete_CLItmp = mysql_query($sql_delete_CLItmp, $conn_re);
            
            //echo"New CLI, need to insert into CLI table ".$temp_cli[$i]."<br>";
        }
    }

}


?>
 
Old 05-27-2015, 04:08 AM   #4
branddonchau
Member
 
Registered: Mar 2013
Posts: 36

Original Poster
Rep: Reputation: Disabled
Thank you all , i just fixed the problem already ^_^
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
plesk + php 4.3.2 upgrade error - "undefined symbol: ap_signal" p_s_shah Linux - Server 0 10-30-2007 12:41 PM
Urgent PHP problem with "undefined function: domxml_open_mem()"! Recomplie php? Oskare100 Linux - Server 0 12-27-2006 12:28 PM
I need help on this PHP error -- "Call to undefined function: mysql_connect()" yzh999 Linux - Software 1 08-12-2006 03:14 AM
avgscan "relocation error" "undefined symbol: __dynamic_cast_2" Monster_user Linux - Software 0 02-22-2006 11:57 AM
"permission denied" error when cron job executes jillu Linux - Newbie 11 11-02-2004 01:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration