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

PostgreSQLPHP

Avatar of undefined
Last Comment
MrTV
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
Julian Hansen
Flag of South Africa image

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
MrTV
Flag of Thailand image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of MrTV
MrTV
Flag of Thailand image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo