php-general Digest 16 Apr 2005 18:59:57 -0000 Issue 3401

Topics (messages 213176 through 213210):

Are sessions unreliable?
        213176 by: Dasmeet Singh
        213177 by: Warren Vail
        213182 by: Dasmeet Singh
        213200 by: Matthew Weier O'Phinney

Re: Any experience with multi-language PHP sites?
        213178 by: Burhan Khalid
        213189 by: Marek Kilimajer

Chat Script
        213179 by: sukalyan  banga
        213210 by: Dasmeet Singh

Re: snort database not appearing in phpmyadmin
        213180 by: Burhan Khalid

Re: Sessions and frames
        213181 by: Gustav Wiberg

Re: Determining array type
        213183 by: zini10
        213184 by: Burhan Khalid

Re: Mysql insert problems
        213185 by: Burhan Khalid

A question
        213186 by: Khorosh Irani
        213187 by: Amir Mohammad Saied
        213191 by: Khorosh Irani
        213195 by: Rory Browne
        213203 by: trlists.clayst.com

Access Denied-phpMyAdmin
        213188 by: Mark Sargent
        213190 by: Marek Kilimajer
        213192 by: Mark Sargent
        213194 by: Andre Dubuc

forwarding email messages directly from a maildir
        213193 by: mbneto

Two tables                                                 (Slightly 0T)
        213196 by: Ryan A
        213197 by: Petar Nedyalkov
        213198 by: Ryan A
        213199 by: Matthew Weier O'Phinney
        213201 by: Ryan A

reducing array size
        213202 by: pete M
        213206 by: Jason Wong

round?
        213204 by: Chris Knipe
        213205 by: trlists.clayst.com

query error
        213207 by: pete M
        213208 by: Satyam

trying to send mail via localhost
        213209 by: AndreaD

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Hi!

I store some user info in sessions.. it works fine but sometimes what happens is that the user id stored in session get changed.. and it happens only sometimes..

Can it be browser problem? or this is common?

Thanks



-
Free cPanel Web Hosting
http://hostwindow.info/web-hosting/2/free-cpanel-web-hosting/

--- End Message ---
--- Begin Message ---
I have had similar things happen but in every case it turned out to be a
program bug in my code.  It was usually something I looked at over and
over and I saw the way it was supposed to work, but because I missed a
detail it was not working that way.  I would suggest you find someone to
look over your code and help you with the debug process.  I found many
bugs just trying to explain to someone clearly how it worked.

I suppose it could be a browser problem, but you need to solve those as
well, or at least handle them gracefully.  Do you make it a practice of
having multiple browser instances open at the same time.  I believe they
will each normally get their own session key, and if you get your hands
crossed, you will be looking at the symptoms in the wrong browser,
bottom line, test, test, and test, then get a second set of eyes to look
at your code, show them how it works, they don't need to really know a
lot about PHP, or even programming for that matter, they will ask
questions that as you try to answer them, you will find your problems.

I have never found a legitimate bug in PHP Sessions, I have on the other
hand found I was inconsistently using session handler routines, and
before register globals was turned off, I was finding form variables
that clobbered my session variables (or maybe it was the other way).

Good Luck,

Warren Vail
[EMAIL PROTECTED]

> -----Original Message-----
> From: Dasmeet Singh [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 15, 2005 11:04 PM
> To: php-general@lists.php.net
> Subject: [PHP] Are sessions unreliable?
> 
> 
> Hi!
> 
> I store some user info in sessions.. it works fine but sometimes what 
> happens is that the user id stored in session get changed.. and it 
> happens only sometimes..
> 
> Can it be browser problem? or this is common?
> 
> Thanks
> 
> 
> 
> -
> Free cPanel Web Hosting 
> http://hostwindow.info/web-hosting/2/free-> cpanel-web-hosting/
> 
> 
> -- 
> PHP General Mailing List 
> (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

--- End Message ---
--- Begin Message ---
Hi! Warren

Thanks for such a detailed reply... I am already looking into the code...

Just wanted to ask... I recently updated Red Hat's kernel.. and this problem seems to started appearing after that... is there a possibility of any connection between these two?


Warren Vail wrote:

I have had similar things happen but in every case it turned out to be a
program bug in my code.  It was usually something I looked at over and
over and I saw the way it was supposed to work, but because I missed a
detail it was not working that way.  I would suggest you find someone to
look over your code and help you with the debug process.  I found many
bugs just trying to explain to someone clearly how it worked.

I suppose it could be a browser problem, but you need to solve those as
well, or at least handle them gracefully.  Do you make it a practice of
having multiple browser instances open at the same time.  I believe they
will each normally get their own session key, and if you get your hands
crossed, you will be looking at the symptoms in the wrong browser,
bottom line, test, test, and test, then get a second set of eyes to look
at your code, show them how it works, they don't need to really know a
lot about PHP, or even programming for that matter, they will ask
questions that as you try to answer them, you will find your problems.

I have never found a legitimate bug in PHP Sessions, I have on the other
hand found I was inconsistently using session handler routines, and
before register globals was turned off, I was finding form variables
that clobbered my session variables (or maybe it was the other way).

Good Luck,

Warren Vail
[EMAIL PROTECTED]


-----Original Message-----
From: Dasmeet Singh [mailto:[EMAIL PROTECTED] Sent: Friday, April 15, 2005 11:04 PM
To: php-general@lists.php.net
Subject: [PHP] Are sessions unreliable?


Hi!

I store some user info in sessions.. it works fine but sometimes what happens is that the user id stored in session get changed.. and it happens only sometimes..

Can it be browser problem? or this is common?

Thanks



-
Free cPanel Web Hosting http://hostwindow.info/web-hosting/2/free-> cpanel-web-hosting/


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





-

Free cPanel Web Hosting
http://hostwindow.info/web-hosting/2/free-cpanel-web-hosting/

--- End Message ---
--- Begin Message ---
* Dasmeet Singh <[EMAIL PROTECTED]> :
> Just wanted to ask... I recently updated Red Hat's kernel.. and this 
> problem seems to started appearing after that... is there a possibility 
> of any connection between these two?

Probably not, unless you're using shared memory for sessions.


> Warren Vail wrote:
>
> > I have had similar things happen but in every case it turned out to be a
> > program bug in my code.  It was usually something I looked at over and
> > over and I saw the way it was supposed to work, but because I missed a
> > detail it was not working that way.  I would suggest you find someone to
> > look over your code and help you with the debug process.  I found many
> > bugs just trying to explain to someone clearly how it worked.
> > 
> > I suppose it could be a browser problem, but you need to solve those as
> > well, or at least handle them gracefully.  Do you make it a practice of
> > having multiple browser instances open at the same time.  I believe they
> > will each normally get their own session key, and if you get your hands
> > crossed, you will be looking at the symptoms in the wrong browser,
> > bottom line, test, test, and test, then get a second set of eyes to look
> > at your code, show them how it works, they don't need to really know a
> > lot about PHP, or even programming for that matter, they will ask
> > questions that as you try to answer them, you will find your problems.
> > 
> > I have never found a legitimate bug in PHP Sessions, I have on the other
> > hand found I was inconsistently using session handler routines, and
> > before register globals was turned off, I was finding form variables
> > that clobbered my session variables (or maybe it was the other way).
> >
> > > -----Original Message-----
> > > From: Dasmeet Singh [mailto:[EMAIL PROTECTED] 
> > > Sent: Friday, April 15, 2005 11:04 PM
> > > To: php-general@lists.php.net
> > > Subject: [PHP] Are sessions unreliable?
> > >
> > > I store some user info in sessions.. it works fine but sometimes what 
> > > happens is that the user id stored in session get changed.. and it 
> > > happens only sometimes..
> > >
> > > Can it be browser problem? or this is common?

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED]         | http://vermontbotanical.org

--- End Message ---
--- Begin Message --- Richard Davey wrote:
Hi all,

[ snipped ]

   I'm interested in knowing of any problems I should be looking out
   for while designing this - what happens to Japanese characters for
   example when stored in a MySQL text field? Any issues re:
   displaying them again once extracted? Or on validating foreign
   data input on web forms?

We develop a few multi-language websites here, but mostly dealing with two languages; our most complex site is in three languages. I can provide the following tips:

1. MySQL's default character set is latin1 -- you need to watch out for this when storing information because it will get garbled. Character sets and collations vary greatly depending on what version of MySQL you are using. I would suggest going over the character set section in the manual [ http://dev.mysql.com/doc/mysql/en/charset-server.html ] if you haven't already. 4.1 has most of the features you would need.

2. Text searching can be a bit of a pain. We were using a system that defaults to utf-8; and stored the information in MySQL. Our users were logging in from Windows, and their character set was windows-1256 -- so searches were turning up blank, till we converted the system to windows-1256. Don't ask me how/why, because I'm really not that good with all this character set stuff :) If you figure this out, please let me know. I've found that matching the character set of HTML to what is expected from your users is the best compromise when coming to display & searching.

3. I'm not sure how you would go and validate foreign data input; as I have never had to do such myself (all our input was in English on the public side, and on the backend, it was manually verified). Best of luck on this one.

Cheers,
Burhan

--- End Message ---
--- Begin Message --- Burhan Khalid wrote:
I've found that matching the character set of HTML to what is expected from your users is the best compromise when coming to display & searching.

This is a must, not a compromise.
--- End Message ---
--- Begin Message ---
Hi!
   I am  finding  a chat script from which I can use that script as a private 
chatting work at my own URL.

--- End Message ---
--- Begin Message --- Sukalyan Banga wrote:
Hi!
   I am  finding  a chat script from which I can use that script as a private 
chatting work at my own URL.

see this :)

http://www.hotscripts.com/PHP/Scripts_and_Programs/Chat_Scripts/index.html

-

Free cPanel Web Hosting
http://hostwindow.info/web-hosting/2/free-cpanel-web-hosting/

--- End Message ---
--- Begin Message --- Mark Sargent wrote:
Mark Sargent wrote:

Hi All,

I've installed phpmyadmin and have a snort database in mysql, but, it doesn't appear in phpmyadmin. I know it's there, because base is using it to display info from snort on the machine. Why wouldn't it appear in phpmyadmin. It appears with the same set up on my work test machine. What should I look for to fix this..? Cheers.

Mark Sargent.

Mark,

This is not the phpmyadmin help list. Its is not the snort help list either. This list is for PHP (the language) related issues.

Regards,
Burhan

--- End Message ---
--- Begin Message ---
Hi there!

Thanx a lot, i thought it was like that, but I wasn't sure....

/G
@varupiraten.se


----- Original Message ----- From: "Chris W. Parker" <[EMAIL PROTECTED]>
To: "Gustav Wiberg" <[EMAIL PROTECTED]>; "PHP General" <php-general@lists.php.net>
Sent: Friday, April 15, 2005 1:26 AM
Subject: RE: [PHP] Sessions and frames


Gustav Wiberg <mailto:[EMAIL PROTECTED]> on Thursday, April 14, 2005 4:00 PM said:

I have built my site into frames.

I want to transfer a session-variable from my left frame to my right
frame... How do I do this best? Thoughts?

You do this best by setting some session data on one page (any page), and then accessing that same data on another page (any page). If both frame sources are within the same domain they both have access to the same session data.



Chris.


-- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.11 - Release Date: 2005-04-14

--- End Message ---
--- Begin Message ---
i dont think there is a pre-made function but u can use :
(! --untested at all --! )

function determine_array($a)
{
  $numric=0;
  $assoc=0;

  foreach($a as $index=>$value)
  {
      if(is_numeric($index)){ $numric=1; }
      else{ $assoc=1; }
   }

  return $numric+$assoc*2;
}


then results should be:
empty: 0
numric: 1
assoc : 2
num+assoc : 3

"Nsk" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> We have two kinds of arrays in PHP:
>
> $array["name"] = "George"
>
> $array[0] = "George"
>
> How can I determine (with a function returning true/false for example) 
> which
> type of array I am working with?
>
> -- 
> NSK (Nikolaos S. Karastathis)
> Personal Homepage at http://nsk.wikinerds.org/
> Owner of http://portal.wikinerds.org
> Owner of http://www.nerdypc.org 

--- End Message ---
--- Begin Message --- NSK wrote:
We have two kinds of arrays in PHP:

$array["name"] = "George"

$array[0] = "George"

How can I determine (with a function returning true/false for example) which type of array I am working with?

There aren't two "kinds" of arrays, there is only one array type:

"There are no different indexed and associative array types in PHP; there is only one array type, which can both contain integer and string indices."

[ http://www.php.net/manual/en/language.types.array.php ]

So, you can have an array like this:

$array = array("hello", "name" => "Burhan");

If you just want to know if all keys are numeric, then you just do a check on the keys :

$keys = array_keys(array("hello","name" => "Burhan", "goodbye"));

foreach($keys as $key) { /* put your check in here */ }

Make sure you do a type-safe check ( === ) not ( == ) which is not type safe.
--- End Message ---
--- Begin Message --- Andy Pieters wrote:
Hi

Whilst you are searching the net, you might also want to search for 'sql injection'. This is no joke!

Please use the mysql_escape_string on each variable you get from the user side.

Use mysql_real_escape_string() instead.
--- End Message ---
--- Begin Message ---
Hello
How I can find that php is installed as cgi or as apache module?
Thanks

--- End Message ---
--- Begin Message --- phpinfo()
--- End Message ---
--- Begin Message ---
How I can find it in phpinfo() ?

On 4/16/05, Amir Mohammad Saied <[EMAIL PROTECTED]> wrote:
> phpinfo()
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
you write a script containing <?php phpinfo(); ?> and <?php phpinfo();
?> only. You access that script through your web browser, and it will
return a variety of useful information. Amongst it will be information
labeled as SERVER API. If you are running as an apache module, Apache
will appear in the box beside it. If you are using CGI, then CGI will
appear there.


On 4/16/05, Khorosh Irani <[EMAIL PROTECTED]> wrote:
> How I can find it in phpinfo() ?
> 
> On 4/16/05, Amir Mohammad Saied <[EMAIL PROTECTED]> wrote:
> > phpinfo()
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
On 16 Apr 2005 Khorosh Irani wrote:

> How I can find it in phpinfo() ?

Another (simpler) approach is:

        echo php_sapi_name();

which will return 'cli', 'cgi', etc.

--
Tom

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

I can access the database from the terminal on Fedora 3,

[EMAIL PROTECTED] bin]# ./mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.10a-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

But, get the following error when accessing via phpMyAdmin with user as root and the correct password,

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.

|#1045 - Access denied for user 'root'@'localhost' (using password: YES)


I don't understand this. What have I missed..?

$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin-2.6.1-pl3/';

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'password is correct'; // MySQL password (only needed



|
--- End Message ---
--- Begin Message --- Mark Sargent wrote:
Hi All,

I can access the database from the terminal on Fedora 3,

[EMAIL PROTECTED] bin]# ./mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.10a-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

