Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP Put variable in sql  postgresql scriptcase

Posted on 2016-10-26
5
Medium Priority
?
169 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 59

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 59

Accepted Solution

by:
Julian Hansen earned 2000 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

Independent Software Vendors: 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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

604 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