php-general Digest 22 Jul 2009 07:41:20 -0000 Issue 6243

Topics (messages 295637 through 295658):

Re: Converting SQL Dialects
        295637 by: Ashley Sheridan
        295640 by: Matt Neimeyer
        295641 by: Andrew Ballard
        295657 by: Paul M Foster

Re: Search Query on two tables not working (RESOLVED)
        295638 by: Miller, Terion

Re: PHP and FoxPro
        295639 by: Matt Neimeyer
        295642 by: Floyd Resler

Re: RFC/Survey for Our Newer Folks (Including Lurkers)
        295643 by: Shawn McKenzie

Re: A prepared statements question
        295644 by: Shawn McKenzie

Re: How to set find pathes for PHP CLI?
        295645 by: Shawn McKenzie

Doubt regarding session_destroy() in PHP 5
        295646 by: Guruprasad
        295647 by: Devendra Jadhav
        295648 by: Phpster
        295649 by: Floyd Resler
        295650 by: Guruprasad
        295652 by: Devendra Jadhav
        295653 by: Lenin

Back again with query problems and row problems
        295651 by: Miller, Terion
        295654 by: Jim Lucas

newbie - Is there a calendar module for date entry?
        295655 by: cool.hosting4days.com
        295656 by: Jonathan Tapicer

Re: Newbie: Composition by Association - Pagination Class general question.
        295658 by: MEM

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
> Has anyone come across / written a script that will convert one
> "flavor" or Dialect of SQL to another?
> 
> I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.
> 
> For the most part the problems are converting VFP functions to the
> equivalent SQL. For example, Visual FoxPro has a function inlist()
> that is used like inlist(X,1,2,3) which converts to the MySQL query "X
> IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
> stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
> 0000-00-00 (or the VFP equivalent anyways for dates), False (for
> Boolean), 0 (for Numeric) are considered empty without needing to
> know the data type. So that starts getting a lot more complex since I'd
> need to check the data type of the field in the "right" table... to be
> able to convert it to something like (X is null OR X="") or (X is null
> OR x=0) etc...
> 
> These are for customer "stored" queries... I've already manually
> converted "system" queries and I'm frustrated to the point of giving
> up and adding a column "untested" and let the end user figure it out
> but that seems bad from the standpoint of "lazy" and "poor customer
> experience".
> 
> Thanks!
> 
> Matt
> 
> P.S. I'm also going to post this to the MySQL general list but my fear
> is that they MIGHT say "We only know MySQL so we can't help you with
> that other DBMS" I'm hoping that by posting here someone might say
> "well it's not to MySQL but I ran script XYZ to convert my VFP to
> PostgreSQL..." or similar.
> 

I'm not sure it's as easy as you think it might be. As you get more into
the various flavours of SQL, you notice their little idiosyncrasies that
only exist within that one particular language branch. As such, it's
often a task best left to people to try and convert from one to the
other, rather than leave it to a machine. How complex are the queries
that you are trying to convert anyway?

Thanks
Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
Um... It depends? :) These are customer entered queries and vary based
on the end user and the customizations they have. It could be as
simple as WHERE inlist(SalesPerson,"Bob","Bill","Fred") OR it could be
something 12 lines long that pulls in criteria from multiple tables
each of those with their own criteria.

And by easy I meant simply that I would feel comfortable hacking
together something to handle inlist(x,1,2,3) and change it to "X in
(1,2,3)" it's the "rest" that worries me.

Having slept on it, I'm probably going to write something that
converts IN, checks for a list of "forbidden" words and then flags the
resulting updated query if it contains any of those words. This way I
can catch some of the low hanging fruit.

My hope is that if X% of queries don't contain foxpro specific
functions, and IN auto-conversions covers another X% of upgrades, and
auto-convert FunctionX (whatever it is...) gives us another X% of
upgrades... that this will result in a hopefully small number of saved
queries that are flagged for manual upgrading. (And not be so painful
in development that it still nets us saved time)

Matt