But, get the following error when accessing via phpMyAdmin with user as root and the correct password,

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.

|#1045 - Access denied for user 'root'@'localhost' (using password: YES)


I don't understand this. What have I missed..?

$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin-2.6.1-pl3/';

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'password is correct'; // MySQL password (only needed

Change $cfg['Servers'][$i]['connect_type'], I guess it should be 'socket' in your setup
--- End Message ---
--- Begin Message ---
Marek Kilimajer wrote:

Mark Sargent wrote:

Hi All,

I can access the database from the terminal on Fedora 3,

[EMAIL PROTECTED] bin]# ./mysql -h localhost -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.1.10a-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

But, get the following error when accessing via phpMyAdmin with user as root and the correct password,

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in config.inc.php and make sure that they correspond to the information given by the administrator of the MySQL server.

|#1045 - Access denied for user 'root'@'localhost' (using password: YES)


I don't understand this. What have I missed..?

$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin-2.6.1-pl3/';

$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'password is correct'; // MySQL password (only needed


Change $cfg['Servers'][$i]['connect_type'], I guess it should be 'socket' in your setup

Hi All,

thanx, but, no difference. What I don't un, is, the setup is the same as
another FC3 box, and it works. Cheers.

Mark Sargent.
--- End Message ---
--- Begin Message ---
On Saturday 16 April 2005 07:18 am, Mark Sargent wrote:
> Marek Kilimajer wrote:
> > Mark Sargent wrote:
> >> Hi All,
> >>
> >> I can access the database from the terminal on Fedora 3,
> >>
> >> [EMAIL PROTECTED] bin]# ./mysql -h localhost -u root -p
> >> Enter password:
> >> Welcome to the MySQL monitor.  Commands end with ; or \g.
> >> Your MySQL connection id is 2 to server version: 4.1.10a-standard
> >>
> >> Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
> >>
> >> mysql>
> >>
> >> But, get the following error when accessing via phpMyAdmin with user
> >> as root and the correct password,
> >>
> >> phpMyAdmin tried to connect to the MySQL server, and the server
> >> rejected the connection. You should check the host, username and
> >> password in config.inc.php and make sure that they correspond to the
> >> information given by the administrator of the MySQL server.
> >>
> >> |#1045 - Access denied for user 'root'@'localhost' (using password: YES)
> >>
> >> I don't understand this. What have I missed..?
> >>
> >> $cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin-2.6.1-pl3/';
> >>
> >> $cfg['Servers'][$i]['user']          = 'root';      // MySQL user
> >> $cfg['Servers'][$i]['password']      = 'password is
> >> correct';          // MySQL password (only needed
> >
> > Change $cfg['Servers'][$i]['connect_type'], I guess it should be
> > 'socket' in your setup
>
> Hi All,
>
> thanx, but, no difference. What I don't un, is, the setup is the same as
> another FC3 box, and it works. Cheers.
>
> Mark Sargent.


