|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
JF1980 Smarty Rookie
Joined: 18 May 2003 Posts: 19
|
Posted: Mon Jun 16, 2003 9:40 pm Post subject: Assigning variables within IF blocks? |
|
|
Is there a problem doing this? For some reason in the below code, the notknown template displays variables from $trans.whatever but the known template does not. Driving me mad! lol
Code: |
$transrow = $transresult->fetchRow(DB_FETCHMODE_ASSOC);
//if success then do the shit
if ($transrow['status']=="SUCCESS"){
//query to see if already a user
$email=$transrow['payer_email'];
$usersql="SELECT * FROM user WHERE email='$email'";
$userresult = $db->query($usersql);
if (DB::isError($userresult)) {
die ($userresult->getMessage());
}
$numrows = $userresult->numRows($userresult);
//if numrows is 0 user doesn't exist post will be to self and will have flag to insert
if ($numrows==0){
//show not exist template
$smarty->assign('trans', $transrow);
$mainframe="notknown.tpl";
}
//else is a user so post forwards to cycle
else {
//show exists template
$userrow = $userresult->fetchRow(DB_FETCHMODE_ASSOC);
//run cycle.php
$userid=$userrow['userid'];
$productid=$transrow['productid'];
$quantity=$transrow['quantity'];
include ('prodcycle.php');
$smarty->assign('trans', $transrow);
$mainframe="known.tpl";
$smarty->assign('user', $userrow);
}
}
|
Also $user.whatever does show ok in known.tpl it's very weird.
Any ideas? |
|
Back to top |
|
seņor64 Smarty n00b
Joined: 16 Jun 2003 Posts: 3 Location: boston
|
Posted: Tue Jun 17, 2003 1:59 pm Post subject: |
|
|
hello:
I dont see anything wrong with that code except the possibility that whatever is in prodcycle.php could be zapping your $transrow. Try print_r($transrow) just before you give it to $smarty->assign(), make sure its still there.
Smarty's debugging flag might also be useful. Hope that helps! _________________ don't sweat the petty things, and don't pet the sweaty things -- George Carlin |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Jun 17, 2003 2:05 pm Post subject: |
|
|
I'm unfamiliar with this DB wrapper but this looks suspicious:
$numrows = $userresult->numRows($userresult); |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|