On Tue, Jul 21, 2009 at 1:54 PM, Ashley
Sheridan<a...@ashleysheridan.co.uk> wrote:
> On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
>> Has anyone come across / written a script that will convert one
>> "flavor" or Dialect of SQL to another?
>>
>> I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.
>>
>> For the most part the problems are converting VFP functions to the
>> equivalent SQL. For example, Visual FoxPro has a function inlist()
>> that is used like inlist(X,1,2,3) which converts to the MySQL query "X
>> IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
>> stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
>> 0000-00-00 (or the VFP equivalent anyways for dates), False (for
>> Boolean), 0 (for Numeric) are considered empty without needing to
>> know the data type. So that starts getting a lot more complex since I'd
>> need to check the data type of the field in the "right" table... to be
>> able to convert it to something like (X is null OR X="") or (X is null
>> OR x=0) etc...
>>
>> These are for customer "stored" queries... I've already manually
>> converted "system" queries and I'm frustrated to the point of giving
>> up and adding a column "untested" and let the end user figure it out
>> but that seems bad from the standpoint of "lazy" and "poor customer
>> experience".
>>
>> Thanks!
>>
>> Matt
>>
>> P.S. I'm also going to post this to the MySQL general list but my fear
>> is that they MIGHT say "We only know MySQL so we can't help you with
>> that other DBMS" I'm hoping that by posting here someone might say
>> "well it's not to MySQL but I ran script XYZ to convert my VFP to
>> PostgreSQL..." or similar.
>>
>
> I'm not sure it's as easy as you think it might be. As you get more into
> the various flavours of SQL, you notice their little idiosyncrasies that
> only exist within that one particular language branch. As such, it's
> often a task best left to people to try and convert from one to the
> other, rather than leave it to a machine. How complex are the queries
> that you are trying to convert anyway?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>

--- End Message ---
--- Begin Message ---
On Tue, Jul 21, 2009 at 2:13 PM, Matt Neimeyer<m...@neimeyer.org> wrote:
> Um... It depends? :) These are customer entered queries and vary based
> on the end user and the customizations they have. It could be as
> simple as WHERE inlist(SalesPerson,"Bob","Bill","Fred") OR it could be
> something 12 lines long that pulls in criteria from multiple tables
> each of those with their own criteria.
>
> And by easy I meant simply that I would feel comfortable hacking
> together something to handle inlist(x,1,2,3) and change it to "X in
> (1,2,3)" it's the "rest" that worries me.
>
> Having slept on it, I'm probably going to write something that
> converts IN, checks for a list of "forbidden" words and then flags the
> resulting updated query if it contains any of those words. This way I
> can catch some of the low hanging fruit.
>
> My hope is that if X% of queries don't contain foxpro specific
> functions, and IN auto-conversions covers another X% of upgrades, and
> auto-convert FunctionX (whatever it is...) gives us another X% of
> upgrades... that this will result in a hopefully small number of saved
> queries that are flagged for manual upgrading. (And not be so painful
> in development that it still nets us saved time)
>
> Matt

You might even be able to convert EMPTY(X) to COALESCE(X, '') = ''.
MySQL seems to be pretty forgiving with its implicit type-casting.

Andrew

--- End Message ---
--- Begin Message ---
On Tue, Jul 21, 2009 at 06:54:35PM +0100, Ashley Sheridan wrote:

> On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
> > Has anyone come across / written a script that will convert one
> > "flavor" or Dialect of SQL to another?
> >
> > I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.
> >
> > For the most part the problems are converting VFP functions to the
> > equivalent SQL. For example, Visual FoxPro has a function inlist()
> > that is used like inlist(X,1,2,3) which converts to the MySQL query "X
> > IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
> > stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
> > 0000-00-00 (or the VFP equivalent anyways for dates), False (for
> > Boolean), 0 (for Numeric) are considered empty without needing to
> > know the data type. So that starts getting a lot more complex since I'd
> > need to check the data type of the field in the "right" table... to be
> > able to convert it to something like (X is null OR X="") or (X is null
> > OR x=0) etc...
> >
> > These are for customer "stored" queries... I've already manually
> > converted "system" queries and I'm frustrated to the point of giving
> > up and adding a column "untested" and let the end user figure it out
> > but that seems bad from the standpoint of "lazy" and "poor customer
> > experience".
> >
> > Thanks!
> >
> > Matt
> >
> > P.S. I'm also going to post this to the MySQL general list but my fear
> > is that they MIGHT say "We only know MySQL so we can't help you with
> > that other DBMS" I'm hoping that by posting here someone might say
> > "well it's not to MySQL but I ran script XYZ to convert my VFP to
> > PostgreSQL..." or similar.
> >
> 
> I'm not sure it's as easy as you think it might be. As you get more into
> the various flavours of SQL, you notice their little idiosyncrasies that
> only exist within that one particular language branch. As such, it's
> often a task best left to people to try and convert from one to the
> other, rather than leave it to a machine. How complex are the queries
> that you are trying to convert anyway?