Mark, 
I had the same problem. Try:

$cfg['PmaAbsoluteUri'] = '';

/**
 * Disable the default warning about $cfg['PmaAbsoluteUri'] not being set
 * You should use this if and ONLY if the PmaAbsoluteUri auto-detection
 * works perfectly.
 */
$cfg['PmaAbsoluteUri_DisableWarning'] = FALSE;

......

$cfg['Servers'][$i]['host']          = 'localhost'; // MySQL hostname or IP 
address

Hth,
Andre

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

I'd like to make a script that opens my maildir
(~login/Maildir/.Junk/cur) and forwards all messages to a specific
address in order to train the spam engine.

Any tips about this ?

tks.

--- End Message ---
--- Begin Message ---
Hey,
My host has MySql 4.0.x so I cant really use the nested selects of 4.1 :-(
please tell me how you solved something like this;

I have two tables:
users_online (username , dateandtime)
users_details (cno, username, has_image, image_name)

1a) I have to select x records from users_online where $username is not more
than 3 minutes old,
1b) then I have to check if that username has_image,if yes, get the
imagename

I thought of having the imagename also in the users_details, but we are
allowing our members to
change/modify their images at will....

What kind of sql do I use above? I dont want to run a query on every record
returned from users_online
as that would be really "expensive".

