Solved

PHP Put variable in sql  postgresql scriptcase

Posted on 2016-10-26
5
30 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
  • 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 51

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 51

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now