This topic is locked

query error only in php runner

1/17/2007 3:46:06 AM
PHPRunner General questions
M
mauro author

I created this query, and it's ok, but in php runner i've error,
SELECT case

left (dst, 8)

when '001234' then 'Test 1'

when '004567' then 'Test 2'

when '008991' then 'Test 3'

when '001156' then 'Test 4'

when '009632' then 'Test 5'

end ,

count(src) as 'Totale',

Max(duration)/60 as 'Lunghezza (min)',

Min(duration)/60 as 'Breve (min)',

avg(duration)/60 as 'Media(min)',

sum(duration)/60 as 'Tempo Tot (min)'

FROM cdr

where MONTH(calldate) = 1

and dstchannel like 'interchannel%'

and accountcode = 'virtual'

and disposition = 'ANSWERED'

group by left (dst, 8) with rollup

Alexey admin 1/17/2007

mauro,
run your query directly on your database, read the error messages and fix your query.

M
mauro author 1/17/2007

I've this error
PHP Parse error: parse error, unexpected T_STRING in C:\mysoftware\file.php on line 391

M
mauro author 1/17/2007

mauro,

run your query directly on your database, read the error messages and fix your query.


in my database if i run my query (on phpmyadmin or with Sqlyog Enetrprise) i've no error

Sergey Kornilov admin 1/17/2007

How does C:\mysoftware\file.php file error applies to PHPRunner?

M
mauro author 1/18/2007

How does C:\mysoftware\file.php file error applies to PHPRunner?


i created new query:
*SELECT

left (src, 4) as 'prefisso',

case

left (src, 4)

when '0131' then 'Palermo'

when '0141' then 'Catania'

when '0161' then 'Taranto'

when '0165' then 'Alessandria'

when '0171' then 'Asti'

when '0183' then 'Vercelli'

when '0187' then 'Aosta'

when '0321' then 'Cuneo'

when '0323' then 'Imperia'

when '0332' then 'La Spezia'

when '0341' then 'Novara'

when '0342' then 'Verbania'

when '0371' then 'Varese'

when '0372' then 'lecco'

when '0376' then 'Sondrio'

when '0382' then 'Lodi'

when '0422' then 'Cremona'

when '0425' then 'Mantova'

when '0432' then 'Pavia'

when '0434' then 'Treviso'

when '0437' then 'Rovigo'

when '0444' then 'Udine'

when '0461' then 'Pordenone'

when '0471' then 'Belluno'

when '0481' then 'Vicenza'

when '0521' then 'trento'

when '0522' then 'Bolzano'

when '0523' then 'Gorizia'

when '0532' then 'Parma'

when '0541' then 'Reggio Emilia'

when '0543' then 'Piacenza'

when '0543' then 'Ferrara'

when '0544' then 'Rimini'

when '0564' then 'Cesena'

when '0565' then 'Forli'

when '0573' then 'Ravenna'

when '0574' then 'Grosseto'

when '0575' then 'Piombino'

when '0577' then 'Pistoia'

when '0583' then 'Prato'

when '0585' then 'Arezzo'

when '0586' then 'Siena'

when '0721' then 'Lucca'

when '0722' then 'Massa Carrara'

when '0733' then 'Livorno'

when '0736' then 'Pesaro'

when '0744' then 'Urbino'

when '0746' then 'Macerata'

when '0761' then 'Ascoli Piceno'

when '0766' then 'Civitavecchia'

when '0773' then 'Terni'

when '0775' then 'Rieti'

when '0783' then 'Viterbo'

when '0784' then 'latina'

when '0823' then 'Frosinone'

when '0824' then 'Oristano'

when '0825' then 'Nuoro'

when '0831' then 'Caserta'

when '0832' then 'Benevento'

when '0835' then 'Avellino'

when '0861' then 'Brindisi'

when '0862' then 'Lecce'

when '0865' then 'Matera'

when '0871' then 'Teramo'

