[PHP-DB] cookies and Global variables

2002-06-06 Thread Dib, Walid (MED, Stagiaire GEMS)

Hello


1) I want to use cookies for my site, how can I do it? My browser warn me
that headers are already sent!!

2) How can I use the same variables on all pages:
for example: $login, I need this variable on all pages to send
requests to a MySQL database.


Thanks 


DIB Walid







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


[PHP-DB] Mysql and DBF files

2002-06-06 Thread Achilleas Maroulis

Hi. I have a problem that I hope some of you may have an answer...

I'd like to use some dbf files I created using clipper with php and mysql. I don't 
want to transform the data from one database to another but I want to have access to 
them by both php and another program built with clipper at the same time. I was told 
that this is possible with ODBC drivers but haven't actually tried yet.

Does anyone here know something about this?


Thanx in advance...
Achilles



Re: [PHP-DB] Mysql and DBF files

2002-06-06 Thread Achilleas Maroulis

Than you very much. I'm talking about dbase files so it must work...



- Original Message -
From: Viliam Frtala [EMAIL PROTECTED]
To: Achilleas Maroulis [EMAIL PROTECTED]
Sent: Wednesday, June 06, 2001 1:14 PM
Subject: RE: [PHP-DB] Mysql and DBF files


 if it's like dbase DBF files, then it works with php ...
 you must have right library ( php_dbase.dll )  in the extensions library
 directory..
 look in the manual for commands working with DBF files 

 -Puvodni zprava-
 Od: Achilleas Maroulis [mailto:[EMAIL PROTECTED]]
 Odeslano: 6. juna 2002 11:52
 Komu: [EMAIL PROTECTED]
 Predmet: [PHP-DB] Mysql and DBF files


 Hi. I have a problem that I hope some of you may have an answer...

 I'd like to use some dbf files I created using clipper with php and mysql.
I
 don't want to transform the data from one database to another but I want
to
 have access to them by both php and another program built with clipper at
 the same time. I was told that this is possible with ODBC drivers but
 haven't actually tried yet.

 Does anyone here know something about this?


 Thanx in advance...
 Achilles




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




[PHP-DB] RE: [PHP] date problem

2002-06-06 Thread Dan Hardiker

 SELECT COUNT(*) AS c
 FROM users_table
 WHERE UNIX_TIMESTAMP( user_regdate )  '1022882400'

 The only way you can do it with a char column is to select the entire
 database, load it into a PHP array, using strtotime() to (hopefully)
 convert May 29, 2002, etc, into a unix timestamp, and then sort by
 that timestamp.


Alternatively you could use the query you are now (if its returning the
correct subset of rows from the table). Replace COUNT(*) AS c with your
primary key field (eg: id), and then use mysql_count_row() [rtfm for more
details] rather than pulling the rows. From here it looks like your
fastest option, but your not providing enough information.

-- 
Dan Hardiker [[EMAIL PROTECTED]]
ADAM Software  Systems Engineer
First Creative Ltd



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




[PHP-DB] Re: cookies and Global variables

2002-06-06 Thread Michael Stolovitzsky

Walid Dib wrote:

 Hello
 
 
 1) I want to use cookies for my site, how can I do it? My browser warn me
 that headers are already sent!!
 

output buffering

 2) How can I use the same variables on all pages:
 for example: $login, I need this variable on all pages to send
 requests to a MySQL database.

global variables
sessions

It's all in the manual.
 
 
 Thanks
 
 
 DIB Walid

-- 
PHP is a real-world language whose sole purpose is to solve very real-world 
problems - Rasmus Lerdof

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




RE: [PHP-DB] cookies and Global variables

2002-06-06 Thread Gary . Every

When you get the Header already sent error, that means that you are trying
to send header info, e.g. cookie info AFTER you've already sent some header
info. This is usually seen when your php script has an include in it (above
your cookie stuff) that contains some html. Check your includes, and make
sure that the header info is the first thing sent.


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


-Original Message-
From: Dib, Walid (MED, Stagiaire GEMS) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 06, 2002 2:06 AM
To: '[EMAIL PROTECTED]'
Subject: [PHP-DB] cookies and Global variables


Hello


1) I want to use cookies for my site, how can I do it? My browser warn me
that headers are already sent!!

2) How can I use the same variables on all pages:
for example: $login, I need this variable on all pages to send
requests to a MySQL database.


Thanks 


DIB Walid








[PHP-DB] Deleting old sess_... files from /tmp dir

2002-06-06 Thread Tim Haak

Hello,

We're trying to use session variables to store a user's database login
information.  I am wondering how to automatically delete the old sess_...
files from the /tmp directory which are used by PHP to store session
variables.  Is there a way to set PHP to do this?  I've tried setting the
session.gc_maxlifetime in the php.ini to a lower number, but had no luck.

I suppose a last resort is a script that runs in cron to delete the old
files.

Our environment is:  Solaris 7, PHP 4.1.2, Apache 1.3.22.

Thanks in advance for any advice you may have.

Tim Haak


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




Re: [PHP-DB] Deleting old sess_... files from /tmp dir

2002-06-06 Thread Jason Wong

On Thursday 06 June 2002 21:47, Tim Haak wrote:
 Hello,

 We're trying to use session variables to store a user's database login
 information.  I am wondering how to automatically delete the old sess_...
 files from the /tmp directory which are used by PHP to store session
 variables.  Is there a way to set PHP to do this?  I've tried setting the
 session.gc_maxlifetime in the php.ini to a lower number, but had no luck.

 I suppose a last resort is a script that runs in cron to delete the old
 files.

In the normal course of operation php will automatically delete the expired 
sessions.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
One seldom sees a monument to a committee.
*/


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




Re: [PHP-DB] a (my)sql sort

2002-06-06 Thread Jeffrey_N_Dyke


ok, i have a query that is like so
select distinct(id), MIN(time), MAX(time), count(page), ip,
(UNIX_TIMESTAMP(MAX(time)) - UNIX_TIMESTAMP(MIN(time))) from trainingHit
group by id

and i really want to sort on the time difference, but i get an error that
states invalid use of group function if i sort on
(UNIX_TIMESTAMP(MAX(time)) - UNIX_TIMESTAMP(MIN(time))), and 0 values if i
call this something like val and sort on that.  But i can call it 'val'
and that is returned correctly in the result set.

Any ideas?
Thanks in advance.
Jd



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




[PHP-DB] help with mssql interaction

2002-06-06 Thread Chris Hohimer

i am using Mac Os X to run PHP and connect to several databases.
I compiled PHP4.1.2 from source
i added the extensions --with-apxs and --with-mysql

I interact with a mysql database on localhost(me) but i also
need the page to interact with a mssql 2000 server elsewhere
on site. When i code

mssql_connect($host, $username, $password);

it says undefined function mssql_connect()
At first I thought i was because i didn't load a mssql extension
when i compiled it but that is not the case since i can't find one
in the --help.

Any advice??
thanks

Chris Hohimer
Sandia National Laboratories
CSU821 ORG9623



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




[PHP-DB] fopen() question

2002-06-06 Thread Tony

I have a database and I am writing a script to auto-update some information
in the database.
That requires me to read data from database, find the URL, read the URL,
find the information I want, then update it in the database.
My problem is, for example I read one record from database who's URL is
http://www.somedomain.com/.
And I try to read the URL with fopen() for information:

$fp = fopen(³http://www.comedomain.com/², ³r²);

if (!$fp)
{
echo ³URL not available.²;
exit;
}

If the URL is available, things will work fine.
But if the URL is NOT available, I will get a error saying ³attempt to load
file ³MyFile¹s URL² failed² from browser.
It¹s supposed to output the string ³URL not available², isn¹t it?
Anyone know how to get around with this?


Tony S. Wu
[EMAIL PROTECTED]


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




Re: [PHP-DB] fopen() question

2002-06-06 Thread Bogdan Stancescu

Also, if you check many URL's from the same script, make sure neither 
PHP nor the browser times out. For PHP, set_time_limit() and for the 
browser echo a space and flush() after each test.

Bogdan

Bogdan Stancescu wrote:

 Try $fp=@fopen( etc

 Bogdan

 Tony wrote:

 I have a database and I am writing a script to auto-update some 
 information
 in the database.
 That requires me to read data from database, find the URL, read the URL,
 find the information I want, then update it in the database.
 My problem is, for example I read one record from database who's URL is
 http://www.somedomain.com/.
 And I try to read the URL with fopen() for information:

 $fp = fopen(³http://www.comedomain.com/², ³r²);

 if (!$fp)
 {
echo ³URL not available.²;
exit;
 }

 If the URL is available, things will work fine.
 But if the URL is NOT available, I will get a error saying ³attempt 
 to load
 file ³MyFile¹s URL² failed² from browser.
 It¹s supposed to output the string ³URL not available², isn¹t it?
 Anyone know how to get around with this?


 Tony S. Wu
 [EMAIL PROTECTED]


  









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




[PHP-DB] MySQL problem on Yellow Dog Linux

2002-06-06 Thread Garrett Nelson

I'm a relative newbie to the Linux/web server world, having worked with Macs
most of my life. I recently installed the Server install of Yellow Dog
Linux, with no window managers, CLI only. Everything is working pretty much
correctly, except PHP interaction with MySQL. When I tried to install
Invision Board, I got the following error‹

Fatal error: Call to undefined function: mysql_connect() in
/var/www/default/forums/sm_install.php on line 249

I figured this meant MySQL or PHP was configured incorrectly so I installed
PhpMyAdmin to see if that would work, and I got the error message

cannot load MySQL extension,
please check PHP Configuration.

What needs to be configured? I was under the impression that MySQL support
was built into PHP now and that it needs no extension. I downloaded the RPM
of PHP 4.1.2 (the latest PPC RPM available at rpmfind) and it told me it was
already installed. I then installed MySQL 3.23.41 to no effect.

So what can I do to fix this?

-- 



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




Re: [PHP-DB] MySQL problem on Yellow Dog Linux

2002-06-06 Thread Paul Burney

on 6/6/02 4:36 PM, Garrett Nelson at [EMAIL PROTECTED] appended the
following bits to my mbox:

 What needs to be configured? I was under the impression that MySQL support
 was built into PHP now and that it needs no extension. I downloaded the RPM
 of PHP 4.1.2 (the latest PPC RPM available at rpmfind) and it told me it was
 already installed. I then installed MySQL 3.23.41 to no effect.

Well, the MySQL library comes bundled with PHP, but to actually build in
support, you need to configure it with --with-MySQL.

I'm not a big RPM guy, but you should probably look for an RPM for PHP that
mentions MySQL as well.

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php

// the statement formerly known as prince
if ($the_elevator == 'tries to bring you down') {
go_crazy('punch a higher floor');
} 

?



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




[PHP-DB] Weird intermittent No Database Selected problem

2002-06-06 Thread Jeff Field

Help!

I've been having a weird problem today (and maybe it's been there all along,
just haven't noticed...it's only been live a few days).  I have a web page
that allows users to query my database by either subject or alphabet (A-Z).
Today (and I think I noticed it once before but didn't pay much attention),
if you do a query, the first time it comes back with the results.  The
second time, clicking the same letter (or sometimes other letters), for
instance, it comes back with a Database Not Selected error.  Or, every
time in a row for a dozen times it comes back with a Database Not Selected
error.  Or, sometimes it comes back with the results just fine for twenty
times in a row. Or, ...

You get the idea.  It doesn't happen all the time, just sometimes, and in no
particular order.  Very strange because I'm not changing a dang thing.
Anyway, I've already tried rebooting the server, no change.  And, I've tried
accessing the web page from other machines, same problem.  Has anyone ever
run into this?

I'm running Red Hat 7.2, Apache 1.3.23, MySQL 3.23.49a, and PHP 4.2.1.

Here's the code in the web page with only some name changes (for security,
ya know):

?php
function Query()
{
global $mydb, $recordset, $total_rows, $letter;
$letter = $_GET['letter'];
mysql_select_db($database_mydb, $mydb);
$query = sprintf(SELECT name
FROM tbl_mytable
WHERE name LIKE %s
ORDER BY name ASC,
SQLStr($letter . %, text));
$recordset = mysql_query($query, $mydb) or die(mysql_error());
$total_rows = mysql_num_rows($recordset);
}
?

And then the code in my include where I keep all the db connection stuff:

?php
$hostname_mydb = localhost;
$database_mydb = mydb;
$username_mydb = user;
$password_mydb = ;
$mydb= mysql_pconnect($hostname_mydb, $username_mydb, $password_mydb) or
die(mysql_error());
?

Any help is appreciated!!  Thanks!

Jeff


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




[PHP-DB] Splitting a string and placing the contents into a form pulldown

2002-06-06 Thread Chris Payne

Hi there everyone,

I have this pattern in a mysql db:

 Deluxe double £165.00 prpnbrbrSingle £128.00 prpnbrbrTriple
£229.00 prpn

What I need to do is to remove the br but where there br's are
should be the end of a string, so in this case I should have an Array
(?) of 3 items.

My question is, how, from this 1 line, can I split it into 3 options and
place it in a pulldown box in my form?  I have no choice but to use the
info in this format as it is for a company who displays this information
in a webpage, (hence the br's) but need the same info to populate a
dropdown menu for selection.  Sigh, they never make it easy for me :-)

I know what needs to be done, but don't know how to do it :-(

Thanks for everything, it's really appreciated.

Chris

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002
 


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




RE: [PHP-DB] Splitting a string and placing the contents into a form pulldown

2002-06-06 Thread Shrock, Court

use explode() by doing something in the gist of:

$options = explode('brbr', $line);
echo 'selectoption'.join('/optionoption',
$options).'/option/select';

-Original Message-
From: Chris Payne
To: [EMAIL PROTECTED]
Sent: 6/6/02 5:25 PM
Subject: [PHP-DB] Splitting a string and placing the contents into a form
pulldown

Hi there everyone,

I have this pattern in a mysql db:

 Deluxe double £165.00 prpnbrbrSingle £128.00 prpnbrbrTriple
£229.00 prpn

What I need to do is to remove the br but where there br's are
should be the end of a string, so in this case I should have an Array
(?) of 3 items.

My question is, how, from this 1 line, can I split it into 3 options and
place it in a pulldown box in my form?  I have no choice but to use the
info in this format as it is for a company who displays this information
in a webpage, (hence the br's) but need the same info to populate a
dropdown menu for selection.  Sigh, they never make it easy for me :-)

I know what needs to be done, but don't know how to do it :-(

Thanks for everything, it's really appreciated.

Chris

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002
 


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

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




[PHP-DB] Splitting a string and placing the contents into a form pulldown Solved

2002-06-06 Thread Chris Payne

Hi there everyone,

I've found a solution that works for me for the problem I was having
earlier with splitting a string and then having populate a dropdown box.
I don't have time to add it to the page requested earlier as I am really
rushed off my feet so if the guy who requested it could do it, that
would be great :-)

Here's how I solved my problem, probably a better way, but this works.

I have the following string:

 Deluxe double £165.00 prpnbrbrSingle £128.00 prpnbrbrTriple
£229.00 prpn

And I needed to take out the BR's and have each item in an array, then
populate a form pulldown field.  In short, here's the code I used in the
end - if anyone can see a better way I'll be all ears :-)  Though this
is short, sweet and does what it needs to do.

$last_minute_room_rates = str_replace(br, ,
$last_minute_room_rates);
$keywords = preg_split ('prpn', $last_minute_room_rates);

and for the form:

  select name=RoomType?
  foreach ($keywords as
$keywords) { ?
option
value=?=$keywords??=$keywords?/option? } ?
  /select
  prpn /td

As you can see, I used the common prpn (Per room per night) at the end
of each item as a reference for the new Array item.  This removed the
prpn from the dropdown but I solved that by simply hardcoding that to
the right of the dropdown box :-)

Regards

Chris Payne

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002
 


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




[PHP-DB] RE: [PHP] Weird intermittent No Database Selected problem

2002-06-06 Thread Jeff Field

Thanks for the help, all!  Here was the problem...I think, I'm pretty sure,
eh?

In mysql_select_db($database_mydb, $mydb), I have the variable,
$database_mydb, which is actually something that Macromedia's Dreamweaver
MX created (for those that don't know it, Dreamweaver MX supports a little
PHP).

Well, not to put the blame on Macromedia, it was all my fault and I now feel
a bit stupid, I think it all boiled down to $database_mydb not being
declared global in the function I wrote to do the query.

Funny that it worked probably 95% of the time.  Must have been due to
mysql_pconnect or something holding open previous connections to the db and
the script just connecting to the last connected db.  Anyway...

Sorry for the trouble!

Jeff

 -Original Message-
 From: hugh danaher [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 06, 2002 5:37 PM
 To: [EMAIL PROTECTED]
 Cc: php
 Subject: Re: [PHP] Weird intermittent No Database Selected problem


 Are all the variables needed for the function getting into your
 call_user_func()?  Also, perhaps some aren't set or are being
 unset outside
 your function--say, you are opening a new page and not passing all the
 variables to it.  The function (which apparently works) isn't getting set
 variables.  Try echoing the input variables just above the
 function call and
 see if they're all there.
 Hope this helps,
 Hugh

 - Original Message -
 From: Jeff Field [EMAIL PROTECTED]
 To: Php-General (E-mail) [EMAIL PROTECTED]
 Sent: Thursday, June 06, 2002 2:34 PM
 Subject: RE: [PHP] Weird intermittent No Database Selected problem


  Hmmm...not sure how to check the status of the db function calls (sorry,
 I'm
  relatively new to PHP, help on this is appreciated), but I did add the
  following to the script:
 
  echo Error  . mysql_errno ( ). :  . mysql_error ( );
 
  It prints out Error 0: when the script runs just fine, but
 nothing when
  the page comes back with No Database Selected.
 
  Any thoughts?  Thanks!
 
  Jeff
 
   -Original Message-
   From: Scott Hurring [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, June 06, 2002 4:15 PM
   To: Php-General (E-mail)
   Subject: RE: [PHP] Weird intermittent No Database Selected problem
  
  
   I assume you're not checking the status returned by the
   database function calls, becuase they'd probably give
   you valueable information on *why* it's doing that.  :)
  
   try checking the return val, and (if using mysql) print
   out mysql_error() if you get a bad return val.
  
   ---
   Scott Hurring
   Systems Programmer
   EAC Corporation
   [EMAIL PROTECTED]
   Voice: 201-462-2149
   Fax: 201-288-1515
  
-Original Message-
From: Jeff Field [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 06, 2002 4:58 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Weird intermittent No Database Selected problem
   
   
I apologize...I just posted this to the database list but
then realized it
may not be a database issue, so thought I'd better give it a
shot over here.
   
Help!
   
I've been having a weird problem today (and maybe it's been
there all along,
just haven't noticed...it's only been live a few days).  I
have a web page
that allows users to query my database by either subject or
alphabet (A-Z).
Today (and I think I noticed it once before but didn't pay
much attention),
if you do a query, the first time it comes back with the
 results.  The
second time, clicking the same letter (or sometimes other
letters), for
instance, it comes back with a Database Not Selected error.
 Or, every
time in a row for a dozen times it comes back with a
Database Not Selected
error.  Or, sometimes it comes back with the results just
fine for twenty
times in a row. Or, ...
   
You get the idea.  It doesn't happen all the time, just
sometimes, and in no
particular order.  Very strange because I'm not changing a
 dang thing.
Anyway, I've already tried rebooting the server, no change.
And, I've tried
accessing the web page from other machines, same problem.
Has anyone ever
run into this?
   
I'm running Red Hat 7.2, Apache 1.3.23, MySQL 3.23.49a, and
 PHP 4.2.1.
   
Here's the code in the web page with only some name changes
(for security,
ya know):
   
?php
function Query()
{
global $mydb, $recordset, $total_rows, $letter;
$letter = $_GET['letter'];
mysql_select_db($database_mydb, $mydb);
$query = sprintf(SELECT name
FROM tbl_mytable
WHERE name LIKE %s
ORDER BY name ASC,
SQLStr($letter . %, text));
$recordset = mysql_query($query, $mydb) or
die(mysql_error());
$total_rows = mysql_num_rows($recordset);
}
?
   
And then the code in my include where I keep all the db
connection stuff:
   
?php
$hostname_mydb = localhost;
$database_mydb = mydb;
$username_mydb = user;
$password_mydb = ;