RE: [PHP-DB] Save mySQL data into a CSV file.
Error found when testing the code below: Warning: Variable passed to each() is not an array or object in apache/htdocs/speeddials.php on line 11 Line 11 is: while ($record_set_array = each($result_set)) { What did I do wrong? Thanks Martin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 5:42 PM To: Martin E. Koss Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] Save mySQL data into a CSV file. $qry = SELECT * FROM TABLE_NAME; $result_set = mysql_query($qry) or die(mysql_error()); ***this has to be called before any headers are written to the browser. *** header(Content-type: application/csv); header(Content-Disposition: attachement; filename=YOURFILENAME.csv); while ($record_set_array = each($result_set)) { print implode(,, $record_set_array) . \n; } that should pretty much cover it. hth Jeff Martin E. Koss [EMAIL PROTECTED]To: [EMAIL PROTECTED] ows.com cc: Subject: RE: [PHP-DB] Save mySQL data into a CSV file. 06/16/2003 12:22 PM I've heard or read about the headers somewhere but right now I sure could use pointing in the direction of a step-by-step tutorial for extracting my data into a CSV file and, of course, setting up the PHP file to handle it correctly. Thanks Martin -Original Message- From: Dillon, John [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 2:06 PM To: 'Martin E. Koss' Subject: RE: [PHP-DB] Save mySQL data into a CSV file. It's something to do with the header in the html page. -Original Message- From: Martin E. Koss [mailto:[EMAIL PROTECTED] Sent: 16 June 2003 13:53 To: Subject: [PHP-DB] Save mySQL data into a CSV file. Importance: High 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 http://www.cantor.com CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are confidential. If you are not the named recipient please notify the sender and immediately delete it. You may not disseminate, distribute, or forward this e-mail message or disclose its contents to anybody else. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Fitzgerald. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Although we routinely screen for viruses, addressees should check this e-mail and any attachments for viruses. We make no representation or warranty as to the absence of viruses in this e-mail or any attachments. Please note that to ensure regulatory compliance and for the protection of our customers and business, we may monitor and read e-mails sent to and from our server(s). For further important information, please read the Important Legal Information and Legal Statement at http://www.cantor.com/legal_information.html -- 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] Save mySQL data into a CSV file.
do a var_dump($result_set) to see what $result_set contains (if it's actually and array. (did you implement the code given as is? if not AND you have put line-11 in a function and $result_set as a global variable then you need to define $result_set as a global inside the function.) ramil On Tue, 2003-06-17 at 14:16, Martin E. Koss wrote: Error found when testing the code below: Warning: Variable passed to each() is not an array or object in apache/htdocs/speeddials.php on line 11 Line 11 is: while ($record_set_array = each($result_set)) { What did I do wrong? Thanks Martin -Original Message- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: sqlconnect garbage while connecting with db2
Ok, I put in the environment variables LIBPATH=/home/db2/sqllib/lib LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/db2/sqllib/lib VWSPATH=/home/db2/sqllib VWS_LOGGING=/home/db2/sqllib/logging VWS_TEMPLATES=/home/db2/sqllib/templates DB2INSTANCE=db2 (basically, I ran the ~db/sqllib/db2profile command - duh) And it got rid of the garbage. Hope this helps someone with that. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Save mySQL data into a CSV file.
On Tuesday 17 June 2003 14:16, Martin E. Koss wrote: Error found when testing the code below: Warning: Variable passed to each() is not an array or object in apache/htdocs/speeddials.php on line 11 Line 11 is: while ($record_set_array = each($result_set)) { $result_set = mysql_query($qry) or die(mysql_error()); Because $result_set is a resource id. Refer to the examples in the manual on how to get results from a db. -- 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-db -- /* Good day for overcoming obstacles. Try a steeplechase. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] updateable cursors in db2 via odbc_exec call?
I've noticed that the odbc_exec call appears to call SELECT statements as updateable in db2. Is there then a way to update each row of the response (an updateable cursor)? Any thoughts would be appreciated. thanks Rob -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] RE: Save mySQL data into a CSV file.
Hi, You can use a content header to instruct the browser to treat output as an attachment for saving. Use something like the following: ?php header(Content-type: text/plain); header(Content-Disposition: attachment; filename=filename.csv); ? (These *must* be the first lines output by your script) Then in the body of the script, do something like this: ?php echo $var1,$var2,$var3\n; ? 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
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
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
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
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
-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
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 ?php // 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] 4.2.3 session login problem...
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
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...
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
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
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
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
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
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: ?php putenv(SYBASE=/usr/local/freetds); putenv(TDSVER=70); $numero= mssql_connect(130.102.1.88 sa , ); echo (ConnectID: $numerobr\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: $c2br\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
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
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
RE: [PHP-DB] Best way to pass multiple selections to a DB
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
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
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.
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.
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 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// 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
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 -- -- ?php // 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
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
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
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
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
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
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
[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
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
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.
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 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// 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 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// 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.
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 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// 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 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// 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
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