when '0874' then 'Aquila'

when '0881' then 'Isernia'

when '0922' then 'Chieti'

when '0923' then 'Campobasso'

when '0931' then 'Agrigento'

when '0932' then 'Foggia'

when '0934' then 'Trapani'

when '0935' then 'Siracusa'

when '0961' then 'Ragusa'

when '0962' then 'Caltanissetta'

when '0963' then 'Enna'

when '0965' then 'Catanzaro'

when '0971' then 'Crotone'

when '0984' then 'Vibo Valentia'

end,

count(dst) as 'Totale Chiamate Perse'

FROM cdr

where MONTH(calldate) = 1

and disposition ='ANSWERED'

and dstchannel not like '%Local/%'

and dst = '951'

and dcontext ='ext-queues'

group by case

left (src, 4)

when '0766' then 'Civitavecchia'

when '0131' then 'Palermo'

when '0141' then 'Catania'

when '0161' then 'Taranto'

when '0165' then 'Alessandria'

when '0171' then 'Asti'

when '0183' then 'Vercelli'

when '0187' then 'Aosta'

when '0321' then 'Cuneo'

when '0323' then 'Imperia'

when '0332' then 'La Spezia'

when '0341' then 'Novara'

when '0342' then 'Verbania'

when '0371' then 'Varese'

when '0372' then 'lecco'

when '0376' then 'Sondrio'

when '0382' then 'Lodi'

when '0422' then 'Cremona'

when '0425' then 'Mantova'

when '0432' then 'Pavia'

when '0434' then 'Treviso'

when '0437' then 'Rovigo'

when '0444' then 'Udine'

when '0461' then 'Pordenone'

when '0471' then 'Belluno'

when '0481' then 'Vicenza'

when '0521' then 'trento'

when '0522' then 'Bolzano'

when '0523' then 'Gorizia'

when '0532' then 'Parma'

when '0541' then 'Reggio Emilia'

when '0543' then 'Piacenza'

when '0543' then 'Ferrara'

when '0544' then 'Rimini'

when '0564' then 'Cesena'

when '0565' then 'Forli'

when '0573' then 'Ravenna'

when '0574' then 'Grosseto'

when '0575' then 'Piombino'

when '0577' then 'Pistoia'

when '0583' then 'Prato'

when '0585' then 'Arezzo'

when '0586' then 'Siena'

when '0721' then 'Lucca'

when '0722' then 'Massa Carrara'

when '0733' then 'Livorno'

when '0736' then 'Pesaro'

when '0744' then 'Urbino'

when '0746' then 'Macerata'

when '0761' then 'Ascoli Piceno'

when '0773' then 'Terni'

when '0775' then 'Rieti'

when '0783' then 'Viterbo'

when '0784' then 'latina'

when '0823' then 'Frosinone'

when '0824' then 'Oristano'

when '0825' then 'Nuoro'

when '0831' then 'Caserta'

when '0832' then 'Benevento'

when '0835' then 'Avellino'

when '0861' then 'Brindisi'

when '0862' then 'Lecce'

when '0865' then 'Matera'

when '0871' then 'Teramo'

when '0874' then 'Aquila'

when '0881' then 'Isernia'

when '0922' then 'Chieti'

when '0923' then 'Campobasso'

when '0931' then 'Agrigento'

when '0932' then 'Foggia'

when '0934' then 'Trapani'

when '0935' then 'Siracusa'

when '0961' then 'Ragusa'

when '0962' then 'Caltanissetta'

when '0963' then 'Enna'

when '0965' then 'Catanzaro'

when '0971' then 'Crotone'

when '0984' then 'Vibo Valentia'

end

with rollup*
but i've the same error. When i use 'case .... end' i have error in php file:
PHP Parse error: parse error, unexpected T_STRING in C:\myfiles\file_list.php on line 391
Query is ok in phpmyadmin or Sqlyog Enterprise on server.
this is file_list.php created automatically by Php Runner:
<?php

ini_set("display_errors","1");

ini_set("display_startup_errors","1");

header("Expires: Thu, 01 Jan 1970 00:00:01 GMT");

set_magic_quotes_runtime(0);
include("include/dbcommon.php");

include("include/file_variables.php");
include('libs/Smarty.class.php');

$smarty = new Smarty();
$conn=db_connect();
// process reqest data, fill session variables
if(!count($_POST) && !count($_GET))

{

$sess_unset = array();

foreach($SESSION as $key=>$value)

if(substr($key,0,strlen($strTableName)+1)==$strTableName."
" &&

strpos(substr($key,strlen($strTableName)+1),"_")===false)

$sess_unset[] = $key;

foreach($sess_unset as $key)

unset($_SESSION[$key]);

}
if(@$_REQUEST["a"]=="showall")

$_SESSION[$strTableName."_search"]=0;

else if(@$_REQUEST["a"]=="search")

{

$_SESSION[$strTableName."_searchfield"]=postvalue("SearchField");

$_SESSION[$strTableName."_searchoption"]=postvalue("SearchOption");

$_SESSION[$strTableName."_searchfor"]=postvalue("SearchFor");

if(postvalue("SearchFor")!="" || postvalue("SearchOption")=='Empty')

$_SESSION[$strTableName."_search"]=1;

else

$_SESSION[$strTableName."_search"]=0;

$_SESSION[$strTableName."_pagenumber"]=1;

}

else if(@$_REQUEST["a"]=="advsearch")

