php-general Digest 6 Feb 2005 06:28:00 -0000 Issue 3270

Topics (messages 208116 through 208136):

Re: wait function
        208116 by: Mike
        208117 by: Jochem Maas
        208120 by: Alessandro Rosa

Re: array_map in conjunction with user_call_func_array - inconsistency
        208118 by: Jochem Maas

Problems with PHP and MySQL
        208119 by: Sarah
        208122 by: Jochem Maas
        208125 by: Bruce Douglas
        208127 by: Bruce Douglas
        208132 by: Sarah

Re: $_SERVER['REQUEST_URI'] being trimmed
        208121 by: Verdon Vaillancourt

correction to my previous mail
        208123 by: Sasidhar Kalagara

Re: Connecting To Multiple MySQL Databases
        208124 by: NathanielGuy#21
        208128 by: Tony Di Croce
        208129 by: John Holmes

Re: Trying to match two tables' data - Resolved (for now at least)
        208126 by: Alp

Where's xml in PHP5?
        208130 by: Brian V Bonini

Re: [suspicious - maybe spam] Re: [PHP] Re: mcrypt public and private key
        208131 by: Daniel Bowett

Global and Local include_path settings
        208133 by: John Nichel
        208134 by: Jason Wong
        208135 by: John Nichel

about watermark
        208136 by: yangshiqi

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
> I would write down an efficient WAIT function.
> The one I did was as follows:
> 
> function microdelay($delay) {
> $UNUSED_PORT=31238;
> @fsockopen("tcp://localhost",$UNUSED_PORT,$errno,$errstr,$delay);
> }
> 


Are you looking for something like sleep()?

http://us2.php.net/manual/en/function.sleep.php

-M

--- End Message ---
--- Begin Message --- Mike wrote:
I would write down an efficient WAIT function.
The one I did was as follows:

function microdelay($delay) {
$UNUSED_PORT=31238;
@fsockopen("tcp://localhost",$UNUSED_PORT,$errno,$errstr,$delay);
}




Are you looking for something like sleep()?

http://us2.php.net/manual/en/function.sleep.php

and for microseconds, depending on your OS + PHP version you may have access to this function:

http://us2.php.net/manual/en/function.usleep.php


-M


--- End Message ---
--- Begin Message ---
Yes, guys, SLEEP was what I was looking for.
I took up the code I showed before from such a
php site, but it did work on a linux server anyway.

I would try the alternative of SLEEP: I was not
so much aware of it.

Yours,

Alessandro





--- End Message ---
--- Begin Message ---
so nobody has any idea? I checked the bug DB btw and couldn't find anything....

Jochem Maas wrote:
listers,

I was playing around with call_user_func_array() and array_map() on
PHP 5.0.2 (cli) (built: Nov 9 2004 19:00:36) and noticed the that
calling call_user_func_array() on 'array_map' with more than 2 args
(i.e. more than just the name of the callback and array
argument that are required for 'array_map') then a numerically indexed array
is returned, where as with just the minimum 2 args the associative keys of array
are maintained:


question is have I missed something, am I doing something wrong or it this
a 'buglet'?


===========================================================================

function array_map_assoc($callback, $arr)
{
    $keys = array_keys($arr);
    $args = func_get_args();

    $arr = call_user_func_array("array_map", $args);

    /* return the fixed array */
    return $arr;
}

// couldn't figure out how else
// to use a single quote with php -r in a bash shell
$sq = chr(39);

// start array
$arr1 = array( "name" => "\"{$sq}Testing{$sq}\"",
"email" => "\"Yadda{$sq}s \"YADDa\"<script language={$sq}Testing{$sq} source={$sq}{$sq}></script>\"");


$arr2 = array_map_assoc("strip_tags", $arr1);
$arr3 = array_map_assoc("htmlentities", $arr2, array( ENT_QUOTES, ENT_QUOTES ));
$arr4 = array_map_assoc("htmlentities", $arr2);
$arr5 = array_map_assoc("strip_tags", $arr1, array( "<p>", "<p>" ));



echo "-----\n\n"; var_dump($arr1, $arr2, $arr3, $arr4, $arr5);


===========================================================================


