Solved

PHP Put variable in sql  postgresql scriptcase

Posted on 2016-10-26
5
100 Views
Last Modified: 2016-10-28
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

0
Comment
Question by:teera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:teera
ID: 41861578
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

0
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41861774
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

0
 

Author Comment

by:teera
ID: 41861892
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
0
 
LVL 56

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 41861914
I am not familiar with scriptface but according to their documents it appears you can use PHP style variable notation in the script i.e. use {$TabName} instead of {TabName}
0
 

Assisted Solution

by:teera
teera earned 0 total points
ID: 41864866
I try   below one it work

$table = {TabName} ;
echo "$table";

$sql ='INSERT INTO pong8_maintable ("filname","timestamp8","Last","TradePrice", "TradeVolume" , "BestBid", "BidSize", "BestAsk","AskSize" ,"Turnover" ,"CalcVWAP" ,"Flow" ,"TradeFlags"

) 

SELECT
'.$table.' ,
cast(public.'.$table.'."Timestamp" as timestamp) ,
cast(public.'.$table.'."Last" as numeric)  ,
cast(public.'.$table.'."Trade Price" as numeric)  , 

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question