Quote:
Originally Posted by af7567
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>";
}
}
}
?>