I have to agree with Ash here. I was a FoxPro 2.6a DOS programmer (just
at the beginning of VFP). We hired a programmer who did a lot of his
queries in FoxPro's crippled version of SQL, but the rest of us just
used regular FoxPro for queries. Remembering what FoxPro SQL was like,
and now having worked with MySQL and PostgreSQL, I wouldn't wish the
conversion of one SQL dialect to another on anyone.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Yep, sure was the spaces....OMG...will I ever get it...

On 7/21/09 12:29 PM, "Ashley Sheridan" <a...@ashleysheridan.co.uk> wrote:

On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote:
> On Tue, Jul 21, 2009 at 1:20 PM, Miller,
> Terion<tmil...@springfi.gannett.com> wrote:
> > Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> > which is prob messing it up right...but in the code why is it doing that 
> > twice..
> >
> > SELECT name, address, inDate, inType, notes, critical, cviolations, 
> > noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> > restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> > restaurants.name LIKE '%A%' ORDER BY restaurants.name;
> >
> >
>
> It's not the multiple LIKE statements. It is the concatenation, like I
> said the last time. There is no white space between "inspection.ID"
> and "AND".
>
> You may indeed have problems with some of those repeated conditions on
> restaurants.name, but if so they will be performance issues resulting
> from table scans, and not the errors you are reporting.
>
> Andrew
>

It's always better putting in extra whitespace at both ends of each part
of the query you are concatenating if you're unsure. Like Andrew said,
MySQL will balk if you have none between keywords, but I've never heard
it complaining about an extra space or two!

Thanks
Ash
www.ashleysheridan.co.uk




--- End Message ---
--- Begin Message ---
What I did to handle memos... and it's a HACK... was to create a
function DoMemo that took as arguments the table, the primary key
field of the table, the value of said pk, the field to update, and the
string.

Take the first 200 characters of the string.
Replace all newlines in that substring with "+CHR(13)+" (Or CHR(13)+CHR(10)?)
Then do something like: UPDATE table SET field=First200 WHERE pk=pkvalue

Then take the next 200 characters of the string.
Replace all newlines as above
Do something like: UPDATE table SET field=ALLTRIM(field)+Next200 WHERE
pk=pkvalue

Repeat until you've "consumed" the entire string. This works because
you never put in more that 250 odd characters at a time. It can still
fail though if you have enough newlines to push your 200 characters up
over the 250 odd character limit.

It DOES work if you use RECNO() as the pk field and the appropriate
recno() that you would get if you did something like SELECT recno() AS
myrecno,* FROM sometable (I use the myrecno because otherwise you get
some weird exp_1 field name)

It just popped into my head... I wonder if something like this would work...

UPDATE sometable SET a=1,a=a+1,a=a+1,a=a+1 WHERE x=y

You might be able to limit the total number of calls to the database
that way... If I wasn't in the process of migrating to MySQL I might
give it a whirl... :)

Hope this helps whatever you decide to do.

On Tue, Jul 21, 2009 at 8:27 AM, Floyd Resler<fres...@adex-intl.com> wrote:
> Matt,
>        Thanks for the information.  I'll look into using ODBTP.  I noticed
> you mentioned the problem with memos.  I currently have that problem with
> the set up we're using and it is a pain!
>
> Thanks!
> Floyd
>
> On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote:
>
>>> We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro
>>> database.  The problem is that the bridge, after a while, starts
>>> consuming a
>>> ton of system resources and we have to reboot the machine.  Afterwards,
>>> it
>>> can take upwards to two hours before everything is running quickly again.
>>> We need another solution.  Does anyone know of a any other way to connect
>>> to a remote FoxPro database (or any ODBC source that isn't a database
>>> server)?
>>
>> We've had a LOT a luck using ODBTP. Which can be found at
>> http://odbtp.sourceforge.net
>>
>> Here's the rough outline...
>>
>> 1. Install Visual FoxPro odbc driver (or whatever drivers you want) on
>> a Windows machine.
>> 2. Install the ODBTP Server on the windows machine
>> 3. Install a PHP module in your php. (Common ones included in the
>> download)
>> 4. Once you connect the functions are ALMOST exactly the same in usage
>> as the mysql_xyz functions.
>>
>> A couple gotchas:
>>
>> 1. If you need to compile the PHP ODBTP module from source on x64 (OS
>> X Leopard at least) it can be a pain.
>> 2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
>> allow more than 250 odd characters to be inserted at a single time so
>> memo's can be a PAIN.
>> 3. It does require a port be opened on the Windows machine's
>> firewall... (Uses TCP/IP for communication)
>> 4. By default the ODBTP server can use up to 32 threads. The VFP ODBC
>> driver is by nature single threaded. We've never had a problem with
>> that directly but I assume it is what causes threads to slowly hang
>> and disappear... eventually a message comes up "Unable to create
>> thread". At that point you simply need to restart the ODBTP service in
>> the Windows Services Control Panel. The bigger the tables and the more
>> heavily used it is the more often this will happen.
>>
>> Other than that... Works like a charm. Looking forward, once you bite
>> the bullet and convert to MySQL (at least for us) you can almost
>> change odbtp_ to mysql_ and be up and running. (Assuming you limit
>> yourself to "pure" SQL and not invoke VFP functions.)
>>
>> Matt
>>
>
>

