[PHP-DB] RE: Save mySQL data into a CSV file.

2003-06-17 Thread Colin Williams
Hi,

You can use a content header to instruct the browser to treat output as an attachment 
for saving.  Use something like the following:



(These *must* be the first lines output by your script)


Then in the body of the script, do something like this:



Note the commas between each value, and also the '\n' which sends a newline to end 
each row.  If the user is running Windows with Excel installed, they will be given a 
choice of opening the file in Excel or saving it.


This works for me using Internet Explorer.  Mozilla appends a .txt to the filename (so 
you get 'filename.csv.txt').  Does anyone else know how to prevent the .txt being 
added by Mozilla?


Hope this helps,

Colin Williams.




-Original Message-
From: Martin E. Koss [mailto:[EMAIL PROTECTED]
Sent: 16 June 2003 13:53
To: [EMAIL PROTECTED]
Subject: Save mySQL data into a CSV file.


Hi,
I have a table with 1,008 columns in it and at it's peak it has up to 500
rows of data.
I want to enable my client to click on a link and the next thing they are
prompted with is 'Save or Open' (the CSV file).
The data will be compiled into a comma delimited CSV file but rather than be
printed to the screen it would be best if the browser popped up asking where
to save the 'filename.csv' file to. Once saved, the file can be opened in
Excel for analysis.

Where do I start to do this?

Thanks

Martin



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



Re: [PHP-DB] Password generator

2003-06-17 Thread Ramil G. Sagum
> a simple way would be to :


$pass = $allowable_characters[mt_rand(0,$ps_len-5)]
for($i = 0; $i < ($length -2); $i++) {
  $pass .= $allowable_characters[mt_rand(0,$ps_len-1)];
 }
$pass .= $allowable_characters[mt_rand(0,$ps_len-5)]



// This variable contains the list of allowable characters
// for the password.  Note that the number 0 and the letter
// 'O' have been removed to avoid confusion between the two.
// The same is true of 'I' and 1

> btw, you didn't implement this.

hope this helps


ramil


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



[PHP-DB] time without seconds

2003-06-17 Thread Lisi
If I have a time stored in MySQL, and I only need the hour and minutes 
without seconds:

1) Can I crop this in PHP after retrieving it?

2) Is there a way to store this without the seconds in MySQL?

Same goes for storing a date without the year. I could use a regular char 
field, but I want to be able to retrieve a row that corresponds to the 
current month and day, currently I am doing this with

$month = date("n");
$day = date("d");
$query = "SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day";
Is there a better way to do this without storing unnecessary data?

Thanks,

-Lisi

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


Re: [PHP-DB] time without seconds

2003-06-17 Thread Ignatius Reilly
Check the TIME_FORMAT(time,format) MySQL function.

Ignatius
_
- Original Message -
From: "Lisi" <[EMAIL PROTECTED]>
To: "PHP-DB" <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 1:16 PM
Subject: [PHP-DB] time without seconds


> If I have a time stored in MySQL, and I only need the hour and minutes
> without seconds:
>
> 1) Can I crop this in PHP after retrieving it?
>
> 2) Is there a way to store this without the seconds in MySQL?
>
> Same goes for storing a date without the year. I could use a regular char
> field, but I want to be able to retrieve a row that corresponds to the
> current month and day, currently I am doing this with
>
> $month = date("n");
> $day = date("d");
> $query = "SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day";
>
> Is there a better way to do this without storing unnecessary data?
>
> Thanks,
>
> -Lisi
>
>
> --
> 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] Testing - please ignore

2003-06-17 Thread Milan Babuskov
It seems that my previous post didn't reach the ML, so I'm trying to see 
if it works.

Sorry.





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


[PHP-DB] FW: Call to undefined function: mysql_connect

2003-06-17 Thread Idan Dolev


>  -Original Message-
> From: Idan Dolev  
> Sent: Tuesday, June 17, 2003 2:52 PM
> To:   '[EMAIL PROTECTED]'
> Subject:  Call to undefined function: mysql_connect
> 
> HI,
> I am using redhat 9 2.4.20-9 kernel and the following rpm's
> MySQL-devel-4.0.13-0
> MySQL-server-4.0.13-0
> MySQL-client-4.0.13-0
> MySQL-shared-3.23.51-1
> php-mysql-4.2.2-17
> 
in my phpinfo file I see --with-mysql

