[PHP-DB] DROP tables with prefix match
I need to rebuild a PHP-mySQL site that has an extensive table structure. Is there a way to DROP all tables that start with a certain prefix? __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] translating password($var) back to text
I am setting up a PHP-mySQL login script. One key feature I need is the ability automatically to e-mail people their password when they forget it. Obviously, I can store the password without using password() and retrieve it at any time. Is it possible to store the password using password() and retrieve a decoded value from mySQL? John Hughes __ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] redirect a page
If you really want to redirect and not just display a message that no records were found, then this will work: $num = mysql_numrows($result); if ($num == 0) { header(Location: sorry.php); exit; } ELSE { while ... --- Rankin, Randy [EMAIL PROTECTED] wrote: Nato, Try something like this: $num = mysql_numrows($result); if ($num == 0) { echo There were no records found.; } else while ... -Original Message- From: Natividad Castro [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 24, 2002 11:01 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] redirect a page Hi to all, I have a search form where users can search for a specific record; up to now is working fine, but what I would like to do is: if the record is not found, redirect them to another page that says that record was not found. Can anybody tell me how to do this? I already tried using this statement if ( !mysql_fetch_array($result) ) { include file // this the page that I want to redirect them, but it doen't work } I would like to execute the first statement it's false: e.g if name doesn't match with anything in the table, redirect to another page else execute the whole query. $query = mysql_query(SELECT * from 150bk where trim(NAME) like '% . $legal_name . %'); while($query_data = mysql_fetch_array($query)) { $id = trim($query_data[ID]); $name = trim($query_data[NAME]); $tracking_num = trim($query_data[TRACKING_NUMBER]); $census = trim($query_data[CENSUS_NUM]); $name_dba = trim($query_data[NAME_DBA]); } Any help, it's greatly appreciate Thanks Nato -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Limitations on sending text to a database via text area forms
I am attempting to build a Web site that will allow users to create simple text documents that will be stored in a database. I had been assuming I could use a textarea form and have PHP pass it to a mySQL database. However, when I attempted to send a 393 word (2,216 characters) text block, the browser (I.E. 6) refused to move. I got no error or other indication of trouble. When I cut the text down under 275 words (1,531 characters), the form was allowed to be submitted, stored and retrievable Is this the limit on passing textarea form fields? And more to point of this mailing list, what alternatives might I use to circumvent this limit? I need to keep the creation of these documents as simple as possible. Anything more than copying and pasting is going to cause trouble more me. John Hughes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How to avoid: Warning: Page has Expired
I have the first part of the kids' soccer photo database site up that I mentioned in an earlier post. The site displays nine image thumbnails. You click on the thumbnails and are taken to a full size photo. Everything works as expected for the first nine images but when you go to the next page of thumbnails, you start getting: Warning: Page has Expired The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you. To resubmit your information and view this Web page, click the Refresh button. What causes this and how can I fix it so this doesn't happen? The URL for this site is http://fuzzheads.org/barcelona TIA John Hughes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] deleting records
This was, of course, an example where the PHP code was introducing an error. The delete sql works as expected and deletes all matching email. Next time I'm going to sleep on a problem before posting. - Original Message - From: John Hughes [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, April 07, 2002 12:51 AM Subject: [PHP-DB] deleting records It's late and I'm getting groggy. I have a table called mail_list. There are four possible list_names. I want to be able to either delete an email associated with a particular list or all matching email. Deleting WHERE email AND list match works fine. The problem is when I want to delete an address from all of the lists. First I check the database to see how many matches I have. $check_sql = SELECT list_id, email FROM mail_list WHERE email = '$this_email' ; For purposes of discussion, we'll say the answer was 3. I use this sql when I want to delete all of the email addresses: $remove_sql = DELETE FROM mail_list WHERE email ='$this_email' ; Only the first record is deleted even though the check_sql found more than one match. Why doesn't the delete get all of the email addresses that match the first time? -- 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] deleting records
It's late and I'm getting groggy. I have a table called mail_list. There are four possible list_names. I want to be able to either delete an email associated with a particular list or all matching email. Deleting WHERE email AND list match works fine. The problem is when I want to delete an address from all of the lists. First I check the database to see how many matches I have. $check_sql = SELECT list_id, email FROM mail_list WHERE email = '$this_email' ; For purposes of discussion, we'll say the answer was 3. I use this sql when I want to delete all of the email addresses: $remove_sql = DELETE FROM mail_list WHERE email ='$this_email' ; Only the first record is deleted even though the check_sql found more than one match. Why doesn't the delete get all of the email addresses that match the first time? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] HTTP authentication script failure display
I have adapted a HTTP authentication script from Leon Atkinson's Core PHP book. I've done something that stopped the failure message from displaying. The password request works and valid users are sent to the correct page. But instead of getting This directory requires a user name and password when a failure occurs, I get a blank screeen. I've compared the code in the book with mine but I can't see what I've done. Any help would be appreciated. John Hughes ? session_start(); /* ** Check password */ if($PHP_AUTH_USER != '') { require (**/connect_***.***'); $sql = SELECT * FROM users WHERE username = '$PHP_AUTH_USER' AND password = password('$PHP_AUTH_PW') ; $result = mysql_query($sql,$connection) or die (Can't execute query.); $num = mysql_numrows($result); if ($num != 0) { $valid=yes; $user=$username; session_register('valid'); session_register('user'); header(Location:letters.php); exit; } #end if } ELSE { //SEND headers to request username and password header(WWW-Authenticate: Basic realm='The Letters Realm'); header(HTTP/1.0 401 Unauthorized); //show failure text print(This directory requires a user name and password.br\n); } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] HTTP authentication
Earlier I posted a question about why the failure message in my HTTP authentication script wasn't working. I figured out the answer. There was no place to go if the user entered a username or password that wasn't in the database. Below is the corrected code. John Hughes ? session_start(); /* ** Check password */ if($PHP_AUTH_USER != '') #If variable has content check user database { require (***directory path ouside Web root***/connect DB***); $sql = SELECT * FROM users WHERE username = '$PHP_AUTH_USER' AND password = password('$PHP_AUTH_PW') ; #end SQL $result = mysql_query($sql,$connection) or die (Can't execute query.); $num = mysql_numrows($result); if ($num != 0) { $valid=yes; $user=$username; session_register('valid'); session_register('user'); header(Location:letters.php); exit; } ELSE { #TRY AGAIN header(WWW-Authenticate: Basic realm='The Letters Realm'); header(HTTP/1.0 401 Unauthorized); //show failure text if user presses cancel print(This directory requires a user name and password.br\n); } #END IF ON SQL CHECK DB RESULT } ELSE { //SEND headers to request username and password header(WWW-Authenticate: Basic realm='The Letters Realm'); header(HTTP/1.0 401 Unauthorized); //show failure text if user presses cancel print(This directory requires a user name and password.br\n); } ? __ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] using multiple checkboxes to delete from db
I believe what you want to do is create an array with the id and delete as separate values. Here's an example using an array of studentdata containing variables send_mail, this_studentname, this_paid. The rows of students are output like this: td input type='checkbox' name='studentdata[$this_student_id][send_mail]' value='Yes' checked input type='hidden' name='studentdata[$this_student_id][this_studentname]' value='$this_studentname' input type='hidden' name='studentdata[$this_student_id][this_paid]' value='$this_paid' /td In this case all of the checkboxes are checked. When the form is submitted, those students who have the checkbox checked have the variable send_mail set to Yes. When I want to process the array it looks like this: foreach($studentdata as $student_id = $data) { $dues_paid = $data[this_paid]; $studentname = $data[this_studentname]; $send_mail = $data[send_mail]; if ($send_mail == Yes) { # Your sql statement and processing goes here }# end if }# end for each Hope this helps. John Hughes - Original Message - From: wesley grubbs:. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, March 30, 2002 4:58 AM Subject: [PHP-DB] using multiple checkboxes to delete from db i've been playing half the day with trying to get php to delete rows when a checkbox is checked. i have a page that pulls all the data from db in a table. one row contains checkboxes. i want it so that whereever a checkbox is checked and then submit, all the selected rows will be deleted. table ?php //get results from db while($row = mysql_fetch_array ($result)) { ? tr tdinput type=checkbox name=delete value=?php print($row[id]); ?/td /tr ?php } ? /table what's the proper function i should write for this? also, can i put the function on the same page without useing SWITCH? i'm trying to minimize the number of files i have. thanks in advance for any help. wes www.devedeset.com -- 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] textarea and mysql query
jas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I need some help with a query to place the results within a text area... here is the code and so far every time I try it out all that happens is it displays the textbox but not the results of the query. form name=wel_area method=post action=index_confirm.php3 target=box ?php $record = mysql_fetch_array(@mysql_query(SELECT wel_area FROM cm_index,$dbh)); echo textarea name='wel_area' value='{$record['wel_area']}' cols='25' rows='8'/textareabrinput type='submit' name='save' value='save'br\n; ? /form Any help would be great. Jas If the wel_area is a TEXT field in the database, why the array treatment. I have a database that contains several TEXT fields that I can call up and edit. To do that I bring the data into a textarea. Here's part of my code: The SQL query: $sql = SELECT subj, body, info, fname, lname, title, city, other, record_date, status, batch, modified_by FROM $table_name WHERE id = '$id' ; The results are read into variables: while ($row = mysql_fetch_array($result)) { $subj = $row['subj']; $body = $row['body']; $info = $row['info']; $fname = $row['fname']; $lname = $row['lname']; $title = $row['title']; $city = $row['city']; $other = $row['other']; $record_date = $row['record_date']; $status = $row['status']; $batch = $row['batch']; $modified_by = $row['modified_by']; } #end while In the body of the HTML section I have areas such as this: td textarea cols=60 rows=20 name=body wrap=soft ? echo $body; ?/textarea /td This creates an editable TEXTAREA that can then be UPDATEd in the database. John Hughes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Creating an array of mySQL results with PHP
With the help of Court Shrock, who answered by original request for help, I have managed to create an array of form data that can be fed to a mySQL UPDATE query. In case anyone else needs to do this, here's the solution I reached. The existing data is read from the database and placed in cells that look like this sample: td align=\center\ input type=\text\ name=\log[$week_no][classroom]\ value=\$classroom\ size=\2\ maxlength=\4\ /td The trick here is the array log[][]. Data from the columns is stored in rows identified by week_no. The UPDATE sql looks like this: #loop through the log[][] array; foreach($log as $week_no = $data) { $classroom = $data[classroom]; $homework = $data[homework]; $library = $data[library]; $fieldtrip = $data[fieldtrip]; $pta = $data[pta]; $mast = $data[mast]; $meetings = $data[meetings]; $other = $data[other]; $sql = UPDATE parent_log SET classroom = \$classroom\, homework = \$homework\, library = \$library\, fieldtrip = \$fieldtrip\, pta = \$pta\, mast = \$mast\, meetings = \$meetings\, other = \$other\ WHERE parent_id = \$parent_id\ AND student_id = \$student_id\ AND week_no = \$week_no\ ; # end create sql query The foreach format and figuring out to extract the data in preparation for the UPDATE command caused me the most trouble. The demo site mentioned in the original message has been modified to incorporate the one-button update feature for those who would like to see how this works. John Hughes - Original Message - From: John Hughes, Jomari Works [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, March 11, 2002 10:42 PM Subject: [PHP-DB] Creating an array of mySQL results with PHP I am working on the creation of Web-based database where parents log the hours they spend participating in school activities. (The school requires that parents spend two hours each week.) I have a prototype demonstration site at http://fuzzheads.org/demo As currently constructed, the parent log database contains a record for each week (there are a total of 39 in the school year) with columns for eight different types of school work -- classroom, homework, field trips, etc. What I have done is create a log that can be updated one week at a time. This shouldn't be a problem for parents who keep their log up to date. But if you want to tinker with the hours for more than one week, it will not be a feature that you must update each week separately. So (now we get to the reason for this message) it occurs to be that if I could retrieve the 39 weekly records as an array of weeks, I would have a structure that I could then update in a single step. This is what my mysql_fetch_array looks like: while ($row = mysql_fetch_array($result)) { $week_no = $row['week_no']; $week_date = $row['week_date']; $parent_id = $row['parent_id']; $student_id = $row['student_id']; $class_id = $row['class_id']; $classroom = $row['classroom']; $homework = $row['homework']; $library = $row['library']; $fieldtrip = $row['fieldtrip']; $pta = $row['pta']; $mast = $row['mast']; $meetings = $row['meetings']; $other = $row['other']; I then create a table row of the result and loop through. A sample table cell looks like this: td align=\center\ input type=\text\ name=\classroom\ value=\$classroom\ size=\2\ maxlength=\4\ /td How would I change the mysql_fetch_array to create an array of weeks and how would I change the table output coding to accommodate such an array? TIA John Hughes -- 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] Creating an array of mySQL results with PHP
I am working on the creation of Web-based database where parents log the hours they spend participating in school activities. (The school requires that parents spend two hours each week.) I have a prototype demonstration site at http://fuzzheads.org/demo As currently constructed, the parent log database contains a record for each week (there are a total of 39 in the school year) with columns for eight different types of school work -- classroom, homework, field trips, etc. What I have done is create a log that can be updated one week at a time. This shouldn't be a problem for parents who keep their log up to date. But if you want to tinker with the hours for more than one week, it will not be a feature that you must update each week separately. So (now we get to the reason for this message) it occurs to be that if I could retrieve the 39 weekly records as an array of weeks, I would have a structure that I could then update in a single step. This is what my mysql_fetch_array looks like: while ($row = mysql_fetch_array($result)) { $week_no = $row['week_no']; $week_date = $row['week_date']; $parent_id = $row['parent_id']; $student_id = $row['student_id']; $class_id = $row['class_id']; $classroom = $row['classroom']; $homework = $row['homework']; $library = $row['library']; $fieldtrip = $row['fieldtrip']; $pta = $row['pta']; $mast = $row['mast']; $meetings = $row['meetings']; $other = $row['other']; I then create a table row of the result and loop through. A sample table cell looks like this: td align=\center\ input type=\text\ name=\classroom\ value=\$classroom\ size=\2\ maxlength=\4\ /td How would I change the mysql_fetch_array to create an array of weeks and how would I change the table output coding to accommodate such an array? TIA John Hughes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Creating an array of mySQL results with PHP
OK. I can see how that works, assuming that the value would be \log[$week_no][classroom]\ as well. What would the mysql_fetch_array look like? - Original Message - From: Shrock, Court [EMAIL PROTECTED] To: 'John Hughes, Jomari Works' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, March 11, 2002 10:50 PM Subject: RE: [PHP-DB] Creating an array of mySQL results with PHP Well, you could use the power of PHP arrays and just name your input fields in such a way that would create an array upon submittal. For example: td align=\center\ input type=\text\ name=\log[$week_no][classroom]\ value=\$classroom\ /td Then, after submittal, you just loop through the array $log like such: foreach($log as $week_no = $data) { $sql = UPDATE table SET classroom='{$data['classroom']}' WHERE week_no=$week_no; mysql_query($sql); } Of course, this all assumes that the key is week_no. Hope this helps, Court -Original Message- From: John Hughes, Jomari Works [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 10:42 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Creating an array of mySQL results with PHP while ($row = mysql_fetch_array($result)) { $week_no = $row['week_no']; $week_date = $row['week_date']; $parent_id = $row['parent_id']; $student_id = $row['student_id']; $class_id = $row['class_id']; $classroom = $row['classroom']; $homework = $row['homework']; $library = $row['library']; $fieldtrip = $row['fieldtrip']; $pta = $row['pta']; $mast = $row['mast']; $meetings = $row['meetings']; $other = $row['other']; I then create a table row of the result and loop through. A sample table cell looks like this: td align=\center\ input type=\text\ name=\classroom\ value=\$classroom\ size=\2\ maxlength=\4\ /td How would I change the mysql_fetch_array to create an array of weeks and how would I change the table output coding to accommodate such an array? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Creating an array of mySQL results with PHP
First, I admit to being VERY new to PHP and mySQL and, to make matters worse, I'm self-taught.. If you visit the demo site at http://fuzzheads.org/demo you might better understand what I'm attempting to do and that might help better explain my confusion with your suggestion. The Parent Log displays the existing data for each week (up to the current week, but not into the rest of the school year) divided into eight possible types of work. This is what the sql looks like: $sql = SELECT weeks.*, parentlog.* FROM weeks LEFT JOIN parentlog USING(week_no) WHERE parentlog.parent_id = \$parent_id\ AND parentlog.student_id = \$student_id\ AND week_date = CURRENT_DATE ; The _existing_ values are placed in the VALUE for each form input in code like this: input type=\text\ name=\classroom\ value=\$classroom\ size=\2\ maxlength=\4\ Hidden values for the $week_no, $parent_id and $student_id are included in each row. Since I'm starting with the existing value for each field, I'm confused by your suggestion that the name reference as an array would be different from the value reference. What I'm shooting for is the ability of the parent to change any existing value in any field in any week and then press a single Update button and have all of the values updated. John Hughes - Original Message - From: Shrock, Court [EMAIL PROTECTED] To: 'John Hughes, Jomari Works' [EMAIL PROTECTED]; Shrock, Court [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Monday, March 11, 2002 11:10 PM Subject: RE: [PHP-DB] Creating an array of mySQL results with PHP Actually, you want the value of the input to be just $classroom. That is because it is within the while loop. Can I ask for a little more information regarding the structure of the table that you are querying--what is(are) the primary keys in the table; I am assuming that the week_no field is the primary key. I am sorry for the confusion--the complete code for outputting the input form follows (minus the appropriate form tags). ###SNIP echo table; while ($row = mysql_fetch_array($result)) { $week_no = $row['week_no']; $week_date = $row['week_date']; $parent_id = $row['parent_id']; $student_id = $row['student_id']; $class_id = $row['class_id']; $classroom = $row['classroom']; $homework = $row['homework']; $library = $row['library']; $fieldtrip = $row['fieldtrip']; $pta = $row['pta']; $mast = $row['mast']; $meetings = $row['meetings']; $other = $row['other']; echo EOD trtd align=\center\ input type=\text\ name=\log[$week_no][classroom]\ value=\$classroom\ /td/tr EOD; } echo /table; ###SNIP -Original Message- From: John Hughes, Jomari Works [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 11:03 PM To: Shrock, Court; [EMAIL PROTECTED] Subject: Re: [PHP-DB] Creating an array of mySQL results with PHP OK. I can see how that works, assuming that the value would be \log[$week_no][classroom]\ as well. What would the mysql_fetch_array look like? -- 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