ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

php variable un sql query

mrsynock 28 Jan, 2009
Hello,
Don't know if CC bug or myself mistake :

This work in a chronoform (after submitting mail):

<?php
$db =& JFactory::getDBO();
$nv_stage=$_POST['stage'];
$requete_get_maquette = 'SELECT urgences,chu,med_adulte,pedia_gyneco FROM jos_liste_stage_hospit WHERE stage="'.$nv_stage.'"';
$db->setQuery($requete_get_maquette);
$liste = $db->loadObjectList();

$le_stage = $liste[0];
echo "urg : $le_stage->urgences ";
echo "ma : $le_stage->med_adulte ";
echo "chu : $le_stage->chu ";
echo "peda_gyneco : $le_stage->pedia_gyneco ";
?>

and give me :
urg : 0 ma : 1 chu : 1 peda_gyneco : 0

But in CConnectivity I get stage not from POST but from context with {} so I change
$nv_stage=$_POST['stage'];
with
$nv_stage="{stage}";
But finely this fails et and retruns :
urg : ma : chu : peda_gyneco :
If I change "'.$nv_stage.'" with "some_const" this works !!!

I thought it was in query but
echo $db->getQuery();
returns same thing for "'.$nv_stage.'" or "some_const" :
SELECT urgences,chu,med_adulte,pedia_gyneco FROM jos_liste_stage_hospit WHERE stage="some const"

do you have some idea ?
thanks

PS : I use DB request in CConnectivity because I use data from another table that the connection use.
Max_admin 28 Jan, 2009
Hi,

that's because the code is evaluated (and so PHP is executed" before the replacement is done, instead use $row->stage

regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
mrsynock 28 Jan, 2009
first thank you for your answer.

Ichanged
$nv_stage="{stage}";
with
 $nv_stage=$row->stage;

but it doesn't change anything. Did you mean that ?
Max_admin 30 Jan, 2009
Hi, thank you, tha's what I mean yes, it will work only in the "body" box code, did you try this ?

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
mrsynock 01 Feb, 2009
come back from week-end and it works !!!

thanks lot your solution were the good one, don't known what I did last week ....
Max_admin 02 Feb, 2009
No problems!🙂

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com