{

$_SESSION[$strTableName."_asearchnot"]=array();

$_SESSION[$strTableName."_asearchopt"]=array();

$_SESSION[$strTableName."_asearchfor"]=array();

$_SESSION[$strTableName."_asearchfor2"]=array();

$tosearch=0;

$asearchfield = postvalue("asearchfield");

$_SESSION[$strTableName."_asearchtype"] = postvalue("type");

if(!$_SESSION[$strTableName."_asearchtype"])

$_SESSION[$strTableName."asearchtype"]="and";

foreach($asearchfield as $field)

{

$gfield=GoodFieldName($field);

$asopt=postvalue("asearchopt
".$gfield);

$value1=postvalue("value".$gfield);

$type=postvalue("type
".$gfield);

$value2=postvalue("value1".$gfield);

$not=postvalue("not
".$gfield);

if($value1 || $asopt=='Empty')

{

$tosearch=1;

$_SESSION[$strTableName."_asearchopt"][$field]=$asopt;

if(!is_array($value1))

$_SESSION[$strTableName."_asearchfor"][$field]=$value1;

else

$_SESSION[$strTableName."_asearchfor"][$field]=combinevalues($value1);

$_SESSION[$strTableName."_asearchfortype"][$field]=$type;

if($value2)

$_SESSION[$strTableName."_asearchfor2"][$field]=$value2;

$_SESSION[$strTableName."_asearchnot"][$field]=($not=="on");

}

}

if($tosearch)

$_SESSION[$strTableName."_search"]=2;

else

$_SESSION[$strTableName."_search"]=0;

$_SESSION[$strTableName."_pagenumber"]=1;

}
if(@$_REQUEST["orderby"])

$_SESSION[$strTableName."_orderby"]=@$_REQUEST["orderby"];
if(@$_REQUEST["pagesize"])

{

$_SESSION[$strTableName."_pagesize"]=@$_REQUEST["pagesize"];

$_SESSION[$strTableName."_pagenumber"]=1;

}
if(@$_REQUEST["goto"])

$_SESSION[$strTableName."_pagenumber"]=@$_REQUEST["goto"];
// process reqest data - end
$smarty->assign("includes",

"&lt;script language=\"JavaScript\" src=\"include/jsfunctions.js\">".

"</script>".

"&lt;script>".

" var bSelected=false;".

"var TEXT_FIRST = \""."Primo"."\";".

"var TEXT_PREVIOUS = \""."Precedente"."\";".

"var TEXT_NEXT = \""."Prossimo"."\";".

"var TEXT_LAST = \""."Ultimo"."\";".

"</script>");
// process session variables

// order by

$strOrderBy="";

$order_ind=-1;
$smarty->assign("order_dir_prefisso","a");

$smarty->assign("order_dir_case_leftsrc4__when0131thenPalermo_when0141th

enCataniawhen0161thenTarantowhen0165thenAlessandriawhen0

171thenAsti
when0183thenVercelliwhen0187thenAostawhen03

21
thenCuneo_when0323","a");

$smarty->assign("order_dir_Totale_Chiamate","a");
if(@$_SESSION[$strTableName."_orderby"])

{

$order_field=substr($_SESSION[$strTableName."_orderby"],1);

$order_dir=substr($_SESSION[$strTableName."_orderby"],0,1);

$order_ind=GetFieldIndex($order_field);
$smarty->assign("order_dir_prefisso","a");

if($order_field=="prefisso")

{

if($order_dir=="a")

{

$smarty->assign("order_dir_prefisso","d");

$img="up";

}

else

$img="down";

$smarty->assign("order_image_prefisso","<img src=\"images/".$img.".gif\" border=0>");

}

$smarty->assign("order_dir_caseleftsrc4__when0131then__Palermo
when0141th

enCataniawhen0161thenTarantowhen0165thenAlessandriawhen0

171thenAsti
when0183thenVercelliwhen0187thenAostawhen03

21
thenCuneo_when0323","a");

if($order_field=="case

left (src, 4)

when '0131' then 'Palermo'

when '0141' then 'Catania'

when '0161' then 'Taranto'

when '0165' then 'Alessandria'

when '0171' then 'Asti'

when '0183' then 'Vercelli'

when '0187' then 'Aosta'

when '0321' then 'Cuneo'

when '0323")

{

if($order_dir=="a")

{

$smarty->assign("order_dircase
leftsrc4__when0131thenPalermo_when0141th

en_Catania
when0161thenTarantowhen0165thenAlessandriawhen0

171
thenAstiwhen0183thenVercelliwhen0187thenAostawhen03

21thenCuneo
when0323","d");

$img="up";

}

else

$img="down";

$smarty->assign("order_image_caseleftsrc4__when0131then__Palermo
when0141

thenCataniawhen0161thenTarantowhen0165thenAlessandria_when_

_0171
then_Asti
when0183thenVercelliwhen0187thenAostawhen

0321
then__Cuneo_when0323","<img src=\"images/".$img.".gif\" border=0>");

}

$smarty->assign("order_dir_Totale_Chiamate","a");

if($order_field=="Totale Chiamate Perse")

{

if($order_dir=="a")

{

$smarty->assign("order_dir_Totale_Chiamate","d");

$img="up";

}

else

$img="down";

$smarty->assign("order_image_Totale_Chiamate","<img src=\"images/".$img.".gif\" border=0>");

}
if($order_ind)

{

if($order_dir=="a")

$strOrderBy="order by ".($order_ind)." asc";

else

$strOrderBy="order by ".($order_ind)." desc";

}

}

if(!$strOrderBy)

$strOrderBy=$gstrOrderBy;
// page number

$mypage=(integer)$_SESSION[$strTableName."_pagenumber"];

if(!$mypage)

$mypage=1;
// page size

$PageSize=(integer)$_SESSION[$strTableName."_pagesize"];

if(!$PageSize)

$PageSize=$gPageSize;
$smarty->assign("rpp10_selected",($PageSize==10)?"selected":"");

$smarty->assign("rpp20_selected",($PageSize==20)?"selected":"");

$smarty->assign("rpp30_selected",($PageSize==30)?"selected":"");

$smarty->assign("rpp50_selected",($PageSize==50)?"selected":"");

$smarty->assign("rpp100_selected",($PageSize==100)?"selected":"");

$smarty->assign("rpp500_selected",($PageSize==500)?"selected":"");
// delete record

if (@$_POST["mdelete"])

{

foreach(@$_POST["mdelete"] as $ind)

{

$keys=array();

$strSQL="delete from ".AddTableWrappers($strOriginalTableName)." where ".KeyWhere($keys);

$retval=true;

$where = substr($strSQL,strlen("delete from ".AddTableWrappers($strOriginalTableName)." where "));

if(function_exists("BeforeDelete"))

$retval = BeforeDelete($where);

if($retval)

{

LogInfo($strSQL);

db_exec($strSQL,$conn);

if(function_exists("AfterDelete"))

AfterDelete();

}

}

if(function_exists("AfterMassDelete"))

AfterMassDelete();

}
// make sql "select" string
$strSQL = $gstrSQL;
// add search params
if(@$_SESSION[$strTableName."_search"]==1)

// regular search

{

$strSearchFor=trim($_SESSION[$strTableName."_searchfor"]);

$strSearchOption=trim($_SESSION[$strTableName."_searchoption"]);

if(@$_SESSION[$strTableName."_searchfield"])

{

$strSearchField = $_SESSION[$strTableName."_searchfield"];

if($where = StrWhere($strSearchField, $strSearchFor, $strSearchOption, ""))

$strSQL = AddWhere($strSQL,$where);

else

$strSQL = AddWhere($strSQL,"1=0");

}

else

{

$strWhere = "1=0";

$strSQL = AddWhere($strSQL,$strWhere);

}

}

else if(@$_SESSION[$strTableName."_search"]==2)

// advanced search

{

$sWhere="";

foreach(@$_SESSION[$strTableName."_asearchfor"] as $f => $sfor)

{

$strSearchFor=trim($sfor);

$strSearchFor2="";

$type=@$_SESSION[$strTableName."_asearchfortype"][$f];

if(array_key_exists($f,@$_SESSION[$strTableName."_asearchfor2"]))

$strSearchFor2=trim(@$_SESSION[$strTableName."_asearchfor2"][$f]);

if($strSearchFor!="" || true)

{

if (!$sWhere)

{

if($_SESSION[$strTableName."_asearchtype"]=="and")

$sWhere="1=1";

else

$sWhere="1=0";

}

$strSearchOption=trim($_SESSION[$strTableName."_asearchopt"][$f]);

if($where=StrWhereAdv($f, $strSearchFor, $strSearchOption, $strSearchFor2,$type))

{

if($_SESSION[$strTableName."_asearchnot"][$f])

$where="not (".$where.")";

if($_SESSION[$strTableName."_asearchtype"]=="and")

$sWhere .= " and ".$where;

else

$sWhere .= " or ".$where;

}

}

}

$strSQL = AddWhere($strSQL,$sWhere);

}
// order by

$strSQL.=" ".trim($strOrderBy);
// save SQL for use in "Export" and "Printer-friendly" pages
$_SESSION[$strTableName."_sql"] = $strSQL;
LogInfo($strSQL);
// select and display records

if(CheckSecurity(@$_SESSION["OwnerID"],"Search"))

{

// Pagination:

$numrows=GetRowCount($strSQL);

if(!$numrows)

{

$smarty->assign("rowsfound",false);

$smarty->assign("message","Non sono stati trovati Record");

}

else

{

$smarty->assign("rowsfound",true);

$smarty->assign("records_found",$numrows);

$maxRecords = $numrows;

$maxpages=ceil($maxRecords/$PageSize);

if($mypage > $maxpages)

$mypage = $maxpages;

if($mypage<1)

$mypage=1;

$maxrecs=$PageSize;

$smarty->assign("page",$mypage);

$smarty->assign("maxpages",$maxpages);
// write pagination

$smarty->assign("pagination","&lt;script language=\"JavaScript\">WritePagination(".$mypage.",".$maxpages.");

function GotoPage(nPageNumber)

{

window.location='file_list.php?goto='+nPageNumber;

}

</script>");
$strSQL.=" limit ".(($mypage-1)$PageSize).",".$PageSize;

}

$rs=db_query($strSQL,$conn);
// hide colunm headers if needed

$recordsonpage=$numrows-($mypage-1)
$PageSize;

if($recordsonpage>$PageSize)

$recordsonpage=$PageSize;

if($recordsonpage>=1)

$smarty->assign("column1show",true);

else

$smarty->assign("column1show",false);
// fill $rowinfo array

$rowinfo = array();

$shade=false;

$recno=1;

$editlink="";

$copylink="";
$data=db_fetch_array($rs);
while($data && $recno<=$PageSize)

{

$row=array();

if(!$shade)

{

$row["shadeclass"]='class="shade"';

$row["shadeclassname"]="shade";

$shade=true;

}

else

{

$row["shadeclass"]="";

$row["shadeclassname"]="";

$shade=false;

}

for($col=1;$data && $recno<=$PageSize && $col<=1;$col++)

{
// key fields

$recno++;

// detail tables

// edit page link

$editlink="";

$row[$col."editlink"]=$editlink;
$copylink="";

$row[$col."copylink"]=$copylink;

$keylink="";
// case

left (src, 4)

when '0131' then 'Palermo'

when '0141' then 'Catania'

when '0161' then 'Taranto'

when '0165' then 'Alessandria'

when '0171' then 'Asti'

when '0183' then 'Vercelli'

when '0187' then 'Aosta'

when '0321' then 'Cuneo'

when '0323 -

$value="";

$value = ProcessLargeText(GetData($data,"case

left (src, 4)

when '0131' then 'Palermo'

when '0141' then 'Catania'

when '0161' then 'Taranto'

when '0165' then 'Alessandria'

when '0171' then 'Asti'

when '0183' then 'Vercelli'

when '0187' then 'Aosta'

when '0321' then 'Cuneo'

when '0323", ""),"field=case+++left+%28src%2C+4%29+++when+%270131%27+then+%27Palermo%27++when+%270141%27+then+%27Catania%27++when+%270161%27+then+%27Taranto%27++when+%270165%27+then+%27Alessandria%27++when+%270171%27+then+%27Asti%27++when+%270183%27+then+%27Vercelli%27++when+%270187%27+then+%27Aosta%27++when+%270321%27+then+%27Cuneo%27++when+%270323".$keylink,"",MODE_LIST);

$row[$col."case_leftsrc4__when0131thenPalermo_when0141thenCatani

awhen0161thenTaranto
when0165thenAlessandria_when0171_then

Asti
when0183thenVercelliwhen0187thenAostawhen0321then__

Cuneo_when0323_value"]=$value;
// prefisso -

$value="";

$value = ProcessLargeText(GetData($data,"prefisso", ""),"field=prefisso".$keylink,"",MODE_LIST);

$row[$col."prefisso_value"]=$value;
// Totale Chiamate Perse -

$value="";

$value = ProcessLargeText(GetData($data,"Totale Chiamate Perse", ""),"field=Totale+Chiamate+Perse".$keylink,"",MODE_LIST);

$row[$col."Totale_Chiamate_Perse_value"]=$value;

$row[$col."show"]=true;

$data=db_fetch_array($rs);

}

$rowinfo[]=$row;

}

$smarty->assign("rowinfo",$rowinfo);

}
$strSQL=$_SESSION[$strTableName."_sql"];
$smarty->display("file_list.htm");

Alexey admin 1/18/2007

Mauro,
please zip and send to support@xlinesoft.com a full set of files created by PHPRunner along with your database creation script.

I'll find what's worng with your project running it on my test box.

M
mauro author 1/18/2007

Mauro,

please zip and send to support@xlinesoft.com a full set of files created by PHPRunner along with your database creation script.

I'll find what's worng with your project running it on my test box.


i sent files
Tnx for your support