Thanks,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.13 - Release Date: 4/16/2005

--- End Message ---
--- Begin Message ---
On Saturday 16 April 2005 17:06, Ryan A wrote:
> Hey,
> My host has MySql 4.0.x so I cant really use the nested selects of 4.1 :-(
> please tell me how you solved something like this;
>
> I have two tables:
> users_online (username , dateandtime)
> users_details (cno, username, has_image, image_name)
>
> 1a) I have to select x records from users_online where $username is not
> more than 3 minutes old,
> 1b) then I have to check if that username has_image,if yes, get the
> imagename
>
> I thought of having the imagename also in the users_details, but we are
> allowing our members to
> change/modify their images at will....
>
> What kind of sql do I use above? I dont want to run a query on every record
> returned from users_online
> as that would be really "expensive".

See the JOIN syntax in MySQL. You can join the two tables.

http://dev.mysql.com/doc/mysql/en/join.html

BTW this is a question for the [MySQL General] list at [EMAIL PROTECTED]

:-)

>
> Thanks,
> Ryan
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.13 - Release Date: 4/16/2005

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436

Attachment: pgpihZToOsxcw.pgp
Description: PGP signature


--- End Message ---
--- Begin Message ---
Hey,
Thanks for replying.

Will look up "join".

> BTW this is a question for the [MySQL General] list at
[EMAIL PROTECTED]

