|
Posted by Matt Madrid on 08/06/07 17:00
Bob Bedford wrote:
> Hi all,
>
> I've a problem and can't resolve it.
>
> I've a include.inc.php file with only line is a huge query. to make it
> simple, the query is $query = "select * from xxx where mode = ".$mode
>
> Now, this file is included in an other PHP form. Here is the code:
>
> $mode = 1;
> mysql_query($query...
> $mode = 2;
> mysql_query($query
>
> the first is OK, but the second isn't ok, it still uses the $mode = 1.
>
> Why ? how to fix it ?
> Bob
>
>
$query will have the value of $mode as it was when you first included the file.
Changing $mode later won't change what's in $query.
The easiest way to do what you want is to use sprintf()
$query = "select * from xxx where mode = %d";
$mode = 1;
mysql_query(sprintf($query,$mode));
$mode = 2;
mysql_query(sprintf($query,$mode));
HTH..
Matt M.
Navigation:
[Reply to this message]
|