--- End Message ---
--- Begin Message ---
Matt,
Thanks for the tip on handling memos. I always thought, "If I could just append to the end of the existing string..." but never figured out how to do it. I'll give your method a shot.

Thanks!
Floyd

On Jul 21, 2009, at 2:04 PM, Matt Neimeyer wrote:

What I did to handle memos... and it's a HACK... was to create a
function DoMemo that took as arguments the table, the primary key
field of the table, the value of said pk, the field to update, and the
string.

Take the first 200 characters of the string.
Replace all newlines in that substring with "+CHR(13)+" (Or CHR(13)+CHR(10)?) Then do something like: UPDATE table SET field=First200 WHERE pk=pkvalue

Then take the next 200 characters of the string.
Replace all newlines as above
Do something like: UPDATE table SET field=ALLTRIM(field)+Next200 WHERE
pk=pkvalue

Repeat until you've "consumed" the entire string. This works because
you never put in more that 250 odd characters at a time. It can still
fail though if you have enough newlines to push your 200 characters up
over the 250 odd character limit.

It DOES work if you use RECNO() as the pk field and the appropriate
recno() that you would get if you did something like SELECT recno() AS
myrecno,* FROM sometable (I use the myrecno because otherwise you get
some weird exp_1 field name)

It just popped into my head... I wonder if something like this would work...

UPDATE sometable SET a=1,a=a+1,a=a+1,a=a+1 WHERE x=y

You might be able to limit the total number of calls to the database
that way... If I wasn't in the process of migrating to MySQL I might
give it a whirl... :)

Hope this helps whatever you decide to do.

On Tue, Jul 21, 2009 at 8:27 AM, Floyd Resler<fres...@adex-intl.com> wrote:
Matt,
Thanks for the information. I'll look into using ODBTP. I noticed you mentioned the problem with memos. I currently have that problem with
the set up we're using and it is a pain!

Thanks!
Floyd

On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote:

We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro
database.  The problem is that the bridge, after a while, starts
consuming a
ton of system resources and we have to reboot the machine. Afterwards,
it
can take upwards to two hours before everything is running quickly again. We need another solution. Does anyone know of a any other way to connect to a remote FoxPro database (or any ODBC source that isn't a database
server)?

We've had a LOT a luck using ODBTP. Which can be found at
http://odbtp.sourceforge.net

Here's the rough outline...

1. Install Visual FoxPro odbc driver (or whatever drivers you want) on
a Windows machine.
2. Install the ODBTP Server on the windows machine
3. Install a PHP module in your php. (Common ones included in the
download)
4. Once you connect the functions are ALMOST exactly the same in usage
as the mysql_xyz functions.

A couple gotchas:

1. If you need to compile the PHP ODBTP module from source on x64 (OS
X Leopard at least) it can be a pain.
2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
allow more than 250 odd characters to be inserted at a single time so
memo's can be a PAIN.
3. It does require a port be opened on the Windows machine's
firewall... (Uses TCP/IP for communication)
4. By default the ODBTP server can use up to 32 threads. The VFP ODBC
driver is by nature single threaded. We've never had a problem with
that directly but I assume it is what causes threads to slowly hang
and disappear... eventually a message comes up "Unable to create
thread". At that point you simply need to restart the ODBTP service in the Windows Services Control Panel. The bigger the tables and the more
heavily used it is the more often this will happen.

Other than that... Works like a charm. Looking forward, once you bite
the bullet and convert to MySQL (at least for us) you can almost
change odbtp_ to mysql_ and be up and running. (Assuming you limit
yourself to "pure" SQL and not invoke VFP functions.)

Matt






--- End Message ---
--- Begin Message ---
Daniel P. Brown wrote:
>     Ladies and Gentlemen:
> 

Daniel P. Brown:

I originally found it here: http://www.php.net/mailing-lists.php when I
was looking for responsive help, and have always accessed it via a
newsgroup on news.php.net instead of as a mailing list.  The news server
times out quite a bit though.  It is doing it today frequently.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> Jason Carson wrote:
>>> Hello everyone,
>>>
>>> I am having a problem getting my prepared statements working. Here is my
>>> setup...
>>>
>>>     index.php -> authenticate.php -> admin.php
>>>
>>> 1)index.php has a login form on it so when someone enters their username
>>> the form redirects to another page I call authenticate.php.
>>>
>>> 2)In the authenticate.php file I want to use prepared statements to
>>> interact with the MySQL database. I want to compare the username
>>> submitted
>>> from the form with the username in the database.
>>>
>>> 3)If the login username was legitimate then you are forwarded to
>>> admin.php
>>>
>>> Its step 2 I am having problems with. Here is what I have but I don't
>>> think it makes any sense and it doesn't work.
>>>
>>>
>>> $link = mysqli_connect($hostname, $dbusername, $password, $database);
>>> $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
>>> adminusers=?");
>>> mysqli_stmt_bind_param($stmt, 's', $username);
>>> $result = mysqli_stmt_execute($stmt);
>>>
>>> $count=mysqli_num_rows($result);
>>>
>>> if($count==1){
>>> header("location:admin.php");
>>> } else {
>>> echo "Failure";
>>> }
>>>
>>> Any help is appreciated.
>>>
>>>
>>> -- 
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> For anyone reading this thread, here is the final code that I used...
>>
>> $link = mysqli_connect($hostname, $username, $password, $database);
>> $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
>> adminusers=?);
>> mysqli_stmt_bind_param($stmt, "s", $adminuser);
>> mysqli_stmt_execute($stmt);
>> mysqli_stmt_store_result($stmt);
>> $count = mysqli_stmt_num_rows($stmt);
>>
>> if($count==1){
>> header("location:admin.php");
>> } else {
>> echo "Failure";
>> }
>>
>>
> 
> I hope not, because you have a parse error on your second line,
> mysqli_prepare()
> 
> Might want to close your double-quoted string
> 
> -- 
> Jim Lucas

Not to mention that I don't see $adminuser defined anywhere.  If its
from a form and register_globals are off, maybe $_POST['adminuser'].

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Tir wrote:
> I have many scripts that I need execute with PHP CLI. They are located in a 
> few directories. I don't want to write full path to script every time when I 
> start it. Therefore I've added this paths to the PATH environment variable. 
> But PHP don't find my scripts. How could i set paths on which PHP would find 
> my script when i call e.g. "php -f my_script.php"? 
> 
> 

You can't do this.  The path only applies to executables.  If your
scripts looked like this (and they are marked executable):

#!/usr/bin/php
<?php
//myscript.php
//bla blah
?>

Then running: $/path/to/myscript.php will run your script.  The php
executable is not going to search your path for the script.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Hi all,
I have a doubt with creating and destroying sessions in PHP using session_destroy(). Supposing there is a PHP-based website hosted on a web server. Now I add another site that I developed using PHP on that web server using virtualhost. I destroy a session in my website using session_destroy() which will destroy all the session variables associated with my website.

What will happen if I have the other website in another tab with similar session variable names? Will the session variables of that website be destroyed too? Or will the session variables be associated with the session id so that only the appropriate website's session variables will get destroyed?

Thanks in advance.

Regards,
Guruprasad

--- End Message ---
--- Begin Message ---
Yes. You are right. Session variables are associated with the session id so
only that appropriate website's session variables will get destroyed.
You can try it in your local system.

On Wed, Jul 22, 2009 at 12:42 AM, Guruprasad <lgp171...@gmail.com> wrote:

> Hi all,
> I have a doubt with creating and destroying sessions in PHP using
> session_destroy(). Supposing there is a PHP-based website hosted on a web
> server. Now I add another site that I developed using PHP on that web server
> using virtualhost. I destroy a session in my website using session_destroy()
> which will destroy all the session variables associated with my website.
>
> What will happen if I have the other website in another tab with similar
> session variable names? Will the session variables of that website be
> destroyed too? Or will the session variables be associated with the session
> id so that only the appropriate website's session variables will get
> destroyed?
>
> Thanks in advance.
>
> Regards,
> Guruprasad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Devendra Jadhav

--- End Message ---
--- Begin Message ---


On Jul 21, 2009, at 3:12 PM, Guruprasad <lgp171...@gmail.com> wrote:

Hi all,
I have a doubt with creating and destroying sessions in PHP using session_destroy(). Supposing there is a PHP-based website hosted on a web server. Now I add another site that I developed using PHP on that web server using virtualhost. I destroy a session in my website using session_destroy() which will destroy all the session variables associated with my website.

What will happen if I have the other website in another tab with similar session variable names? Will the session variables of that website be destroyed too? Or will the session variables be associated with the session id so that only the appropriate website's session variables will get destroyed?


Each session has it's own id and therefore each session will just have it's own data destroyed



Thanks in advance.

Regards,
Guruprasad

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


Bastien

Sent from my iPod


--- End Message ---
--- Begin Message --- Keep in mind that sessions are based on the domain. I've run into situations where someone will be working in several different sites that we host. Each site is accessed via http://domain/site. Each site has it's own database, users, etc. However, because they all hang off the same domain, they get one session. That can really mess things up for the users as they go from site to site. I got around this by using MySQL-based sessions. It keeps things nice and separated.

Take care,
Floyd

On Jul 21, 2009, at 4:14 PM, Devendra Jadhav wrote:

Yes. You are right. Session variables are associated with the session id so
only that appropriate website's session variables will get destroyed.
You can try it in your local system.

On Wed, Jul 22, 2009 at 12:42 AM, Guruprasad <lgp171...@gmail.com> wrote:

Hi all,
I have a doubt with creating and destroying sessions in PHP using
session_destroy(). Supposing there is a PHP-based website hosted on a web server. Now I add another site that I developed using PHP on that web server using virtualhost. I destroy a session in my website using session_destroy() which will destroy all the session variables associated with my website.

What will happen if I have the other website in another tab with similar
session variable names? Will the session variables of that website be
destroyed too? Or will the session variables be associated with the session
id so that only the appropriate website's session variables will get
destroyed?

Thanks in advance.

Regards,
Guruprasad

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




--
Devendra Jadhav


--- End Message ---
--- Begin Message ---
Hi,
Floyd Resler wrote:
Keep in mind that sessions are based on the domain. I've run into situations where someone will be working in several different sites that we host. Each site is accessed via http://domain/site. Each site has it's own database, users, etc. However, because they all hang off the same domain, they get one session. That can really mess things up for the users as they go from site to site. I got around this by using MySQL-based sessions. It keeps things nice and separated.

Take care,
Floyd

Will this be causing issues when http://1.a.b and http://2.a.b are the two PHP sites running on the same web server using virtualhosts?

Regards,
Guruprasad

--- End Message ---
--- Begin Message ---
By default sub-domains do not share sessions but you can make them to share
the session

On Wed, Jul 22, 2009 at 1:54 AM, L.Guruprasad <lgp171...@gmail.com> wrote:

> Hi,
> Floyd Resler wrote:
>
>> Keep in mind that sessions are based on the domain.  I've run into
>> situations where someone will be working in several different sites that we
>> host.  Each site is accessed via http://domain/site.  Each site has it's
>> own database, users, etc.  However, because they all hang off the same
>> domain, they get one session.  That can really mess things up for the users
>> as they go from site to site.  I got around this by using MySQL-based
>> sessions.  It keeps things nice and separated.
>>
>> Take care,
>> Floyd
>>
>
> Will this be causing issues when http://1.a.b and http://2.a.b are the two
> PHP sites running on the same web server using virtualhosts?
>
> Regards,
> Guruprasad
>



-- 
Devendra Jadhav

--- End Message ---
--- Begin Message ---
On Wed, Jul 22, 2009 at 3:24 AM, L.Guruprasad <lgp171...@gmail.com> wrote:

> Hi,
> Floyd Resler wrote:
>
>> Keep in mind that sessions are based on the domain.  I've run into
>> situations where someone will be working in several different sites that we
>> host.  Each site is accessed via http://domain/site.  Each site has it's
>> own database, users, etc.  However, because they all hang off the same
>> domain, they get one session.  That can really mess things up for the users
>> as they go from site to site.  I got around this by using MySQL-based
>> sessions.  It keeps things nice and separated.
>>
>> Take care,
>> Floyd
>>
>
> Will this be causing issues when http://1.a.b and http://2.a.b are the two
> PHP sites running on the same web server using virtualhosts?
>
As Floyd suggested keeping your sessions in the DB will give you better
session management and security as well.

--- End Message ---
--- Begin Message ---
Okay I'm back guys...not sure what happened it was working..now it's all hung 
up...
Here are the errors:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
 on line 464

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
 on line 488



Here is the full code snippet:

                                                                <?php           
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                      // Check if page is set 
to show all                                    if(isset($_GET['show']) && 
$_GET['show'] == 'all')                                    {                    
                  unset($_SESSION['results']);                                  
    unset($_SESSION['searchname']);                                      
unset($_SESSION['address']);                                                    
                                                           }                    
                                                    // Check if there was an 
empty search sent                                    
if(isset($_SESSION['noVarsSent']))                                    {         
                             echo "<p><b>No values were submitted for the 
search.</b></p>";                                      // Unset it so a reload 
of page doesn't redisplay the error                                      
unset($_SESSION['noVarsSent']);                                      // 
unset($_SESSION['results']);                                    }               
                                                                                
             // Check if full list of restaurants has been created and stored 
yet                                    // Store full results in $_SESSION to 
limit database hits                                    
if(!isset($_SESSION['fullRestaurantList']))                                    
{                                      // List not grabbed yet, so run query 
and store in $_SESSION                                                          
                //check for range                                    if 
(!(isset($rangenum)))                                      {                    
                  $rangenum = 1;                                      }         
                             // Grab all restaurants in alphabetical order      
                                $sql = "SELECT ID, name, address, inDate, 
inType, notes, critical, cviolations, noncritical FROM restaurants, inspections 
WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY 
name;";                                      $result = mysql_query($sql);       
                                                                 //trying to 
grab it by ranges from the db?                                     $rows = 
mysql_num_rows($sql);                                      $page_rows = 100;    
                                  $last_row = ceil($rows/$page_rows);           
                                                                 if ($rangenum 
< 1)                                    {                                      
$rangenum = 1;                                      }                           
           elseif ($rangenum > $last_row)                                      
{                                      $rangenum = $last_row;                   
                   }                                                            
                //This sets the range to display in our query                   
                   $max = 'limit ' .($rangenum - 1) * $page_rows .',' 
.$page_rows;                                                                    
                                                                                
    // Process all results into $_SESSION array                                 
                                           $position = 1;                       
                                                     while ($row = 
mysql_fetch_array($result))                                      {              
                        $_SESSION['fullRestaurantList'][$position] = $row;      
                                $position++;                                    
  }                                                                            
$_SESSION['totalNumberOfRestaurants'] = $position;                              
                                            }                                  
?>

It's like 15min til 4pm here in Missouri and I am so out the door at 4..because 
this has been one long frustrating day..and this girl needs a beer.....or two.
Talk to you all tomorrow!
Terion

--- End Message ---
--- Begin Message ---
Miller, Terion wrote:
> Okay I'm back guys...not sure what happened it was working..now it's all hung 
> up...
> Here are the errors:
> 
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
>  on line 464
> 
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
>  on line 488
> 
> 
> 
> Here is the full code snippet:
> 
>                                                                 <?php         
>                                                                               
>                                                                               
>                                                                               
>                                                                               
>                                                                               
>                                                                   // Check if 
> page is set to show all                                    
> if(isset($_GET['show']) && $_GET['show'] == 'all')                            
>         {                                      unset($_SESSION['results']);   
>                                    unset($_SESSION['searchname']);            
>                           unset($_SESSION['address']);                        
>                                                                       
                 }                                                              
          // Check if there was an empty search sent                            
        if(isset($_SESSION['noVarsSent']))                                    { 
                                     echo "<p><b>No values were submitted for 
the search.</b></p>";                                      // Unset it so a 
reload of page doesn't redisplay the error                                      
unset($_SESSION['noVarsSent']);                                      // 
unset($_SESSION['results']);                                    }               
                                                                                
             // Check if full list of restaurants has been created and stored 
