Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

PHP Put variable in sql postgresql scriptcase

the code below when i put table name it work then i put variable name  {TabName}  it does not work how can i fix it

Parse error: syntax error, unexpected 'scriptcase' (T_STRING) in C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\Pong8\bla nk\index.php on line 1142


I  do with scriptcase it a php deleloping tool
sc_lookup(Dataset, "SELECT  tablename FROM pg_catalog.pg_tables
where schemaname = 'public'and tablename not like 'pong8%' order by tablename") ;

{TabName} = {Dataset[33][0]};

echo "{TabName} " ;




$sql ='INSERT INTO pong8_maintable ("timestamp8","Last","TradePrice", "TradeVolume" , "BestBid") 

SELECT 
cast(public.'.{TabName}.'"Timestamp" as timestamp) ,

cast(public.'.{TabName}.'"Last" as numeric)  ,
cast(public.'.{TabName}.'"Trade Price" as numeric)  ,  
cast(public.'.{TabName}.'"Trade Volume" as numeric),
cast(public.'.{TabName}.'"Best Bid" as numeric)
FROM Public.'.{TabName}.'  ;

Open in new window

Avatar of MrTV
MrTV
Flag of Thailand image

ASKER

This one it workbut my target is  to put variable replace pong8

$sql ='INSERT INTO pong8_maintable ("timestamp8","Last","TradePrice", "TradeVolume" , "BestBid") 

SELECT 
cast(public.pong8."Timestamp" as timestamp) ,

cast(public.pong8."Last" as numeric)  ,
cast(public.pong8."Trade Price" as numeric)  ,  
cast(public.pong8."Trade Volume" as numeric),
cast(public.pong8."Best Bid" as numeric)
FROM Public.pong8'; 



sc_exec_sql($sql);

Open in new window

Avatar of Julian Hansen
And if you replace
cast(public.'.{TabName}.'"Timestamp" as timestamp)

Open in new window

with
cast(public.'.{$TabName}.'"Timestamp" as timestamp)

Open in new window

Avatar of MrTV

ASKER

sc_lookup(Dataset, "SELECT  tablename FROM pg_catalog.pg_tables
where schemaname = 'public'and tablename not like 'pong8%' order by tablename") ;

{TabName} = {Dataset[33][0]};

echo "{TabName} " ;

$sql ='INSERT INTO pong8_maintable ("timestamp8","Last","TradePrice", "TradeVolume" , "BestBid") 

SELECT 
cast(public.gel."Timestamp" as timestamp) ,
cast(public.gel."Last" as numeric)  ,
cast(public.gel."Trade Price" as numeric)  ,  
cast(public.gel."Trade Volume" as numeric),
cast(public.gel."Best Bid" as numeric)
FROM Public.'.{TabName}; 


sc_exec_sql($sql);

Open in new window



this code is work   bur how can I change   cast(public.gel."Best Bid" as numeric)  to   cast(public. {TabName}."Best Bid" as numeric)   like last line
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial