[PHP-DB] opendir() gives failed to open dir: No error in C:\Apache\Apache\htdocs\sample_php.php
Hi All, I am using a simple opendir() function in my code as below. $o = opendir ($dir) or error (cannot open directory: $dir); and the code fails saying opendir(tests): failed to open dir: No error in C:\Apache\Apache\htdocs\sample_php.php. Don't know why the code I am getting the above error. And definitely tests directory is accessible and it is also a local directory(not shared over the network) Well, I my OS is Windows 2003 64 bit OS. PHP version is 4.3.9 thanks in advance. Satya. __ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Update multiple records
--- Jochem Maas [EMAIL PROTECTED] wrote: if (count($inds) 0 AND is_array($inds)) { $ind = '.implode(',', $inds).'; } looks like you want to do a select statement with $ind in the form of SELECT * FROM yourtable WHERE yourfield IN ($inds) Adding the IN clause did not help in any way. What I've been able to get so far is only the first record returned from the database (even though 2 exists) Using this result set it is picking up the correct user records: $query_rsLPINDS = sprintf(SELECT LurkProfiles_Industries.ProfileID, LurkProfiles_Industries.IndID, LurkerProfiles.ProfileID FROM LurkProfiles_Industries INNER JOIN LurkerProfiles ON (LurkProfiles_Industries.ProfileID = LurkerProfiles.ProfileID) INNER JOIN SignUp ON (LurkerProfiles.LurkID = SignUp.SignUpID) INNER JOIN StaIndTypes ON LurkProfiles_Industries.IndID = StaIndTypes.CareerIDs) WHERE LurkerProfiles.ProfileID = %s and LurkID = %s and hash = '%s', $colname__rsLPINDS,$colname2__rsLPINDS,$colname3__rsLPINDS); I've created the variable for IndID like this : $IndID = $rsLPINDS-Fields('IndID'); which when I do a print_r($IndID), prints out the first record. So at this point I'm trying to figure out what I need to make $IndID an array. Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Complicated Question (maybe)?
Turning off 'Update' privileges in the DB will work but it's ugly. REVOKE UPDATE ON your table.column - or - * for all FROM the web user http://dev.mysql.com/doc/mysql/en/GRANT.html for documentation Now when someone tries to update this they will get an error and unless you have different logins fro every user UPDATE will not work for anyone over the web. I have two other ideas, although each is more work: -Make a second table like the first address table but add a timestamp column, do not use auto increment (you will set the ID to the ID in the original table). In your PHP when you do an update you will first INSERT the original record and the current time into the new table then allow the UPDATE to the original table. This will not break your app but will preserve the data. -Add a column 'vaild' to the original table and when someone tries to update the table find the original record and set valid to 0; then insert a new record. This may not work if you are joining off of the ID (all related records will still point to the old record). You could also remove of disable all the UPDATE code from your PHP pages, no? Good luck, Frank On Jan 11, 2005, at 9:39 AM, [EMAIL PROTECTED] wrote: From: Chris As long as I'm understanding you correctly, this is able to be done with the mysql privileges. Just create a user that isn't allowed to update that column, then use that user in your PHP code. The wording of your message makes it look like you're using a webform to specify a columnname-value combination to update int he database. This is inherently insecure. Chris JeRRy wrote: Hi, I want to BLOCK any possible updates from a webform or php page to the address field. Or even halt any sort of update/modification from mysql to that column but have it possible to unblock by admin. Is this possible? Sure I could refuse an mysql update to do this but I want to lock out everyone to ensure no sneaky activity or changes are made. Is it possible or am I talking too much? J Find local movie times and trailers on Yahoo! Movies. http://au.movies.yahoo.com
Re: [PHP-DB] Update multiple records
Stumbling across some posts online, I noticed [some of] my messages were being sent as evil ugly HTML - so I'm going to do my best to post from Thunderbird for the list. Gotta keep OE configured as is for all the lovely meeting scheduling. Stuart Felenstein wrote: --- Jochem Maas [EMAIL PROTECTED] wrote: if (count($inds) 0 AND is_array($inds)) { $ind = '.implode(',', $inds).'; } looks like you want to do a select statement with $ind in the form of SELECT * FROM yourtable WHERE yourfield IN ($inds) Adding the IN clause did not help in any way. What I've been able to get so far is only the first record returned from the database (even though 2 exists) Using this result set it is picking up the correct user records: $query_rsLPINDS = sprintf(SELECT LurkProfiles_Industries.ProfileID, LurkProfiles_Industries.IndID, LurkerProfiles.ProfileID FROM LurkProfiles_Industries INNER JOIN LurkerProfiles ON (LurkProfiles_Industries.ProfileID = LurkerProfiles.ProfileID) INNER JOIN SignUp ON (LurkerProfiles.LurkID = SignUp.SignUpID) INNER JOIN StaIndTypes ON LurkProfiles_Industries.IndID = StaIndTypes.CareerIDs) WHERE LurkerProfiles.ProfileID = %s and LurkID = %s and hash = '%s', $colname__rsLPINDS,$colname2__rsLPINDS,$colname3__rsLPINDS); I've created the variable for IndID like this : $IndID = $rsLPINDS-Fields('IndID'); which when I do a print_r($IndID), prints out the first record. So at this point I'm trying to figure out what I need to make $IndID an array. Stuart If I remember correctly, you're using some kind of database class that we spent some time pinning down how to pull the values out of. If that is indeed the case - you need to request the next record to be able to pull that records value for the field in. I don't remember what package you were using - but whatever that is, I think you need to be running across your result set (foreach || while ) and requesting each result as you go (or you need to access the property of the object that stores the whole result set/etc.). Whatever the case - I'm like 95% sure that -Fields('fieldname') was for last pulled rows value of this field or similar and was for pulling record by record. Cheers, - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Question regarding how-to stop the form inputting empty data at end
if the media_ID field is an autonumber, then there is no need to do anything with it...mysql will take the null and generate the next id. bastien From: Mike Millner [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] Question regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return Date: Tue, 11 Jan 2005 18:52:10 -0700 Hello everyone, I have this form that we use for keeping track of tapes we send off site for storage where I work. The form works almost perfectly with the help of a few people. We use a scanner to input the tape id's. The scanner automatically puts a carriage return at the end of each tape so they all go on seperate lines. Anyway the question is this: After the last tape is scanned I end up with a line put into the mysql db that looks like this: (from mysql log file) 243 Query INSERT INTO tape_tracking_test (media_id,retention,out_date,return_date,box_id) values ('','7WK=%s','2005-01-11','2005-3-01','006455C5092800') If you look closely you'll see the first field is '' Single quotes with nothing in between. How can I get PHP to ignore that line that has empty data in the media_id field? I have checking in place to not allow empty fields but PHP/mysql think that last carriage return is not empty. I don't want to tell users they have to backspace at the end of the last tape (which fixes the problem) I hope I'm explaining this properly. If not I'm sure you guys will let me know :) Here is the script: Above here is javascript for a calendar //-- /script /head Body body onLoad=showCalendar('now') ?php if (isset($_POST['submit'])) { // Handle the form. $message = NULL; // Create an empty new variable. } // Check for MediaID. if (strlen($_POST['MediaID']) 0) { $MediaID = TRUE; } else { $MediaID = FALSE; $message .= 'pYou forgot to enter a Media ID!/p'; } // Set the page title and include the HTML header. $page_title = 'submit!'; ? form action=?php echo $_SERVER['PHP_SELF']; ? method=post fieldsetlegendEnter the Tape information into the form below:/legend pbRetention:/bbr Select name=Retention option value=4WK4 Weeks/option option value=7WK7 Weeks/option option value=1YR1 Year/option option value=2YR2 Years/option /select/p pbOut Date: /bbr input type=text name=OutDate size=20 maxlength=40 value=?php print date(Y-m-d); ? //p pbReturn Date:/b script type=text/javascript language=JavaScriptdoRCCalendar()/script pbBox ID:/bbr input type=text name=BoxID size=20 maxlength=40 value=?php if (!empty($_POST['BoxID'])) echo $_POST['BoxID']; ? //p pbMedia ID:/bbr textarea name=MediaID rows=6 cols=24 ?php if (!empty($_POST['MediaID'])) echo $_POST['MediaID']; ? /textarea form name=submit action= div align=centerinput type=submit name=date value=Submit //div /form /fieldset ? $delimiter = \n; $MediaID_ar = explode($delimiter,$_POST['MediaID']); $len_ar['MediaID'] = count($MediaID_ar); $len_ar['Retention'] = strlen($_POST['Retention']); $len_ar['OutDate'] = strlen($_POST['OutDate']); $len_ar['ReturnDate'] = strlen($_POST['calendarDate']); $len_ar['BoxID'] = strlen($_POST['BoxID']); if(($len_ar['MediaID']) ($len_ar['OutDate']) ($len_ar['ReturnDate']) ($len_ar['BoxID'])) { define ('DB_USER', 'mysql'); define ('DB_PASSWORD', 'mysql'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'tape_track_db'); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error()); mysql_select_db (DB_NAME); for($i=0; $i $len_ar['MediaID']; $i++) { $MediaID_ar[$i] = str_replace(array(\r,\n),,$MediaID_ar[$i]); mysql_query (INSERT INTO tape_tracking_test (media_id,retention,out_date,return_date,box_id) values ('.$MediaID_ar[$i].','. $_POST['Retention'] .=%s','. $_POST['OutDate'] .','. $_POST['calendarDate'] .','. $_POST['BoxID'] .')); echo mysql_error(); } mysql_close(); } else { echo font color = RedpYou have not entered all information for each box./p/font; } ? /form!-- End of Form -- /body /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
Re: [PHP-DB] Trying to figure out the best way to get and output data
It can be done in one query. Just join the two tables, and do a single loop through that query, printing out each row. When you reach a new category, display it. Something like this: $iCategoryID = -1; while($aRow = ...) { if($iCategoryID != $aRow['iCategoryID']) { echo '[',$aRow['sCategoryName'],]\n; $iCategoryID = $aRow['iCategoryID']; } echo $aRow['sSectionName'],\n; } That's bare bones, but that is, as far as I know, the best way to do it. Chris Seona Bellamy wrote: Hi guys, I'm relatively new to php, and am pretty much trying to learn as I go along. I've been struggling to get my head around this problem for a day and half, so I'm hoping that someone with more familiarity with the language can help me. I have the following two tables: CATEGORY - ID - CategoryName - TitleImage SECTION --- - ID - CategoryID - SectionName - Description What I want is to get the name of each category and output that, and then under each category I want to list the sections that belong to it. So for example: Catgeory 1 - Section 1 - Section 2 Category 2 - Section 3 - Section 4 Is there a simple way to do this? Do I need to run one query and then run a second query inside a loop? I have concerns about overheads using this method, but so far it's the only one I have come up with. I'm open to suggestions, but please spell everything out clearly because I'm still learning. :) Cheers, Seona. __ ella for Spam Control has removed Spam messages and set aside Later for me You can use it too - and it's FREE! http://www.ellaforspam.com -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.6.10 - Release Date: 10/01/2005 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question regarding how-to stop the form inputting empty data at end of the form that is empty due to a carriage return
Mike Millner wrote: Hello everyone, I have this form that we use for keeping track of tapes we send off site for storage where I work. The form works almost perfectly with the help of a few people. We use a scanner to input the tape id's. The scanner automatically puts a carriage return at the end of each tape so they all go on seperate lines. Anyway the question is this: After the last tape is scanned I end up with a line put into the mysql db that looks like this: (from mysql log file) 243 Query INSERT INTO tape_tracking_test (media_id,retention,out_date,return_date,box_id) values ('','7WK=%s','2005-01-11','2005-3-01','006455C5092800') If you look closely you'll see the first field is '' Single quotes with nothing in between. How can I get PHP to ignore that line that has empty data in the media_id field? I have checking in place to not allow empty fields but PHP/mysql think that last carriage return is not empty. I don't want to tell users they have to backspace at the end of the last tape (which fixes the problem) I hope I'm explaining this properly. If not I'm sure you guys will let me know :) Here is the script: Above here is javascript for a calendar //-- /script /head Body body onLoad=showCalendar('now') ?php if (isset($_POST['submit'])) { // Handle the form. $message = NULL; // Create an empty new variable. } // Check for MediaID. if (strlen($_POST['MediaID']) 0) { $MediaID = TRUE; } else { $MediaID = FALSE; $message .= 'pYou forgot to enter a Media ID!/p'; } // Set the page title and include the HTML header. $page_title = 'submit!'; ? form action=?php echo $_SERVER['PHP_SELF']; ? method=post fieldsetlegendEnter the Tape information into the form below:/legend pbRetention:/bbr Select name=Retention option value=4WK4 Weeks/option option value=7WK7 Weeks/option option value=1YR1 Year/option option value=2YR2 Years/option /select/p pbOut Date: /bbr input type=text name=OutDate size=20 maxlength=40 value=?php print date(Y-m-d); ? //p pbReturn Date:/b script type=text/javascript language=JavaScriptdoRCCalendar()/script pbBox ID:/bbr input type=text name=BoxID size=20 maxlength=40 value=?php if (!empty($_POST['BoxID'])) echo $_POST['BoxID']; ? //p pbMedia ID:/bbr textarea name=MediaID rows=6 cols=24 ?php if (!empty($_POST['MediaID'])) echo $_POST['MediaID']; ? /textarea form name=submit action= div align=centerinput type=submit name=date value=Submit //div /form /fieldset ? $delimiter = \n; $MediaID_ar = explode($delimiter,$_POST['MediaID']); $len_ar['MediaID'] = count($MediaID_ar); $len_ar['Retention'] = strlen($_POST['Retention']); $len_ar['OutDate'] = strlen($_POST['OutDate']); $len_ar['ReturnDate'] = strlen($_POST['calendarDate']); $len_ar['BoxID'] = strlen($_POST['BoxID']); if(($len_ar['MediaID']) ($len_ar['OutDate']) ($len_ar['ReturnDate']) ($len_ar['BoxID'])) { define ('DB_USER', 'mysql'); define ('DB_PASSWORD', 'mysql'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'tape_track_db'); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die (mysql_error()); mysql_select_db (DB_NAME); for($i=0; $i $len_ar['MediaID']; $i++) { $MediaID_ar[$i] = str_replace(array(\r,\n),,$MediaID_ar[$i]); mysql_query (INSERT INTO tape_tracking_test (media_id,retention,out_date,return_date,box_id) values ('.$MediaID_ar[$i].','. $_POST['Retention'] .=%s','. $_POST['OutDate'] .','. $_POST['calendarDate'] .','. $_POST['BoxID'] .')); echo mysql_error(); } mysql_close(); } else { echo font color = RedpYou have not entered all information for each box./p/font; } ? /form!-- End of Form -- /body /html Hi Mike I am not sure of the format of the media id, but can you not use a simple regex so that if mediaID is not of a certain pattern (e.g. all alphanumeric and a certain length), the relevant corrective action is taken? Regards -- Rory McKinley Nebula Solutions +27 21 555 3227 - office +27 21 551 0676 - fax +27 82 857 2391 - mobile www.nebula.co.za -- Rory McKinley Nebula Solutions +27 21 555 3227 - office +27 21 551 0676 - fax +27 82 857 2391 - mobile www.nebula.co.za -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php