yet                                    // Store full results in $_SESSION to 
limit database hits                                    
if(!isset($_SESSION['fullRestaurantList']))                               
     {                                      // List not grabbed yet, so run 
query and store in $_SESSION                                                    
                      //check for range                                    if 
(!(isset($rangenum)))                                      {                    
                  $rangenum = 1;                                      }         
                             // Grab all restaurants in alphabetical order      
                                $sql = "SELECT ID, name, address, inDate, 
inType, notes, critical, cviolations, noncritical FROM restaurants, inspections 
WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY 
name;";                                      $result = mysql_query($sql);       
                                                                 //trying to 
grab it by ranges from the db?                                     $rows = 
mysql_num_rows($sql);                                   
   $page_rows = 100;                                      $last_row = 
ceil($rows/$page_rows);                                                         
                   if ($rangenum < 1)                                    {      
                                $rangenum = 1;                                  
    }                                      elseif ($rangenum > $last_row)       
                               {                                      $rangenum 
= $last_row;                                      }                             
                                               //This sets the range to display 
in our query                                      $max = 'limit ' .($rangenum - 
1) * $page_rows .',' .$page_rows;                                               
                                                                                
                         // Process all results into $_SESSION array            
                                        
                        $position = 1;                                          
                                  while ($row = mysql_fetch_array($result))     
                                 {                                      
$_SESSION['fullRestaurantList'][$position] = $row;                              
        $position++;                                      }                     
                                                       
$_SESSION['totalNumberOfRestaurants'] = $position;                              
                                            }                                  
?>
> 
> It's like 15min til 4pm here in Missouri and I am so out the door at 
> 4..because this has been one long frustrating day..and this girl needs a 
> beer.....or two.
> Talk to you all tomorrow!
> Terion
> 

        $sql = "SELECT ID, name, address, inDate, inType, notes, critical,
cviolations, noncritical FROM restaurants, inspections WHERE
restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY name;";
        $result = mysql_query($sql);


Because the following line is wrong
        //trying to grab it by ranges from the db?
        $rows = mysql_num_rows($sql);

should be

        $rows = mysql_num_rows($result);


But this is failing...

        while ($row = mysql_fetch_array($result)) {

because your

        $result = mysql_query($sql);

is probably failing.

Try changing the

        $result = mysql_query($sql);

to

        $result = mysql_query($sql) or die(mysql_error());

What ever you do, don't use this in production code.  But it WILL be
useful with testing.

Jim Lucas


--- End Message ---
--- Begin Message ---
newbie ...

- is there a calendar module for date fields?

- so that a small calendar pops up - then you can click on a date, to add to a field - like google or yahoo calendars has...?

BTW: I saw this - but it doesn't seem to be the right thing ( more meant for Converter issues) for what I'm looking for...

http://us2.php.net/manual/en/intro.calendar.php


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




--- End Message ---
--- Begin Message ---
On Tue, Jul 21, 2009 at 10:06 PM,
c...@hosting4days.com<c...@hosting4days.com> wrote:
> newbie ...
>
> - is there a calendar module for date fields?
>
> - so that a small calendar pops up - then you can click on a date,  to add
> to a field - like google or yahoo calendars has...?
>
> BTW: I saw this - but it doesn't seem to be the right thing ( more meant for
> Converter issues) for what I'm looking for...
>
> http://us2.php.net/manual/en/intro.calendar.php
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

That is javascript thing, not PHP.

The Yahoo UI has a nice one, here you have an example:
http://developer.yahoo.com/yui/examples/calendar/calcontainer_clean.html,
and here the module reference:
http://developer.yahoo.com/yui/calendar/

Jonathan

--- End Message ---
--- Begin Message ---
> > > As for (1) even in my pre-OO days I was used to using a single
> > > generic DAO for all database access. The only time that more
> > > than one DAO existed was for a different DBMS engine. This
> > > is why I have one DAO class for MySQL, one for PostgreSQL
> > > and another for Oracle. If you are incapable of writing  a
> > > single generic DAO then it just shows that you still have a lot to
> > > learn. For an idea on how this works take a look at
> > > http://www.tonymarston.net/php-mysql/databaseobjects.html


Before I dig in on this DAO, I'm wondering, where should I, and how could I,
properly place a JOIN on this kind of pattern? Is it easy done or, on a JOIN
scenario (and I will have a lot of them) I choose probably choose another
pattern?


Regards,
Márcio



--- End Message ---

Reply via email to