I know its largly a MySql question, but I am using it via PHP...and thats
why I wrote the OT in the subject...didnt want to tick anyone off.

Cheers,
Ryan


On 4/16/2005 3:57:49 PM, [EMAIL PROTECTED] wrote:
> On Saturday 16 April 2005 17:06, Ryan A wrote:
>
> > Hey,
>
> > My host has MySql 4.0.x so I cant really use the nested selects of 4.1
:-
> (
>
> > please tell me how you solved something like this;
>
> >
>
> > I have two tables:
>
> > users_online (username , dateandtime)
>
> > users_details (cno, username, has_image, image_name)
>
> >
>
> > 1a) I have to select x records from users_online where $username is not
>
> > more than 3 minutes old,
>
> > 1b) then I have to check if that username has_image,if yes, get the
>
> > imagename
>
> >
>
> > I thought of having the imagename also in the users_details, but we are
>
> > allowing our members to
>
> > change/modify their images at will....
>
> >
>
> > What kind of sql do I use above? I dont want to run a query on every
> record
>
> > returned from users_online
>
> > as that would be really "expensive".
>
>
>
> See the JOIN syntax in MySQL. You can join the two tables.
>
>



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.13 - Release Date: 4/16/2005

--- End Message ---
--- Begin Message ---
* Ryan A <[EMAIL PROTECTED]>:
> My host has MySql 4.0.x so I cant really use the nested selects of 4.1 :-(
> please tell me how you solved something like this;
>
> I have two tables:
> users_online (username , dateandtime)
> users_details (cno, username, has_image, image_name)
>
> 1a) I have to select x records from users_online where $username is not more
> than 3 minutes old,
> 1b) then I have to check if that username has_image,if yes, get the
> imagename
>
> I thought of having the imagename also in the users_details, but we are
> allowing our members to
> change/modify their images at will....
>
> What kind of sql do I use above? I dont want to run a query on every record
> returned from users_online
> as that would be really "expensive".

You're right, this is OT, but I'll answer anyways.

You need to start brushing up on ANSI SQL, as this requires only a JOIN
and a LIMIT:

SELECT 
    users_details.username,
    image_name
FROM
    users_details
INNER JOIN
    users_online ON users_online.username = users_details.username
WHERE
    users_online.dateandtime < ? AND
    has_image = 'yes'
LIMIT x

(where '?' is a date or timestamp 3 minutes in the past, and 'x' is the
number of records you wish to select).

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED]         | http://vermontbotanical.org

--- End Message ---
--- Begin Message ---
Hey,
Thanks for replying.

I know, I need to start brushing up on my Sql, problem is I rarely need to
use much other than
a simple select,update,insert.

Sorry I didnt write my where query before...this is what i am using:

SELECT last_online  from `members_online` WHERE
last_online > DATE_sub(NOW(),INTERVAL 5 MINUTE );

Cheers,
Ryan

On 4/16/2005 4:29:27 PM, Matthew Weier O'Phinney ([EMAIL PROTECTED]) wrote:
> * Ryan A <[EMAIL PROTECTED]>:
>
> > My host has MySql 4.0.x so I cant really use the nested selects of 4.1
:-
> (
>
> > please tell me how you solved something like this;
>
> >
>
> > I have two tables:
>
> > users_online (username , dateandtime)
>
> > users_details (cno, username, has_image, image_name)
>
> >
>
> > 1a) I have to select x records from users_online where $username is not
> more
>
> > than 3 minutes old,
>
> > 1b) then I have to check if that username has_image,if yes, get the
>
> > imagename
>
> >
>
> > I thought of having the imagename also in the users_details, but we are
>
> > allowing our members to
>
> > change/modify their images at will....
>
> >
>
> > What kind of sql do I use above? I dont want to run a query on every
> record
>
> > returned from users_online
>
> > as that would be really "expensive".
>
>
>
> You're right, this is OT, but I'll answer anyways.
>
>
>



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.13 - Release Date: 4/16/2005