OUTPUTS ON MACHINE:
-----
array(2) {
["name"]=>
string(11) ""'Testing'""
["email"]=>
string(63) ""Yadda's "YADDa"<script language='Testing' source=''></script>""
}
array(2) {
["name"]=>
string(11) ""'Testing'""
["email"]=>
string(17) ""Yadda's "YADDa"""
}
array(2) {
[0]=>
string(31) "&quot;&#039;Testing&#039;&quot;"
[1]=>
string(42) "&quot;Yadda&#039;s &quot;YADDa&quot;&quot;"
}
array(2) {
["name"]=>
string(21) "&quot;'Testing'&quot;"
["email"]=>
string(37) "&quot;Yadda's &quot;YADDa&quot;&quot;"
}
array(2) {
[0]=>
string(11) ""'Testing'""
[1]=>
string(17) ""Yadda's "YADDa"""
}




rgds,
Jochem


--- End Message ---
--- Begin Message ---
Hi,

I'm relatively new to PHP, but have already written a few functional web-based scripts. I recently decided to implement a MySQL-based system, but hit the following problem...

I have PHP version 5.03, and MySQL v 4.19. I downloaded and compiled both, and both work perfectly alone. However, when I run a command-line app to manipulate my database, I get the following error:

__________________________________________________________________________
[EMAIL PROTECTED]:~# ./useradmin -a -u unclebulgaria -p uberwomble
constructor called

Fatal error: Call to undefined function mysql_connect() in veep/useradmin on line 16

Fatal error: Call to undefined function mysql_close() in /veep/useradmin on line 22
[EMAIL PROTECTED]:~#
__________________________________________________________________________



You might think 'Aah! the doofus has forgotten to link MySQL into the compiled PHP interpreter'.


However, my phpinfo() page gives the following information:

__________________________________________________________________________
Configure command:

'./configure' '--with-apxs2=/opt/apache/sbin/apxs' '--prefix=/usr' '--sysconfdir=/etc/php5' '--with-dba' '--with-db4' '--with-auth' '--with-zlib' '--with-tiff' '--with-jpeg' '--with-mysql=/usr'
__________________________________________________________________________


And...

__________________________________________________________________________

MySQL-related data:

mysql
MySQL Support   enabled
Active Persistent Links         0
Active Links    0
Client API version      4.1.9
MYSQL_MODULE_TYPE       external
MYSQL_SOCKET    /tmp/mysql.sock
MYSQL_INCLUDE   -I/usr/include/mysql
MYSQL_LIBS      -L/usr/lib -lmysqlclient

Directive                       Local Value     Master Value
mysql.allow_persistent          On              On
mysql.connect_timeout           60              60
mysql.default_host              localhost       localhost
mysql.default_password          wurms           wurms
mysql.default_port              3306            3306
mysql.default_socket            no value        no value
mysql.default_user              wiggly          wiggly
mysql.max_links Unlimited       Unlimited
mysql.max_persistent            Unlimited       Unlimited
mysql.trace_mode                Off             Off
_________________________________________________________________________


Finally, the client program is:

_________________________________________________________________________

#!/usr/bin/php
<?php

class UserDB
{
        static $user='wiggly';
        static $pass='wurms';
        static $db='multimedia_access';

        private $m_link;
        private $m_live;

        function __construct()
        {
                print("constructor called\n");
                $this->m_link = mysql_connect('localhost', self::$user, 
self::$pass);
                $this->m_live = mysql_select_db(self::db);
        }

        function __destruct()
        {
                mysql_close($this->m_link);
                print("destructor called");
        }

function Add($u, $p)
{
$H = md5($u, true);
// $R = mysql_query("INSERT INTO users (userkey, user, password) values ($H, $u, $p)", $this->m_link);
$S = mysql_real_escape_string("INSERT INTO users (userkey, user, password) values ('$H', '$u', '$p')", $this->m_link);
$R = mysql_query($S, $this->m_link);
if (!$R)
{
printf("SQL query error during Add operation\n");
}
return $R;
}


        function Delete($u)
        {
                $H=md5($u, true);
                $R=mysql_query("DELETE FROM users WHERE userkey=$H");
                if ($R)
                {
                        $R=mysql_query("DELETE FROM iplist WHERE userkey=$H");
                }
                if (!$R)
                {
                        printf("SQL query error during Add operation\n");
                }
                return $R;
        }

        function Replace($u, $p)
        {
                return 0;
        }