> I get the  following error when I try to access my php page:
> 
> Fatal error: Call to undefined function: mysql_connect() in 
> 
> help
> 
> Idan

---
This e-mail message may contain confidential, commercial and privileged information or 
data that constitute proprietary information of Cellcom Israel Ltd. Any review or 
distribution by others is strictly prohibited. If you are not the intended recipient 
you are hereby notified that any use of this information or data by any other person 
is absolutely prohibited. If you are not the intended recipient, please delete all 
copies and contact us by e-mailing to: [EMAIL PROTECTED]
Thank You.




[PHP-DB] Password generator

2003-06-17 Thread Davy Obdam
Hi people,

I have to make a password generator, but i have a little problem.

- It needs to generate password 8 characters long, and including 1 or 2 
special characters(like #$%&*@).
- Those special characters can never appear as the first or last 
character in the string... anywhere between is fine.

I have a password generator script now that does the first thing... but 
the special character can be in front or back of the string wich it 
shouldnt.. i have been looking on the web for this but i havent found 
the answer. Below is my scripts so far.. 

Any help is appreciated, thanks for your time,

Best regards,

Davy Obdam




   // This variable contains the list of allowable characters
   // for the password.  Note that the number 0 and the letter
   // 'O' have been removed to avoid confusion between the two.
   // The same is true of 'I' and 1
   $allowable_characters = "abcdefghefghijklmnopqrstuvwxyz0123456789%#*&";
  
   // We see how many characters are in the allowable list
   $ps_len = strlen($allowable_characters);

   // Seed the random number generator with the microtime stamp
   // (current UNIX timestamp, but in microseconds)
   mt_srand((double)microtime()*100);
   // Declare the password as a blank string.
   $pass = "";
   // Loop the number of times specified by $length
   for($i = 0; $i < $length; $i++) {
  
   // Each iteration, pick a random character from the
   // allowable string and append it to the password.
   $pass .= $allowable_characters[mt_rand(0,$ps_len-1)];
  
   }

   // Retun the password we've selected
   return $pass;
}
$password = generate_password();
echo $password;
?>

--
---
Davy Obdam 
Web application developer

Networking4all
email: [EMAIL PROTECTED]
email: [EMAIL PROTECTED]
internet: http://www.networking4all.com
---


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


[PHP-DB] 4.2.3 session login problem...

2003-06-17 Thread NIPP, SCOTT V (SBCSI)
I have an application that is currently working fine under 4.1.2,
and I am in the process of upgrading to 4.2.3.  The problem is that after
upgrading PHP the application login no longer works.  Additionally, this
same application works fine on another machine running 4.2.3.  The only
difference in the machines is that the working one uses PHP as a static
module and the broken one uses PHP as a loadable module.  Anyone run into
this problem before?  Thanks in advance.

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



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



[PHP-DB] ODBC conection with DB2

2003-06-17 Thread Norma Ramirez - TECNOSOFT
Hi, I need to do a ODBC conexión with DB2 over AS400 for a php aplication, my 
aplication is in a web server wiht linux red hat 7.0, I´ve
 already downloaded the unixODBC driver and the iSeriesODBC from IBM page, but when I 
run the installation 
command: rpm -ivh iSeriesODBC-5.1.0-0.xx..rpm. I´get this error:
odbcinst: iniOpen failed on /unixodbcregistration.
Could someone help??? 
Thank´s.
Norma Ramirez



Re: [PHP-DB] 4.2.3 session login problem...

2003-06-17 Thread CPT John W. Holmes
> I have an application that is currently working fine under 4.1.2,
> and I am in the process of upgrading to 4.2.3.  The problem is that after
> upgrading PHP the application login no longer works.  Additionally, this
> same application works fine on another machine running 4.2.3.  The only
> difference in the machines is that the working one uses PHP as a static
> module and the broken one uses PHP as a loadable module.  Anyone run into
> this problem before? 

Yes, I have. Your problem is on line 325.

---John Holmes...

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



[PHP-DB] MySQL Transaction

2003-06-17 Thread Becoming Digital
A question was raised on the MySQL list about implementing transactions with
PHP.  I had planned on them for an upcoming project but I'd yet to figure out
how I'd coordinate things.

The original author's solution (slightly altered) was to make an array with all
the queries and loop through them, setting a boolean flag and exiting the loop
if a query fails.  Testing for the value of the flag would execute a commit or
rollback according to its value.

I think this is a decent solution, but I'm wondering what some of you are using.
A search of the Classes Repository yielded only one class, the comments for
which are written in Spanish.  I've included a link below for those who are
interested.
http://promoxy.mirrors.phpclasses.org/browse.html/file/3077.html

Edward Dudlik
Becoming Digital
www.becomingdigital.com




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



[PHP-DB] Best way to pass multiple selections to a DB

2003-06-17 Thread Creative Solutions New Media
Hello,

Can anyone enlighten me as to some techniques for transferring information
from a multiple select list box to mySQL.

Someone recommended something about using join tables for this (which I have
no idea how to set up).

Thanks

Tim Winters
Manager, Creative Development
Sampling Technologies Incorporated (STI)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
W: 902 450 5500
C:  902 430 8498




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



RE: [PHP-DB] Best way to pass multiple selections to a DB

2003-06-17 Thread Hutchins, Richard
Tim,

You need to name your multiple select box as an array (e.g. selectThis[]).
The values will be passed as an array to the next page. You then need to
iterate over that array and pass the values into the database.

There's plenty of info on how to pull this off in the archives on PHP.NET
just search for select box or multiple select or the like and you should get
plenty of hits with code and summaries and the whole smash.

Rich

> -Original Message-
> From: Creative Solutions New Media [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 17, 2003 2:53 PM
> To: PHP-DB
> Subject: [PHP-DB] Best way to pass multiple selections to a DB
> 
> 
> Hello,
> 
> Can anyone enlighten me as to some techniques for 
> transferring information
> from a multiple select list box to mySQL.
> 
> Someone recommended something about using join tables for 
> this (which I have
> no idea how to set up).
> 
> Thanks
> 
> Tim Winters
> Manager, Creative Development
> Sampling Technologies Incorporated (STI)
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> W: 902 450 5500
> C:  902 430 8498
> 
> 
> 
> 
> -- 
> 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



Re: [PHP-DB] Best way to pass multiple selections to a DB

2003-06-17 Thread Becoming Digital
> Can anyone enlighten me as to some techniques for transferring information
> from a multiple select list box to mySQL.

Not knowing how you need to insert the values (multiple entries, values in
multiple fields), I would generate an array of the selections and loop through,
either running individual queries or building your multi-value query string.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message -
From: "Creative Solutions New Media" <[EMAIL PROTECTED]>
To: "PHP-DB" <[EMAIL PROTECTED]>
Sent: Tuesday, 17 June, 2003 14:52
Subject: [PHP-DB] Best way to pass multiple selections to a DB


Hello,

Can anyone enlighten me as to some techniques for transferring information
from a multiple select list box to mySQL.

Someone recommended something about using join tables for this (which I have
no idea how to set up).

Thanks

Tim Winters
Manager, Creative Development
Sampling Technologies Incorporated (STI)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
W: 902 450 5500
C:  902 430 8498




--
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] problem witd freetds

2003-06-17 Thread Alvaro Rosales R.
HI guys I have installed freetds and compiles php4 withmssql support. But when I ty 
to make a query from a web page it doest work , freetds is working fine cbecause I 
have tested it with tsql. 
My page looks like this: 

\n"); 
$numero2= mssql_select_db ( northwind ,northwind) 

$result=mssql_query("select * from customers",$numero ); 
while ($row=mssql_fetch_array($result)) { 
$counter++; 
$c1=$row["colonna1"]; 
$c2=$row["colonna2"]; 
echo ("$counter c1: $c1 c2: $c2\n"); 
} 

$result=mssql_query("INSERT into customers 
values('ko','ook')",$numero); 

mssql_close($numero); 

?> 

and I get this error 
Parse error: parse error in /usr/local/www/data.default/test.php on line 4. 

Any hints would be appreciated



[PHP-DB] PHP-DB - calling c function from php app

2003-06-17 Thread Mignon Hunter
Can anyone make a suggestion on how to connect to a c function from a
php app?

I have to connect to sales tax calculation software.  The function
is being written for me but I have to figure how to call it - get the
variable - and use it again in my php app.

Is this even possible ??

Thx
-- 



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



RE: [PHP-DB] problem witd freetds

2003-06-17 Thread Jennifer Goodie
> Parse error: parse error in /usr/local/www/data.default/test.php ]

The parser is complaining about this line
> $numero= mssql_connect("130.102.1.88" "sa" , " " ); 

Try putting a comma between your arguments
$numero= mssql_connect("130.102.1.88", "sa", " " ); 

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



[PHP-DB] Re: PHP-DB - calling c function from php app

2003-06-17 Thread Hugh Bothwell
"Mignon Hunter" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Can anyone make a suggestion on how to connect to a c function from a
> php app?
>
> I have to connect to sales tax calculation software.  The function
> is being written for me but I have to figure how to call it - get the
> variable - and use it again in my php app.
>
> Is this even possible ??


How complex is this function?  And how often might it change?

If it is reasonably simple, it might be worth coding
directly in php.  Slightly longer, and you could compile
the C program and exec() it; or, more efficiently, you
could look at the source to the php extensions and
figure out how to turn it into an extension.

If it's really a monster, or is part of a commercial
package, it might be worth exposing it as a web
service; then your script can call it using a
well-documented interface.

--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+



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



RE: [PHP-DB] Best way to pass multiple selections to a DB

2003-06-17 Thread Creative Solutions New Media
Thanks Richard and Edward,

The naming of the list box as an array works great for passing the data
around. Thanks.

As for exactly what I need to do with the data I'm not exactly sure myself.
PHP and mySQL is a bit new to me.

I may be back for more help but for now thanks for the unbelievably quick
and helpful replies

Have a DAY

Respectfully,

Tim Winters
Manager, Creative Development
Sampling Technologies Incorporated (STI)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
W: 902 450 5500
C:  902 430 8498

-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
Sent: June 17, 2003 3:57 PM
To: '[EMAIL PROTECTED]'; PHP-DB
Subject: RE: [PHP-DB] Best way to pass multiple selections to a DB

Tim,

You need to name your multiple select box as an array (e.g. selectThis[]).
The values will be passed as an array to the next page. You then need to
iterate over that array and pass the values into the database.

There's plenty of info on how to pull this off in the archives on PHP.NET
just search for select box or multiple select or the like and you should get
plenty of hits with code and summaries and the whole smash.

Rich

> -Original Message-
> From: Creative Solutions New Media [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 17, 2003 2:53 PM
> To: PHP-DB
> Subject: [PHP-DB] Best way to pass multiple selections to a DB
>
>
> Hello,
>
> Can anyone enlighten me as to some techniques for
> transferring information
> from a multiple select list box to mySQL.
>
> Someone recommended something about using join tables for
> this (which I have
> no idea how to set up).
>
> Thanks
>
> Tim Winters
> Manager, Creative Development
> Sampling Technologies Incorporated (STI)
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> W: 902 450 5500
> C:  902 430 8498
>
>
>
>
> --
> 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Updating a MySQL record

2003-06-17 Thread Stephen Sequeira
Hello from North Central University in Minneapolis.

I have two forms. Both relate to required student ministry involvement
(students must be involved in four semesters of Christian ministry to
graduate).

The first is a "credit registration" form which students fill out before
starting a ministry. The second is a "credit evaluation" form which students
fill out after their ministry is over.

Often, when students fill out the registration form, they don't have
accurate information regarding their ministry assignment. So the information
they enter into the evaluation form takes precedent in terms of accuracy.

I would like the data from the evaluation form to update the student's
record (for those fields which overlap).

What I don't want is the evaluation form to create a new record, because
then I would have two records for each student.

How do I: 1) check the table to see if the student's ID has already been
entered, then 2) update the fields in that record with the new data from the
evaluation form?

Thanks for your help.



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



[PHP-DB] Updating a MySQL record

2003-06-17 Thread Stephen Sequeira
Hello from North Central University in Minneapolis.

I have two forms. Both relate to required student ministry involvement
(students must be involved in four semesters of Christian ministry to
graduate).

The first is a "credit registration" form which students fill out before
starting a ministry. The second is a "credit evaluation" form which students
fill out after their ministry is over.

Often, when students fill out the registration form, they don't have
accurate information regarding their ministry assignment. So the information
they enter into the evaluation form takes precedent in terms of accuracy.

I would like the data from the evaluation form to update the student's
record (for those fields which overlap).

What I don't want is the evaluation form to create a new record, because
then I would have two records for each student.

How do I: 1) check the table to see if the student's ID has already been
entered, then 2) update the fields in that record with the new data from the
evaluation form?

Thanks for your help.



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



[PHP-DB] Select Statement with output in different colors.

2003-06-17 Thread Christopher Lyon
I have a php script that does some select statements, on mysql, and
outputs that to a table. I would like to change the color of the table
row depending upon one of the fields. The select statements are from a
syslog database that I have and I would like to highlight key events by
changing the colors for that row. Example would be MAJOR, yellow and
INFO, green. Does anybody have any examples of how to do this?


 

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



RE: [PHP-DB] Select Statement with output in different colors.

2003-06-17 Thread Peter Lovatt
Try this

$query = 'SELECT * FROM table  
$mysql_result = mysql_query($query, $link);

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


 switch ($row["event"] )
 {
 case event_one:
$bg = 'blue'
 break;
 case event_one:
$bg = 'red'
 break;
 case event_one:
$bg = 'green'
 break;
 default:
$bg = 'white'

 }
 
 
 print '
 da da da  
';
 
 
 }// end while




HTH

Peter



-Original Message-
From: Christopher Lyon [mailto:[EMAIL PROTECTED]
Sent: 17 June 2003 22:35
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Select Statement with output in different colors.


I have a php script that does some select statements, on mysql, and
outputs that to a table. I would like to change the color of the table
row depending upon one of the fields. The select statements are from a
syslog database that I have and I would like to highlight key events by
changing the colors for that row. Example would be MAJOR, yellow and
INFO, green. Does anybody have any examples of how to do this?


 

-- 
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] Re: Password generator

2003-06-17 Thread Andrei BEJENARU
Here's a little function that could help you...
It uses the ASCII table to generate the characters and it still needs to be
customized for any length
and to deny the use of the special characters...
Don't forget to set the mt seed!

function generatePassword() {
 $passwd = "";
 while(strlen($passwd)<10) {
  switch(mt_rand(1,4)) {
   case 1:
$tmp = chr(mt_rand(33,46));
if ($tmp!="'" && $tmp!="\"") {
 $passwd .= $tmp;
}
break;
   case 2:
$passwd .= chr(mt_rand(48,57));
break;
   case 3:
$passwd .= chr(mt_rand(65,90));
break;
   case 4:
$passwd .= chr(mt_rand(97,122));
break;
  }
 }
 return $passwd;
}


"Davy Obdam" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi people,
>
> I have to make a password generator, but i have a little problem.
>
> - It needs to generate password 8 characters long, and including 1 or 2
> special characters(like #$%&*@).
> - Those special characters can never appear as the first or last
> character in the string... anywhere between is fine.
>
> I have a password generator script now that does the first thing... but
> the special character can be in front or back of the string wich it
> shouldnt.. i have been looking on the web for this but i havent found
> the answer. Below is my scripts so far..
>
> Any help is appreciated, thanks for your time,
>
> Best regards,
>
> Davy Obdam
>
> --
--
>
>  // A function to generate random alphanumeric passwords in PHP
> // It expects to be passed a desired password length, but it
> // none is passed the default is set to 8 (you can change this)
> function generate_password($length = 8) {
>
> // This variable contains the list of allowable characters
> // for the password.  Note that the number 0 and the letter
> // 'O' have been removed to avoid confusion between the two.
> // The same is true of 'I' and 1
> $allowable_characters =
"abcdefghefghijklmnopqrstuvwxyz0123456789%#*&";
>
> // We see how many characters are in the allowable list
> $ps_len = strlen($allowable_characters);
>
> // Seed the random number generator with the microtime stamp
> // (current UNIX timestamp, but in microseconds)
> mt_srand((double)microtime()*100);
>
> // Declare the password as a blank string.
> $pass = "";
>
> // Loop the number of times specified by $length
> for($i = 0; $i < $length; $i++) {
>
> // Each iteration, pick a random character from the
> // allowable string and append it to the password.
> $pass .= $allowable_characters[mt_rand(0,$ps_len-1)];
>
> }
>
> // Retun the password we've selected
> return $pass;
> }
>
> $password = generate_password();
> echo $password;
>
> ?>
>
> -- 
> ---
> Davy Obdam
> Web application developer
>
> Networking4all
> email: [EMAIL PROTECTED]
> email: [EMAIL PROTECTED]
> internet: http://www.networking4all.com
> ---
>
>
>



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



[PHP-DB] MySQL Connection

2003-06-17 Thread moses . johnson
Hello,

Would be grateful if someone couldkindly point me in the right direction.

Whenever I try to connect to mysql server, I get these messsage back

1.
mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>

2.
mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>

what could be wrong. Help please .

Regards

Moses



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



[PHP-DB] connecting to mySQL - testing server specified does not map to the http://localhost/_MMServerScript/MMHTTPDB.php

2003-06-17 Thread Ildiko Nyari
Hello,
I have installed the PHP, mySQL and Apache on WIN XP, but:

1. when I want to open in the explorer: http://localhost/test.php  I always get a 
download window, and than my Dreamweaver MX opens, and so I can't see the test.php 
file I created in the explorer.

2. When I created a php file in Dreamweaver MX, and I want to connect it to mySQL, I 
have problems with the connection. It doesn't connect, the error always something with 
the:
The testing server specified for this site does not map to the 
http://localhost/_MMServerScript/MMHTTPDB.php Verify that the URL prefix maps to the 
root of the site.

What is wrong? What and how can I do?
I get crazy.
THANKS,
ildiko


Re: [PHP-DB] MySQL Connection

2003-06-17 Thread Ramil G. Sagum
On Wed, 2003-06-18 at 08:16, [EMAIL PROTECTED] wrote:
> Hello,
> 
> Would be grateful if someone couldkindly point me in the right direction.
> 
> Whenever I try to connect to mysql server, I get these messsage back
> 
> 1.
> mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql>
> 
> 2.
> mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
> ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
> mysql>
> 
something must be wrong with your connection string, would you post the
mysql_connect statement here.




> what could be wrong. Help please .
> 
> Regards
> 
> Moses
> 
> 


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



Re: [PHP-DB] connecting to mySQL - testing server specified doesnot map to the http://localhost/_MMServerScript/MMHTTPDB.php

2003-06-17 Thread John W. Holmes
Ildiko Nyari wrote:

I have installed the PHP, mySQL and Apache on WIN XP, but:

1. when I want to open in the explorer: http://localhost/test.php  I always get a download window, and than my Dreamweaver MX opens, and so I can't see the test.php file I created in the explorer.
You don't have PHP/Apache installed correctly. Do normal HTML pages come 
upcorrectly?

2. When I created a php file in Dreamweaver MX, and I want to connect it to mySQL, I 
have problems with the connection. It doesn't connect, the error always something with 
the:
The testing server specified for this site does not map to the 
http://localhost/_MMServerScript/MMHTTPDB.php Verify that the URL prefix maps to the 
root of the site.
No idea about that. Sounds DMX specific.

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

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


Re: [PHP-DB] MySQL Transaction

2003-06-17 Thread John W. Holmes
Becoming Digital wrote:

A question was raised on the MySQL list about implementing transactions with
PHP.  I had planned on them for an upcoming project but I'd yet to figure out
how I'd coordinate things.
The original author's solution (slightly altered) was to make an array with all
the queries and loop through them, setting a boolean flag and exiting the loop
if a query fails.  Testing for the value of the flag would execute a commit or
rollback according to its value.
Sounds like a good solution to me. Sounds like something that could 
easily be passed to a function with a flag to use a transaction or not 
on the group of queries. Sounds good.

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

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


Re: [PHP-DB] time without seconds

2003-06-17 Thread John W. Holmes
Lisi wrote:
If I have a time stored in MySQL, and I only need the hour and minutes 
without seconds:

1) Can I crop this in PHP after retrieving it?
Sure, just chop off the last : and what's after it if in HH:MM:SS 
format, or the last two numbers if in HHMMSS format.

2) Is there a way to store this without the seconds in MySQL?
Not really. You could use DATE_FORMAT or TIME_FORMAT to format the 
date/time without the seconds, though.

Same goes for storing a date without the year. I could use a regular 
char field, but I want to be able to retrieve a row that corresponds to 
the current month and day, currently I am doing this with

$month = date("n");
$day = date("d");
$query = "SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day";
Is there a better way to do this without storing unnecessary data?
I don't think there's any way to not store the year. Just ignore it like 
you're doing.

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

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


Re: [PHP-DB] MySQL Connection

2003-06-17 Thread John W. Holmes
[EMAIL PROTECTED] wrote:

Would be grateful if someone couldkindly point me in the right direction.

Whenever I try to connect to mysql server, I get these messsage back

1.
mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>
2.
mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana";
ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO)
mysql>
what could be wrong. Help please .
1. This has nothing to do with PHP.

2. The user you connected to PHP with does not have permission to GRANT 
privileges.

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

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





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


RE: [PHP-DB] connecting to mySQL - testing server specified does not map to the http://localhost/_MMServerScript/MMHTTPDB.php

2003-06-17 Thread Creative Solutions New Media
PHP is for sure not installed correctly.  I hand a similar problem when I
did the install for the first time.

It was a while agoand I don't remember clearly but I seem to remember
that it had to do with mis-configuring apache for PHP.

Honestly the best solution for all the time it would take is to just
uninstall mySQL and PHP and go at it again following the directions closely.

If you're looking for a handholding process through the installs the book
"Foundation Dreamweaver MX" by Friends of Ed has a great opening on getting
set up with PHP and mySQL.

Tim Winters
Manager, Creative Development
Sampling Technologies Incorporated (STI)
[EMAIL PROTECTED]
[EMAIL PROTECTED]
W: 902 450 5500
C:  902 430 8498

-Original Message-
From: Ildiko Nyari [mailto:[EMAIL PROTECTED]
Sent: June 17, 2003 9:24 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] connecting to mySQL - testing server specified does not
map to the http://localhost/_MMServerScript/MMHTTPDB.php

Hello,
I have installed the PHP, mySQL and Apache on WIN XP, but:

1. when I want to open in the explorer: http://localhost/test.php  I always
get a download window, and than my Dreamweaver MX opens, and so I can't see
the test.php file I created in the explorer.

2. When I created a php file in Dreamweaver MX, and I want to connect it to
mySQL, I have problems with the connection. It doesn't connect, the error
always something with the:
The testing server specified for this site does not map to the
http://localhost/_MMServerScript/MMHTTPDB.php Verify that the URL prefix
maps to the root of the site.

What is wrong? What and how can I do?
I get crazy.
THANKS,
ildiko



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



[PHP-DB] Creating/Populating DB

2003-06-17 Thread Gerard Samuel
Im trying to make an install script that would run under MSSQL.
I could make it either create a database or populate a database.
I can't seem to do both.
Has anyone been able to create and populate a MSSQL database via php in 
one shot??

Thanks

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


Re: [PHP-DB] Select Statement with output in different colors.

2003-06-17 Thread Becoming Digital
Here's a slight alteration to Peter's code in "case" someone isn't familiar with
switch statements.  Ooh, such a bad pun, as if there's any other kind.


da da da  
';
}// end while
?>


Edward Dudlik
Becoming Digital
www.becomingdigital.com


- Original Message -
From: "Peter Lovatt" <[EMAIL PROTECTED]>
To: "Christopher Lyon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, 17 June, 2003 17:42
Subject: RE: [PHP-DB] Select Statement with output in different colors.


Try this

$query = 'SELECT * FROM table
$mysql_result = mysql_query($query, $link);

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


 switch ($row["event"] )
 {
 case event_one:
$bg = 'blue'
 break;
 case event_one:
$bg = 'red'
 break;
 case event_one:
$bg = 'green'
 break;
 default:
$bg = 'white'

 }


 print '
 da da da  
';


 }// end while




HTH

Peter



-Original Message-
From: Christopher Lyon [mailto:[EMAIL PROTECTED]
Sent: 17 June 2003 22:35
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Select Statement with output in different colors.


I have a php script that does some select statements, on mysql, and
outputs that to a table. I would like to change the color of the table
row depending upon one of the fields. The select statements are from a
syslog database that I have and I would like to highlight key events by
changing the colors for that row. Example would be MAJOR, yellow and
INFO, green. Does anybody have any examples of how to do this?




--
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Select Statement with output in different colors.

2003-06-17 Thread Christopher Lyon
Thank you for the heads up. I did notice that is must have a ; after
every variable case entry, e.g. $bg = 'blue'; in order to work right.

That was at least how I had to get it working.



> -Original Message-
> From: Becoming Digital [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 17, 2003 9:51 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Select Statement with output in different
colors.
> 
> Here's a slight alteration to Peter's code in "case" someone isn't
> familiar with
> switch statements.  Ooh, such a bad pun, as if there's any other kind.
> 
>  $query = 'SELECT * FROM table
> $mysql_result = mysql_query($query, $link);
> 
> while($row = mysql_fetch_array($mysql_result))
> {
> switch ($row["event"] )
> {
> case event_one:
> $bg = 'blue'
> break;
> case event_two:
> $bg = 'red'
> break;
> case event_three:
> $bg = 'green'
> break;
> default:
> $bg = 'white'
> }
> print '
> da da da  
> ';
> }// end while
> ?>
> 
> 
> Edward Dudlik
> Becoming Digital
> www.becomingdigital.com
> 
> 
> - Original Message -
> From: "Peter Lovatt" <[EMAIL PROTECTED]>
> To: "Christopher Lyon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Tuesday, 17 June, 2003 17:42
> Subject: RE: [PHP-DB] Select Statement with output in different
colors.
> 
> 
> Try this
> 
> $query = 'SELECT * FROM table
> $mysql_result = mysql_query($query, $link);
> 
> while($row = mysql_fetch_array($mysql_result))
> {
> 
> 
>  switch ($row["event"] )
>  {
>  case event_one:
> $bg = 'blue'
>  break;
>  case event_one:
> $bg = 'red'
>  break;
>  case event_one:
> $bg = 'green'
>  break;
>  default:
> $bg = 'white'
> 
>  }
> 
> 
>  print '
>  da da da  
> ';
> 
> 
>  }// end while
> 
> 
> 
> 
> HTH
> 
> Peter
> 
> 
> 
> -Original Message-
> From: Christopher Lyon [mailto:[EMAIL PROTECTED]
> Sent: 17 June 2003 22:35
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Select Statement with output in different colors.
> 
> 
> I have a php script that does some select statements, on mysql, and
> outputs that to a table. I would like to change the color of the table
> row depending upon one of the fields. The select statements are from a
> syslog database that I have and I would like to highlight key events
by
> changing the colors for that row. Example would be MAJOR, yellow and
> INFO, green. Does anybody have any examples of how to do this?
> 
> 
> 
> 
> --
> 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 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



Re: [PHP-DB] time without seconds

2003-06-17 Thread Lisi
In general, is it better to have MySQL select less using TIME_FORMAT than 
to have PHP crop the info?

-Lisi

At 09:50 PM 6/17/03 -0400, John W. Holmes wrote:
Lisi wrote:
If I have a time stored in MySQL, and I only need the hour and minutes 
without seconds:
1) Can I crop this in PHP after retrieving it?
Sure, just chop off the last : and what's after it if in HH:MM:SS format, 
or the last two numbers if in HHMMSS format.

2) Is there a way to store this without the seconds in MySQL?
Not really. You could use DATE_FORMAT or TIME_FORMAT to format the 
date/time without the seconds, though.

Same goes for storing a date without the year. I could use a regular char 
field, but I want to be able to retrieve a row that corresponds to the 
current month and day, currently I am doing this with
$month = date("n");
$day = date("d");
$query = "SELECT ... WHERE MONTH(date) = $month AND DAYOFMONTH = $day";
Is there a better way to do this without storing unnecessary data?
I don't think there's any way to not store the year. Just ignore it like 
you're doing.

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

PHP|Architect: A magazine for PHP Professionals ­ www.phparch.com






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


[PHP-DB] PLS Advise, Highlighted Text from a Query

2003-06-17 Thread nabil
Dear all,

1- I have a form with an input text : keyword
2- the field address is in my MySQL as TEXT field.
3- I select * from db where address like '%keyword%'
4- I want when echo the return $row["address"] to highlight the entered
keyword (that the user has entered in the search form) in the output with a
different font backcolor or by just another color... to let the user see
what he was searching for
5- and if it possible to echo how accurate (percentage) the return rows has
fit his search...

Please Advise how to do it...



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