PHP Classes

defaultcols with a variable

Recommend this page to a friend!

      DrasticTools  >  All threads  >  defaultcols with a variable  >  (Un) Subscribe thread alerts  
Subject:defaultcols with a variable
Summary:defaultcols option with php variable is not OK
Messages:5
Author:Coutolleau yves
Date:2009-06-22 09:47:16
Update:2009-07-01 08:27:45
 

  1. defaultcols with a variable   Reply   Report abuse  
Picture of Coutolleau yves Coutolleau yves - 2009-06-22 09:47:16
hello,
I'm trying using the "defaultcols" option with a php variable.
with "defaultcols" => array("col1" => "test") the result is OK (1 row displayed ).
but with "defaultcols" => array (col1" => "$var_test" ) the result is not OK (no row displayed )
(same request , with the ?op=vm option: the number of row is equal to 1 !)

thanks for your help


  2. Re: defaultcols with a variable   Reply   Report abuse  
Picture of dd dd - 2009-06-25 10:00:42 - In reply to message 1 from Coutolleau yves
Hi yves,

One thing that I see in your code which could cause the problem is that the variable is between quotes, which makes it a string instead of a variable that is being parsed. So maybe you could try to replace:
"defaultcols" => array (col1" => "$var_test" )
with
"defaultcols" => array (col1" => $var_test )

Hope this helps,

regards,
DrasticData

  3. Re: defaultcols with a variable   Reply   Report abuse  
Picture of Coutolleau yves Coutolleau yves - 2009-06-29 08:19:01 - In reply to message 2 from dd
Hi dd,
thank you for your response, but the problem is the same.
I've tried to use the "$_REQUEST["myparameter"];" in the class, as this:

************begin of code *******************
"* If you pass multiple parameters copy the line multiple times
*
* $myparameter = $_REQUEST["myparameter"];
*/
if (isset($_REQUEST["login"])) { $this->login_user = $_REQUEST["login"];
}
else {
$this->login_user = "default_user";
}

***************** and this: ************

class mysrc extends drasticSrcMySQL {
protected function select(){
$res = mysql_query(" SELECT * from $this->table where realname = '$this->login_user' ". $this->orderbystr, $this->conn) or die(" SELECT * from $this->table ". $this->wherestr . $this->orderbystr . mysql_error());
return ($res);
}
protected function metadata(){
$res = mysql_query(" SELECT * FROM $this->table LIMIT 1 " . $this->orderbystr, $this->conn) or die(mysql_error());
return ($res);
}
}
**********end of code ***********

the "default_user" line is always displayed, even for the request
test.php?login=another_user


have you got an idea ?
best regards ;
yves






  4. Re: defaultcols with a variable   Reply   Report abuse  
Picture of dd dd - 2009-06-29 19:46:21 - In reply to message 3 from Coutolleau yves
Hi Yves,

The
$myparameter = $_REQUEST["myparameter"];
line is meant to be used when you pass a variable from the calling javascript to the server-side .php class.
So this might be what you want to do, but then you have to use the 'addparams' variable (see exampleGrid9) to pass your variable from the javascript.

The reason that the http://test.php?login=another_user
does not work is that it calls test.php which calls javascript which calls test.php and the variable login must be transmitted from php to javascript to php i suppose.
It's a bit difficult to analyze of course without having the complete code.
If this does not work out for you, you can send your code to [email protected] and we'll have a closer look.

regards,
DrasticData

  5. Re: defaultcols with a variable   Reply   Report abuse  
Picture of Coutolleau yves Coutolleau yves - 2009-07-01 08:27:45 - In reply to message 4 from dd
hello DD,
starting back with example 9, this work fine now !

thank you for your help

yves