        function Tabulate()
        {
                $R=mysql_query("SELECT user,password FROM TABLE users");
                if (!$R)
                {
                        printf("SQL query error during List operation\n");
                }

                $N=mysql_num_rows($R);

                if ($N > 0)
                {
                        while($Row = mysql_fetch_row($R))
                        {
                                foreach($Row as $K => $V)
                                {
                                        $Col = mysql_field_name($R ,$K);
                                        printf("%s='%s', ", $Col, $V);
                                }
                                printf("\n");
                        }
                }
                return $R;
        }
}

function Usage($text)
{
printf("useradmin:\n\tuseradmin (-a|-d|-r) -u <user name> -p <password>\n\n");
printf("\t-a - add given user.\n");
printf("\t-d - delete given user.\n");
printf("\t-r - replace given user.\n");
printf("\t-l - list all users and passwords in the database.\n");
printf("\n\t%s\n\n", $text);
exit(0);
}


function do_add($u, $p)
{
        $D=new UserDB();

        return $D->Add($u, $p);
}

function do_del($u)
{
        $D=new UserDB();

        return $D->Delete($u);
}

function do_rep($u, $p)
{
        $D=new UserDB();

        return $D->Replace($u, $p);
}

function do_list()
{
        $D=new UserDB();

        return $D->Tabulate();
}

function main()
{
        $password='';
        $username='';
        
        $command['a']=false;
        $command['d']=false;
        $command['r']=false;
        $command['l']=false;
        
        $cmdcount=0;
        
        $opt = getopt("ladru:p:h");
        
        foreach ($opt as $k => $v)
        {
                switch($k)
                {
                case 'h':
                        Usage("Help information.");
                        break;
                case 'p':
                        if ($v)
                        {
                                $password=$v;
                        }
                        break;
                case 'u':
                        if ($v)
                        {
                                $username=$v;
                        }
                        break;
                case 'a':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                case 'd':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                case 'r':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                case 'l':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                default:
                }
        }
        
        if ($cmdcount > 1)
        {
                Usage("You may specifiy no more than one command at a time");
        }
        else if ($cmdcount < 1)
        {
                Usage("You must specify one of add, delete, replace");
        }

if ($command['a'] == true)
{
if ($username == false || $password == false)
{
Usage("You must specify the username and password when adding an user");
}
do_add($username, $password);
}
else if ($command['r'] == true)
{
if ($username == false || $password == false)
{
Usage("You must specify the username and password when replacing an user");
}
do_del($username);
}
else if ($command['d'] == true)
{
if ($username == false)
{
Usage("You must specify the username when deleting an user");
}
else if ($password != false)
{
Usage("The password is superfluous for the delete comand");
}
do_rep($username, $password);
}
else if ($command['l'] == true)
{
if ($username != false || $password != false)
{
Usage("Superfluous arguments given to the list command");
}
do_list($username, $password);
}


        exit(0);
}

main();
--- End Message ---
--- Begin Message --- Sarah wrote:
Hi,

I'm relatively new to PHP, but have already written a few functional web-based scripts. I recently decided to implement a MySQL-based system, but hit the following problem...

I have PHP version 5.03, and MySQL v 4.19. I downloaded and compiled both, and both work perfectly alone. However, when I run a command-line app to manipulate my database, I get the following error:

__________________________________________________________________________
[EMAIL PROTECTED]:~# ./useradmin -a -u unclebulgaria -p uberwomble
constructor called

Fatal error: Call to undefined function mysql_connect() in veep/useradmin on line 16

Fatal error: Call to undefined function mysql_close() in /veep/useradmin on line 22
[EMAIL PROTECTED]:~#
__________________________________________________________________________



I _think_, given the version of MySQL you are using, you should compile in and use the mysqli extension iso of the mysql extension. ^----!

these to links may help you:

http://www.zend.com/php5/articles/php5-mysqli.php
http://be.php.net/mysqli

failing that you might want to check this page for an overview of funcs you
can use to determine exactly what is available, with more accuracy than 
phpinfo()
e.g.:

var_dump( extension_loaded("mysql"),
          extension_loaded("mysqli"),
          get_loaded_extensions(),
          get_extension_funcs ("mysql"),
          get_extension_funcs ("mysqli") );   

--- End Message ---
--- Begin Message ---
disregard if you've already done this...

you might want to do a quick php app with phpinfo, to determine if/what version 
of mysql php sees.. it's quite possible that php isn't seeing/interfacing with 
mysql. 

php needs to not only be built with a version of mysql, but the php.ini file 
also needs to be setup correctly.

-bruce


-----Original Message-----
From: Jochem Maas <[EMAIL PROTECTED]>
Sent: Feb 5, 2005 8:46 AM
To: Sarah <[EMAIL PROTECTED]>
Cc: [email protected]
Subject: Re: [PHP] Problems with PHP and MySQL

Sarah wrote:
> Hi,
> 
> I'm relatively new to PHP, but have already written a few functional 
> web-based scripts. I recently decided to implement a MySQL-based system, 
> but hit the following problem...
> 
> I have PHP version 5.03, and MySQL v 4.19. I downloaded and compiled 
> both, and both work perfectly alone. However, when I run a command-line 
> app to manipulate my database, I get the following error:
> 
> __________________________________________________________________________
> [EMAIL PROTECTED]:~# ./useradmin -a -u unclebulgaria -p uberwomble
> constructor called
> 
> Fatal error: Call to undefined function mysql_connect() in 
> veep/useradmin on line 16
> 
> Fatal error: Call to undefined function mysql_close() in /veep/useradmin 
> on line 22
> [EMAIL PROTECTED]:~#
> __________________________________________________________________________
> 

I _think_, given the version of MySQL you are using, you should compile in
and use the mysqli extension iso of the mysql extension.
                 ^----!

these to links may help you:

http://www.zend.com/php5/articles/php5-mysqli.php
http://be.php.net/mysqli

failing that you might want to check this page for an overview of funcs you
can use to determine exactly what is available, with more accuracy than 
phpinfo()
e.g.:

var_dump( extension_loaded("mysql"),
          extension_loaded("mysqli"),
          get_loaded_extensions(),
          get_extension_funcs ("mysql"),
          get_extension_funcs ("mysqli") );     

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
sarah...

rather than deal with classes/objs... (at least initially)

just create a simple php/mysql app that sets up the user/passwd/host for the 
db, and see if you can do a successful mysql_connect.... check the return/error 
codes to see if the call/code works

this will quickly tell you if you actually have php/mysql setup properly...

once you've done this... you can get into the guts of your app, to determine 
where the prob is....

-bruce


-----Original Message-----
From: Sarah <[EMAIL PROTECTED]>
Sent: Feb 5, 2005 7:41 AM
To: [email protected]
Subject: [PHP] Problems with PHP and MySQL

Hi,

I'm relatively new to PHP, but have already written a few functional 
web-based scripts. I recently decided to implement a MySQL-based system, 
but hit the following problem...

I have PHP version 5.03, and MySQL v 4.19. I downloaded and compiled 
both, and both work perfectly alone. However, when I run a command-line 
app to manipulate my database, I get the following error:

__________________________________________________________________________
[EMAIL PROTECTED]:~# ./useradmin -a -u unclebulgaria -p uberwomble
constructor called

Fatal error: Call to undefined function mysql_connect() in 
veep/useradmin on line 16

Fatal error: Call to undefined function mysql_close() in /veep/useradmin 
on line 22
[EMAIL PROTECTED]:~#
__________________________________________________________________________


You might think 'Aah! the doofus has forgotten to link MySQL into the 
compiled PHP interpreter'.

However, my phpinfo() page gives the following information:

__________________________________________________________________________
Configure command:

'./configure' '--with-apxs2=/opt/apache/sbin/apxs' '--prefix=/usr' 
'--sysconfdir=/etc/php5' '--with-dba' '--with-db4' '--with-auth' 
'--with-zlib' '--with-tiff' '--with-jpeg' '--with-mysql=/usr'
__________________________________________________________________________

And...

__________________________________________________________________________

MySQL-related data:

mysql
MySQL Support   enabled
Active Persistent Links         0
Active Links    0
Client API version      4.1.9
MYSQL_MODULE_TYPE       external
MYSQL_SOCKET    /tmp/mysql.sock
MYSQL_INCLUDE   -I/usr/include/mysql
MYSQL_LIBS      -L/usr/lib -lmysqlclient

Directive                       Local Value     Master Value
mysql.allow_persistent          On              On
mysql.connect_timeout           60              60
mysql.default_host              localhost       localhost
mysql.default_password          wurms           wurms
mysql.default_port              3306            3306
mysql.default_socket            no value        no value
mysql.default_user              wiggly          wiggly
mysql.max_links Unlimited       Unlimited
mysql.max_persistent            Unlimited       Unlimited
mysql.trace_mode                Off             Off
_________________________________________________________________________


Finally, the client program is:

_________________________________________________________________________

#!/usr/bin/php
<?php

class UserDB
{
        static $user='wiggly';
        static $pass='wurms';
        static $db='multimedia_access';

        private $m_link;
        private $m_live;

        function __construct()
        {
                print("constructor called\n");
                $this->m_link = mysql_connect('localhost', self::$user, 
self::$pass);
                $this->m_live = mysql_select_db(self::db);
        }

        function __destruct()
        {
                mysql_close($this->m_link);
                print("destructor called");
        }

        function Add($u, $p)
        {
                $H = md5($u, true);
                // $R = mysql_query("INSERT INTO users (userkey, user, 
password) 
values ($H, $u, $p)", $this->m_link);
                $S = mysql_real_escape_string("INSERT INTO users (userkey, 
user, 
password) values ('$H', '$u', '$p')", $this->m_link);
                $R = mysql_query($S, $this->m_link);
                if (!$R)
                {
                        printf("SQL query error during Add operation\n");
                }
                return $R;
        }

        function Delete($u)
        {
                $H=md5($u, true);
                $R=mysql_query("DELETE FROM users WHERE userkey=$H");
                if ($R)
                {
                        $R=mysql_query("DELETE FROM iplist WHERE userkey=$H");
                }
                if (!$R)
                {
                        printf("SQL query error during Add operation\n");
                }
                return $R;
        }

        function Replace($u, $p)
        {
                return 0;
        }

        function Tabulate()
        {
                $R=mysql_query("SELECT user,password FROM TABLE users");
                if (!$R)
                {
                        printf("SQL query error during List operation\n");
                }

                $N=mysql_num_rows($R);

                if ($N > 0)
                {
                        while($Row = mysql_fetch_row($R))
                        {
                                foreach($Row as $K => $V)
                                {
                                        $Col = mysql_field_name($R ,$K);
                                        printf("%s='%s', ", $Col, $V);
                                }
                                printf("\n");
                        }
                }
                return $R;
        }
}