--- End Message ---
--- Begin Message ---
Is there an easy way to "trim" an array ?

I'm using array_unshift to push elemnts onto the front of an array but I want to limit the size to 20 ??

Is there an easy way to do this without "looping" and unsetting the elements ??

tia
Pete

--- End Message ---
--- Begin Message ---
On Saturday 16 April 2005 23:07, pete M wrote:
> Is there an easy way to "trim" an array ?
>
> I'm using array_unshift to push elemnts onto the front of an array but
> I want to limit the size to 20 ??
>
> Is there an easy way to do this without "looping" and unsetting the
> elements ??

array_slice(), array_splice()

-- 
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 ---
Hi,

I'm not sure if round() is what I am after. I want to round whole numbers to the closest 10 - thus, not decimals, etc.

For example.

11.23 = 10
14.76 = 10
15.23 = 20
18.53 = 20

Thanks,


-- Chris.

I love deadlines. I especially love the whooshing sound they make as they fly by..." - Douglas Adams, 'Hitchhiker's Guide to the Galaxy'
--- End Message ---
--- Begin Message ---
On 16 Apr 2005 Chris Knipe wrote:

> I'm not sure if round() is what I am after.  I want to round whole numbers 
> to the closest 10 - thus, not decimals, etc.

Just use a precision of -1.  For example round(125, -1) will return 
130.

--
Tom

--- End Message ---
--- Begin Message ---
I've got a database table with a whole list of "windows" file paths.

eg
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Binder.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Excel.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Office Setup.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Outlook.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft PowerPoint.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Word.lnk
Advent Tower PC\C\Program Files\Microsoft Office\MS Access Workgroup Administrator.lnk
Advent Tower PC\C\Program Files\Microsoft Office\MSCREATE.DIR
Advent Tower PC\C\Program Files\Microsoft Office\OF97SPEC.INI
Advent Tower PC\C\Program Files\Microsoft Office\Office
Advent Tower PC\C\Program Files\Microsoft Office\Office\1033


Now I want my DB query to search for directories .. here's a sample query select * from ff_files where full_path like 'Advent Tower PC\C\freeserve\help\images\%'

doesnt work as the % is taken as a literal '%'

I've aslso tried
like 'Advent Tower PC\\C\\freeserve\\help\\images\%'

I'm completely lost ..
all I want is to return all rows that start with
'Advent Tower PC\C\freeserve\help\images\'

tia
Pete

--- End Message ---
--- Begin Message ---
I believe the \ preceding the last % makes it a literal % not the wildcard %

"pete M" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've got a database table with a whole list of "windows" file paths.
>
> eg
> Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Binder.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Excel.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Office 
> Setup.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Outlook.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\Microsoft PowerPoint.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Word.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\MS Access Workgroup 
> Administrator.lnk
> Advent Tower PC\C\Program Files\Microsoft Office\MSCREATE.DIR
> Advent Tower PC\C\Program Files\Microsoft Office\OF97SPEC.INI
> Advent Tower PC\C\Program Files\Microsoft Office\Office
> Advent Tower PC\C\Program Files\Microsoft Office\Office\1033
>
>
> Now I want my DB query to search for directories .. here's a sample query
> select * from ff_files
> where full_path
> like 'Advent Tower PC\C\freeserve\help\images\%'
>
> doesnt work as the % is taken as a literal '%'
>
> I've aslso tried
> like 'Advent Tower PC\\C\\freeserve\\help\\images\%'
>
> I'm completely lost ..
> all I want is to return all rows that start with
> 'Advent Tower PC\C\freeserve\help\images\'
>
> tia
> Pete 

--- End Message ---
--- Begin Message ---
When trying to send mail via localhost I get the following error

Warning: mail() [function.mail]: SMTP server response: 550 5.7.1


Any ideas?/


RH 

--- End Message ---

Reply via email to