function Usage($text)
{
        printf("useradmin:\n\tuseradmin (-a|-d|-r) -u <user name> -p 
<password>\n\n");
        printf("\t-a - add given user.\n");
        printf("\t-d - delete given user.\n");
        printf("\t-r - replace given user.\n");
        printf("\t-l - list all users and passwords in the database.\n");
        printf("\n\t%s\n\n", $text);
        exit(0);
}

function do_add($u, $p)
{
        $D=new UserDB();

        return $D->Add($u, $p);
}

function do_del($u)
{
        $D=new UserDB();

        return $D->Delete($u);
}

function do_rep($u, $p)
{
        $D=new UserDB();

        return $D->Replace($u, $p);
}

function do_list()
{
        $D=new UserDB();

        return $D->Tabulate();
}

function main()
{
        $password='';
        $username='';
        
        $command['a']=false;
        $command['d']=false;
        $command['r']=false;
        $command['l']=false;
        
        $cmdcount=0;
        
        $opt = getopt("ladru:p:h");
        
        foreach ($opt as $k => $v)
        {
                switch($k)
                {
                case 'h':
                        Usage("Help information.");
                        break;
                case 'p':
                        if ($v)
                        {
                                $password=$v;
                        }
                        break;
                case 'u':
                        if ($v)
                        {
                                $username=$v;
                        }
                        break;
                case 'a':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                case 'd':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                case 'r':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                case 'l':
                        $command[$k]=true;
                        $cmdcount += 1;
                        break;
                default:
                }
        }
        
        if ($cmdcount > 1)
        {
                Usage("You may specifiy no more than one command at a time");
        }
        else if ($cmdcount < 1)
        {
                Usage("You must specify one of add, delete, replace");
        }

        if ($command['a'] == true)
        {
                if ($username == false || $password == false)
                {
                        Usage("You must specify the username and password when 
adding an user");
                }
                do_add($username, $password);
        }       
        else if ($command['r'] == true)
        {
                if ($username == false || $password == false)
                {
                        Usage("You must specify the username and password when 
replacing an 
user");
                }
                do_del($username);
        }       
        else if ($command['d'] == true)
        {
                if ($username == false)
                {
                        Usage("You must specify the username when deleting an 
user");
                }
                else if ($password != false)
                {
                        Usage("The password is superfluous for the delete 
comand");
                }
                do_rep($username, $password);
        }       
        else if ($command['l'] == true)
        {
                if ($username != false || $password != false)
                {
                        Usage("Superfluous arguments given to the list 
command");
                }
                do_list($username, $password);
        }       

        exit(0);
}

main();

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message --- Fixed. It was a combination of the commandline version of PHP 503 not building by default, *and* my having to use the 'mysqli' interface as you suggested. The object interface to mysql works quite nicely.

Many thanks,

Sarah
--- End Message ---
--- Begin Message --- On 3-Feb-05, at 3:46 PM, Richard Lynch wrote:

Your very problem is that you are NOT encoding the URL data, so the browser is trying to do it for you, only it can't be sure whether & is supposed to be data or is supposed to separate your URL arguments.

http://php.net/urlencode

Thanks for the tip re urlencode(). I had tried that before I posted, but I was doing it at the wrong side of the process. I was using it in my switch file on the referrer being returned to location: instead of on the link I was passing to my switch file. When I changed my link to...

<a href="/switch.php?userLangChoice=fr&amp;sender=<?php echo urlencode($_SERVER['REQUEST_URI']); ?>">French</a>

...the problem was fixed. DOH!


You may also want to just include the switch.php whenever userLangChoice
is set in the URL:


----------- langchoic.inc -------------
<?php
  if (isset($_GET['userLangChoice'])){
    setCookie($_GET['userLangChoice']);
  }
?>

You can simply: <?php include 'langchoice.inc'?> on every page or in a
globals file you already include, and then you're not wasting a bunch of
HTTP connections bouncing around with the header or worrying about your
URL getting munged.


<?php
  include 'langchoice.inc';
  echo "<a href=\"$_SERVER[PHP_SELF]?userLangChoice=fr\">French</a>";
  echo "<a href=\"$_SERVER[PHP_SELF]?userLangChoice=en\">English</a>";
?>

I tried a few quick tests with this method and variations of it. I could get it to set a cookie like '[en] => ' or '[fr] => ' but I could not get it to set a cookie like '[userLang] => en'. Even if I worked that out though, there is a disadvantage to this approach, in that (AFAIK) the page has to be refreshed before the server will be aware of the new cookie value on the client, not desirable in this situation where I'm offering bilingual content.


My thoughts in using the switch.php file was to set the cookie, make the server aware of it so it can deliver appropriate content, and return to the URL intact at the end of the process, without any new vars in it.

With your reminder about urlencode, this is all playing nicely now.

Thanks,
verdon


Verdon Vaillancourt wrote:
I am trying to build a simple mechanism to allow visitors to set a site
preference (stored in a cookie) by clicking on a link. I want the
cookie set and the original page reloaded with the new cookie set, when
a visitor clicks on the link.


My link looks like this...

<a href="/switch.php?userLangChoice=fr&amp;sender=<?php echo
$_SERVER['REQUEST_URI']; ?>">French</a>

My file switch.php looks like this...

<?php

        setcookie("userLang", $userLangChoice);

     if ($sender == "")
        $sender = "index.php";
     else
        $sender = "$sender";

      header("location:".$sender);

?>

Now, for the most part this works fine, but in some cases, my referring
URL ($sender) is being truncated. Simple URLs such as
'/listingsearch.php?Category%5B%5D=Hunting' work fine, although it is
being returned as '/listingsearch.php?Category[]=Hunting'. More complex
URLs like
'/listingsearch.php?
Accommodation%5B%5D=Outpost&Category%5B%5D=Fishing&Region%5B%5D=North-
West' are being truncated at the first variable down to
'/listingsearch.php?Accommodation[]=Outpost'


Is there something I can do to make sure the referring URL is not
truncated and it would also be nice if it was left alone and not
encoded or decoded.

--- End Message ---
--- Begin Message ---
hi Geeks!!!

       I am sorry that there are some changes to my previous mail to the group.

As of my prev mail, It is OU Eng College event and LUG, Hyd is only
Supporting for the event Voluntarily. we are in no way sponsoring for
the event.

OU Eng college Students are conducting their annual techfest and in
which they had an event called LUG Festival on 19th of February. they
had asked for the speakers from LUG, Hyderabad and some of our luggies
are voluntarily supporting the event with some sessions and workshops.

They need  a session on LAMP and so if  the members of this group can
support us with ur  voluntary participation that wld be of great help
for the students particpating in the event.

regards
sasi

--- End Message ---
--- Begin Message ---
Worked like a charm, thanks!
--nathan


On Thu, 03 Feb 2005 20:33:17 -0700, Dan Trainor <[EMAIL PROTECTED]> wrote:
> NathanielGuy#21 wrote:
> > I know this may be slightly off topic for a PHP listserv but I cant
> > find my answer anywhere else.  I start off generating a page connected
> > to one database as a certain user and I call a script that requires a
> > connection to a second database as a different user.  Is there any way
> > I could open that connection while maintaining the current one aswell?
> >  The connection of the script is opend and closed before any more of
> > the other page is generated.  Im not sure how to go about solving this
> > problem other than rewriting my script.  Any ideas?
> >
> > --nathan
> >
> 
> I'm a bit new myself, but why not call the resources seperate names?
> 
> $sql1 = mysql_connect($host1, $user1, $pass1);
> 
> $sql2 = mysql_connect($host2, $user2, $pass2);
> 
> Hope that helps
> -dant
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
http://www.blacknute.com/

--- End Message ---
--- Begin Message ---
OK... Here's a slightly different, but related question...

Can database connection resources be serialiazed and re-used in a
different script invocation? For example, can I open a DB connection,
assign it to a $_SESSION[] variable and then later use it on a
different page? Somehow, I doubt it...


On Sat, 5 Feb 2005 11:34:01 -0600, NathanielGuy#21 <[EMAIL PROTECTED]> wrote:
> Worked like a charm, thanks!
> --nathan
> 
> 
> On Thu, 03 Feb 2005 20:33:17 -0700, Dan Trainor <[EMAIL PROTECTED]> wrote:
> > NathanielGuy#21 wrote:
> > > I know this may be slightly off topic for a PHP listserv but I cant
> > > find my answer anywhere else.  I start off generating a page connected
> > > to one database as a certain user and I call a script that requires a
> > > connection to a second database as a different user.  Is there any way
> > > I could open that connection while maintaining the current one aswell?
> > >  The connection of the script is opend and closed before any more of
> > > the other page is generated.  Im not sure how to go about solving this
> > > problem other than rewriting my script.  Any ideas?
> > >
> > > --nathan
> > >
> >
> > I'm a bit new myself, but why not call the resources seperate names?
> >
> > $sql1 = mysql_connect($host1, $user1, $pass1);
> >
> > $sql2 = mysql_connect($host2, $user2, $pass2);
> >
> > Hope that helps
> > -dant
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> http://www.blacknute.com/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Send REAL USPS letters from the Web!
http://www.quickymail.com

--- End Message ---
--- Begin Message --- Tony Di Croce wrote:
OK... Here's a slightly different, but related question...

Can database connection resources be serialiazed and re-used in a
different script invocation? For example, can I open a DB connection,
assign it to a $_SESSION[] variable and then later use it on a
different page? Somehow, I doubt it...

No. The connection is automatically closed at the end of the script if you don't do it yourself.


--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
I have solved it through a sort of nested loop.

print '<table width="600" border="0" cellspacing="0" cellpadding="0"><tr>';

$x = 0;
while ($x < $colcnt) {
 $coltitle = mysql_result($prccols,$x,"colhdr");
 print '<td>'.$coltitle.'</td>';
 $x++;
 }

print '</tr>';
$i = 1;
while ($i <= $pricing_details) {
 print '<tr>';
 $c=0;
 while ($c < $colcnt) {
  print '<input type="hidden" name="tourtype" value="'.$tourtype.'">';
  print '<input type="hidden" name="tour_id" value="'.$tour_id.'">';
  print '<input type="hidden" name="tourid[]" value="'.$tour_id.'">';
  print '<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">';
  print '<input type="text" name="prcdet[]" size="20">';
  print '</b></font></td>';
  $c++;
  }
 Print '</tr>';
 $i++;
 }
print '</tr></table>';

Thanks anyway.

Alp

"Alp" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi experts,
>
> Here's the scenario:
> - 3 lines of data is present in a table
> - 2 lines of detail lines (corresponding to the above) are needed to be
> entered into a second table
>
> Result needed is:
> table1line1    table1line2    table1line3 (as column headers)
> table2line1    table2line2    table2line3 (as first line of detail)
> table2line4    table2line5    table2line6 (as second line of detail)
>
> I might be in a wrong approach in accomplising this and would highly
> appreciate any corrections. In short, column header data is entered into a
> table, then number of detail lines are obtained (in general, i.e. 2), the
> display should show 2 lines of input boxes under each header text in the
> browser for data entry into these detail lines.
>
> Clear as mud? Its getting there for me slowly...
>
> Thanks in advance.
>
> Alp

--- End Message ---
--- Begin Message ---
Just compiled PHP5 usign --enable-xml (though I see it is supposed to be
enabled by defaut however I'm getting 'call to undefined function'
errors now.

Fatal error: Call to undefined function xml_parser_create() in
bla/bla/bla on line xxx

phpinfo(): http://gfx-design.com/test/

Apache is 2.x

--- End Message ---
--- Begin Message --- Richard Lynch wrote:
Daniel Bowett wrote:

Marek Kilimajer wrote:

Daniel Bowett wrote:


Hi,

I have been reading up on the mcrypt function. Is it possible to use
it with a public and private key pair or just with a single key?

Cheers.


mcrypt supports only single key


Is there anything out there that supports public/private key other than using gpg through the command line?


http://php.net/ssh2 MIGHT have what you need...


This isn't really what I am after. I need to store some data encrypted in a database on a web server and then later download it and decrypt it. Hence why I think a public/private key is more secure.

--- End Message ---
--- Begin Message --- Hey, I'm running a box which hosts quite a few virtual hosts, and I want to configure it to where all vhosts have access to a global include directory (for things like PEAR and Smarty), as well as access to a local include directory for each virtual host. My current config has me setting paths like this inside of each vhost directive in Apache....

php_value include_path ".:/path/to/global:/path/to/local"

What I'm wondering is if anyone knows of a way to set the global path in one location, and 'append' the local path in the vhosts directive. Kind of like on a *nix system where I can set a global path once...

PATH=/usr/bin

And append to that somewhere else on the system....

PATH=$PATH:/usr/local/bin

I've tried setting the global path in the php.ini, and the local path in both the httpd.conf and .htaccess file, but both of those overwrite the global path, and since PHP values do not exist outside of php, I can't set it like above.

Not really a problem if there isn't a way to do it dynamically...it would just be nice to 'centralize' my global include. TIA

--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
On Sunday 06 February 2005 07:27, John Nichel wrote:
> Hey, I'm running a box which hosts quite a few virtual hosts, and I
> want to configure it to where all vhosts have access to a global
> include directory (for things like PEAR and Smarty), as well as access
> to a local include directory for each virtual host.  My current config
> has me setting paths like this inside of each vhost directive in
> Apache....
>
> php_value include_path ".:/path/to/global:/path/to/local"
>
> What I'm wondering is if anyone knows of a way to set the global path
> in one location, and 'append' the local path in the vhosts directive. 

One method (not sure whether it's the best or most efficient) is to use an 
auto_prepend_file to set the local component(s) of the path.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts

--- End Message ---
--- Begin Message --- Jason Wong wrote:
On Sunday 06 February 2005 07:27, John Nichel wrote:

Hey, I'm running a box which hosts quite a few virtual hosts, and I
want to configure it to where all vhosts have access to a global
include directory (for things like PEAR and Smarty), as well as access
to a local include directory for each virtual host.  My current config
has me setting paths like this inside of each vhost directive in
Apache....

php_value include_path ".:/path/to/global:/path/to/local"

What I'm wondering is if anyone knows of a way to set the global path
in one location, and 'append' the local path in the vhosts directive.


One method (not sure whether it's the best or most efficient) is to use an auto_prepend_file to set the local component(s) of the path.


Yeah, I was thinking about that route, but just as I was reading your response, I thought up a new 'problem' for myself. Even if I set it in the httpd.conf, a .htaccess, or in a file that I auto_prepend, if the end user on one of the vhosts uses the ini_set(), it will be overwritten. I could turn off the ability for users to set a local include path, but I'd like to give them as much *freedom* as possible. It's not an issue at the moment, since I'm the only one who does any php code on the box (I have a 'designer' who helps me out from time to time, but he doesn't mess with any PHP), but sooner or later, I'm probably going to pick up a customer who wants to handle his/her own code. I guess if I'm feeling really brave, I could brush up on my C code, and modify the source so that ini_set() will append, and not overwrite the include path.


--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
Does anyone can recommend some app about watermark(open source)?

Coz I want to use it in our production, so I must use sth which is certified
very safely and fast.

Thx.

 

Best regards,

Yang Shiqi

 

 

 

 


--- End Message ---

Reply via email to