Re: [PHP] PHP 5.3.0 Released!
Michael A. Peters wrote: http://www.clfsrpm.net/php53/ I just have to try to rebuild some of the pecl modules, and test it to make sure the build doesn't segfault or give me the finger or anything rude like that before I upload the src.rpm. Ugh - limited testing shows the interpreter working, but ... [r...@jerusalem ~]# pear upgrade-all Nothing to upgrade-all [r...@jerusalem ~]# pear list-channels Segmentation fault [r...@jerusalem ~]# Seg fault happens w/ both older pear 1.7.2 (from Fedora 9) and pear 1.8.1 (packaged by me) - both versions of pear work dandy on php 5.2.9 - so somewhere something ain't quite right. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: check a variable after EACH function
On Tue, 30 Jun 2009 18:31:54 -0500, Flint Million wrote: > Suppose I have some kind of check variable - say for example > $abort_now. Or it could be a function. Something to be evaluated to a > value. > > I want to execute a block of statements, but after EACH statement > executes, check the value of $abort_now and if it is true, break; out > of the block. > > Here's an example > > do { > do_something(); > do_something_else(); > do_another_thing(); > do_yet_another_thing(); > and_keep_doing_things(); > } while ($abort_now != 1); I would have the functions return true or false and do something like: while (do_something() && do_something_else()&& do_another_thing() && do_yet_another_thing() && and_keep_doing_things()) ; /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exasperated again - shot in the foot
2009/7/1 PJ : > Jay Blanchard wrote: >> [snip] >> Use the OOP interface to mysqli or PDO and these problems don't happen >> [/snip] >> >> Either that or include a modicum of error checking in your code. >> >> > OK, Ok, I feel stupid enough already. > I'm not sure I want to get in that deep... it's tough enough with the > simple stuff... > so, talk to me about the OOP interface or the PDO... :-\ The first step on the road to enlightenment is to learn how to learn without asking for help. 1) RTFM 2) Try it - set up a sandbox where you can play with code and make mistakes without consequences 3) Google/Bing it (yeah, Bing's never gonna catch on like that!) 4) Try it again 5) If you're still having problems ask here and include evidence that you've put some effort into steps 1-4 This list should be your last port of call when you can't figure something out. Now I have to disagree that the OO variants of the MySQL API are any better than the plain old mysql_* functions. In particular I have found PDO to be significantly slower. Yes you have to take care of escaping values in SQL statements yourself, but having to be consciously aware of security issues is never a bad thing unless you're lazy about it. As Jay says you cannot assume that any code that calls external services is going to work. You need to check return values, catch exceptions and do everything else you can to handle unexpected events. I've found that 99.99% of the time MySQL is perfectly reliable, but in the 0.01% you may unexpectedly lose the connection for any number of reasons. If you don't handle it then you could end up losing data but happily telling your users it was stored successfully. In general this is known as defensive programming. Never assume anything, handle every eventuality you can think of including the "this will never happen" cases, and always make sure you have a catch-all for stuff you can't think of. Learn to do this early and you'll have a much better time of it. Now I have to go and find June - I'm sure I lost a few days in there somewhere. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] my first order job on manages jobs
2009/7/1 Suresh Gupta VG : > Hi List, > > This is the first job chain I am creating using manages job chains. I am > trying to create 2 order jobs, 1 order and one jobchain. First I created an > orderjob and named it and tried to edit it. A new window displayed with the > properties of that order job. I choose "executable file" from job type and > saved the job. Then I clicked on param1 and wrote the code sh -c "echo hello > world" and clicked on "store" button. The job summary explorer came. The jobs > saved are in RED color and "X" mark is indicating. I thought that this is > throwing an error and checked the log files. I couldn't see any error in the > logs. I am following the "OSJS Sample - Job Chain Setup in Job Scheduler.mht" > file. I observed some differences in the screen shots of this demo file and > my current view. > > > 1. > Why it is showing the red color after submit of the order jobs, job > chain and order too. > 2. > In the Orderjob edit window, I couldn't see the "Active YES/NO" radio > buttons", "Scheduler ID" box and at the end of the page there are only 2 > buttons "Store" and "Cancel", but I couldn't see the "store and submit" > button. > 3. > After creating the order job then we need to choose the job scheduler > from the list where we need to submit the job order. How to get this small > window with schedulers list. > 4. > When I edit the job chain there are only 2 buttons not 4. Missing > buttons are "store and submit" and "store and remove orders". Please advice. > 5. > Here also I found that the job chain and order are in red color with > "x" mark on it. > > Please advice me to get rid of all these errors and get success in executing > this sample program. This would appear to be relating to a specific product and not PHP in general. You see the clue is in the list name... PHP General. Please contact the company or developer that supplied the software you are trying to use - they might know what the heck you're talking about. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5.3.0 Released!
Michael A. Peters wrote: Michael A. Peters wrote: http://www.clfsrpm.net/php53/ I just have to try to rebuild some of the pecl modules, and test it to make sure the build doesn't segfault or give me the finger or anything rude like that before I upload the src.rpm. Ugh - limited testing shows the interpreter working, but ... [r...@jerusalem ~]# pear upgrade-all Nothing to upgrade-all [r...@jerusalem ~]# pear list-channels Segmentation fault [r...@jerusalem ~]# Seg fault happens w/ both older pear 1.7.2 (from Fedora 9) and pear 1.8.1 (packaged by me) - both versions of pear work dandy on php 5.2.9 - so somewhere something ain't quite right. No seg fault if I don't load the suhosin module. (suhosin not an issue in 5.2.9) - works as expected, so suhosin needs an update. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exasperated again - shot in the foot
Stuart wrote: 3) Google/Bing it (yeah, Bing's never gonna catch on like that!) Of cause it would be nice to see the Bing clockwork toys that run it ... I couldn't help giggle when they announced they were naming it after a toy manuafacturer :) -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Cleaning up automatically when leaving a page
Mary Anderson wrote: Hi all, I have a php application for which I have a page which creates temporary junk and puts it into a persistent store (in this case a postgres database, but that is beside the point.) I have a Save button which puts the stuff I really want into the persistent store and cleans up the temporary junk. I have a Cancel button which only cleans up the temporary junk. I would really like to have the cleanup code run anytime a user leaves the page without hitting the Save button. Is there anyway to do this? I.e. have php code called conditionally on exiting the page? Thanks Mary I assume you looked at register_shutdown_function() and session_set_save_handler() One way I handled this problem is to save the data in "cleanup" files. Then when the page is called by a new client, a function checks the file's time stamp, say if it's more than 10 minutes earlier, does the cleanup process. This technique assumes that a new client will come along and that the cleanup process(es) are fairly fast. Al... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Push an Array, Comma separated.
> -Original Message- > From: Louie Miranda [mailto:lmira...@gmail.com] > Sent: 01 July 2009 04:19 > To: php-general@lists.php.net > Subject: Re: [PHP] Re: Push an Array, Comma separated. > > This is what I did. And it worked. > > $saveFiles = array(); > $arrSize=sizeof($saveFiles); > for ($number = 0; $number < $arrSize; $number++) { > $saveFilesDump = "$saveFiles[$number], "; > echo "$saveFiles[$number], "; > } > > File1.txt, File2.txt, File3.txt, Oh! You mean: $saveFilesDump = implode(', ', $saveFiles); I think everyone was confused by you using the word "push", which means something else entirely. (I know I was.) Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
Re: [PHP] Re: check a variable after EACH function
2009/7/1 Nisse Engström : > On Tue, 30 Jun 2009 18:31:54 -0500, Flint Million wrote: > >> Suppose I have some kind of check variable - say for example >> $abort_now. Or it could be a function. Something to be evaluated to a >> value. >> >> I want to execute a block of statements, but after EACH statement >> executes, check the value of $abort_now and if it is true, break; out >> of the block. >> >> Here's an example >> >> do { >> do_something(); >> do_something_else(); >> do_another_thing(); >> do_yet_another_thing(); >> and_keep_doing_things(); >> } while ($abort_now != 1); > > I would have the functions return true or false and > do something like: > > while (do_something() && > do_something_else() && > do_another_thing() && > do_yet_another_thing() && > and_keep_doing_things()) > ; > > > /Nisse > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I think you *could* do something like this: The catch is that in this case all the functions would have to accept the same parameters. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: my first order job on manages jobs
Suresh Gupta VG wrote: > Hi List, > > This is the first job chain I am creating using manages job chains. I am > trying to create 2 order jobs, 1 order and one jobchain. First I created an > orderjob and named it and tried to edit it. A new window displayed with the > properties of that order job. I choose "executable file" from job type and > saved the job. Then I clicked on param1 and wrote the code sh -c "echo hello > world" and clicked on "store" button. The job summary explorer came. The jobs > saved are in RED color and "X" mark is indicating. I thought that this is > throwing an error and checked the log files. I couldn't see any error in the > logs. I am following the "OSJS Sample - Job Chain Setup in Job Scheduler.mht" > file. I observed some differences in the screen shots of this demo file and > my current view. > > > 1. > Why it is showing the red color after submit of the order jobs, job > chain and order too. > 2. > In the Orderjob edit window, I couldn't see the "Active YES/NO" radio > buttons", "Scheduler ID" box and at the end of the page there are only 2 > buttons "Store" and "Cancel", but I couldn't see the "store and submit" > button. > 3. > After creating the order job then we need to choose the job scheduler > from the list where we need to submit the job order. How to get this small > window with schedulers list. > 4. > When I edit the job chain there are only 2 buttons not 4. Missing > buttons are "store and submit" and "store and remove orders". Please advice. > 5. > Here also I found that the job chain and order are in red color with > "x" mark on it. > > Please advice me to get rid of all these errors and get success in executing > this sample program. > > > > With thanks and Regards, > > Suresh.G > Not recommended, but you will need to ensure that register_globals are on. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exasperated again - shot in the foot
Lester Caine wrote: > Stuart wrote: >> 3) Google/Bing it (yeah, Bing's never gonna catch on like that!) > > Of cause it would be nice to see the Bing clockwork toys that run it ... > I couldn't help giggle when they announced they were naming it after a > toy manuafacturer :) > OT, but the first time I tried bing I resolved to not go back. If I search on spidean, which is the name of my site and is a Gaelic word found in the name of many mountain peaks in Scotland, I get results for spiderman as top results. In contrast, google asks me "did you mean spiderman?" but gives me all results for spidean. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Select and compare problems still ...
Why doesn't this work? $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND address = '$ucAddress' " ; $result = mysql_query($query) or die(mysql_error()); echo $result; $row = mysql_fetch_array ($result); $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, critical, cviolations, noncritical) VALUES (" ; $sql .= " '$ucName', '$ucAddress', '$inDate', '$inType', '$notes', '$critical', '$cleanViolations', '$noncritical')"; $result = mysql_query($sql) or die(mysql_error()); The error I keep getting is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use And I have gone in the mySQL panel and let it make the query so I'm really stumped why it hangs ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select and compare problems still ...
On Jul 1, 2009, at 10:56 AM, "Miller, Terion" > wrote: Why doesn't this work? $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND address = '$ucAddress' " ; $result = mysql_query($query) or die(mysql_error()); echo $result; $row = mysql_fetch_array ($result); $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, critical, cviolations, noncritical) VALUES (" ; $sql .= " '$ucName', '$ucAddress', '$inDate', '$inType', '$notes', '$critical', '$cleanViolations', '$noncritical')"; $result = mysql_query($sql) or die(mysql_error()); The error I keep getting is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use And I have gone in the mySQL panel and let it make the query so I'm really stumped why it hangs ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Try removing the backticks from the tablename, I have found that if you include the backticks around the table name and not the field names, mysql will throw the occassional fit. Bastien Sent from my iPod -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with unit tests
I am using test-harness.php (PHP TAP Test Harness 1_0_0_BETA) and test-more.php to write some unit tests for several libraries of functions. These tests need to run from a MS-Windows CLI so they can be run on our desktops for now and can be added to the automated build process later. I have written my first tests using test-more.php to generate TAP compliant results, and they work as expected (see below - yes, both tests should fail). But when I run them with test-harness.php, the reported results are wrong (also below). The harness reports all tests passed, even if they didn't. After doing some digging, I found Bug #44908, which seems to be related. It appears the interpreter on MS-Windows is not creating the pipe file for STDOUT, so the harness never sees the results from the actual tests. I also tried using the Perl Test::Harness to run the scripts and get the same error message there. Both harnesses appear to ignore the error count returned as the process exit value as well. But I am not sure if that is true or they just never saw it. Has any workaround been identified for this problem? Is there another mailing list that might be a more appropriate forum for this issue? Thank you, Bob McConnell --9<- D:\project\workspace\t>ver Microsoft Windows XP [Version 5.1.2600] <<- XP Pro 2002 w/SP2 D:\project\workspace\t>php -v PHP 5.2.10 (cli) (built: Jun 17 2009 16:16:57) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies D:\project\workspace\t>php testSessionKV.php 1..2 not ok 1 - Should fail # Failed test (D:\project\workspace\t\testSessionKV.php at line 13) not ok 2 - Old KV pair # Failed test (D:\project\workspace\t\testSessionKV.php at line 24) # Looks like you failed 2 tests of 2. D:\project\workspace\t>php test-harness.php -v testSessionKV.php.ok Could not open input file: D: All test scripts passed! All subtests passed! D:\project\workspace>ren testSessionKV.php testSessionKV.t D:\project\workspace>cd .. D:\MMID\workspace\t>perl -v This is perl, v5.10.0 built for MSWin32-x86-multi-thread <<- Camelbox Copyright 1987-2007, Larry Wall D:\project\workspace>set HARNESS_PERL=php D:\project\workspace>perl -MTest::Harness -e "@ARGV= map glob, @ARGV if $^O =~ /^MSWin/; runtests @ARGV;" t/*.t t/testSessionKVCould not open input file: print join qq[\n], @INC FAILED before any test output arrived FAILED--1 test script could be run, alas--no output ever seen --9<- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select and compare problems still ...
On Wed, Jul 1, 2009 at 10:56 AM, Miller, Terion wrote: > Why doesn't this work? > > > $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND > address = '$ucAddress' " ; > > $result = mysql_query($query) or die(mysql_error()); > > > echo $result; > $row = mysql_fetch_array ($result); > > > > $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, > critical, cviolations, noncritical) VALUES (" ; > $sql .= " '$ucName', > '$ucAddress', '$inDate', '$inType', '$notes', '$critical', > '$cleanViolations', '$noncritical')"; > > > > $result = mysql_query($sql) or die(mysql_error()); > > The error I keep getting is: > > You have an error in your SQL syntax; check the manual that corresponds to > your MySQL server version for the right syntax to use > > And I have gone in the mySQL panel and let it make the query so I'm > really stumped why it hangs ... > > > The last example you posted said: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's Roast Beef Restaurant #9459', ' 1833 W Republic Rd ', '3/2/09', '' at line 1 This indicated that the value for $ucName contained an apostrophe/single-quote character. (Perhaps it was supposed to be "Arby's Roast Beef Restaurant #9459"?). Try this: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Split up Date Range
I haven't been able to find anything by googling... Does anyone know of any libraries that will split up date ranges? We've got a project where "Date Of Attendance" is moving from a single type in character field to an automatically built field based on a DateBegin date field and a DateEnd date field. Some examples of what I'd like ideally... Given: July 19-22, 2009 Return: 7/19/2009 and 7/22/2009 Given: July 19th and 20th Return: 7/19/2009 and 7/20/2009 (we can safely assume current year for this project) Given: Sept 19, 2009 - Sept 22, 2009 Return: 9/19/2009 and 9/22/2009 Given: July 19th, 2009 Return: 7/19/2009 and 7/19/2009 Given: 7/19/2009 Return: 7/19/2009 and 7/19/2009 I could probably hack something together that would work most of the time... but why reinvent the wheel if some poor shlub has already done it. If such a thing doesn't exist... then I'm considering an algorithm like such... (and advice... yays and nays are appreciated) Replace the names (and variations thereof) of the months with their numeric equivilants followed by a comma. So the above would become... 7, 19-22, 2009 7, 19th and 20th 9, 19, 2009 - 9, 22, 2009 7, 19th, 2009 7/19/2009 Then replace all the th and nd and st with nothing... replace all the ands with a dash... and eliminate spaces... and change / to , Giving... 7,19-22,2009 7,19-20 9,19,2009-9,22,2009 7,19,2009 7,19,2009 Then explode on commas. If you have two elements populate the third with the current year. (This "fixes" 7,19-20 to 7,19-20,2009). Not a given example, but it would also fix 7/19 to 7,19,2009. When you have three elements then you have a "valid" date. Loop over each element and populate begin and end, if you find a dash in the current element then split on the dash and populate as needed. Yes this would allow 7-8,19-20,2009 to create 7/19/2009 and 8/20/2009 but I think its as safe as any assumption that "regular people" wouldn't enter that as a date range. If you have more than three elements then split on the dash and as long as you have have only two elements then consider each item by itself. If it's not handled by the above rules then don't split it up. Thanks in advance. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Split up Date Range
On Wednesday 01 July 2009 16:25:29 Matt Neimeyer wrote: > I haven't been able to find anything by googling... Does anyone know > of any libraries that will split up date ranges? We've got a project > where "Date Of Attendance" is moving from a single type in character > field to an automatically built field based on a DateBegin date field > and a DateEnd date field. Some examples of what I'd like ideally... > > Given: July 19-22, 2009 > Return: 7/19/2009 and 7/22/2009 > > Given: July 19th and 20th > Return: 7/19/2009 and 7/20/2009 (we can safely assume current year for > this project) > > Given: Sept 19, 2009 - Sept 22, 2009 > Return: 9/19/2009 and 9/22/2009 > > Given: July 19th, 2009 > Return: 7/19/2009 and 7/19/2009 > > Given: 7/19/2009 > Return: 7/19/2009 and 7/19/2009 > > I could probably hack something together that would work most of the > time... but why reinvent the wheel if some poor shlub has already done > it. > > If such a thing doesn't exist... then I'm considering an algorithm > like such... (and advice... yays and nays are appreciated) > > Replace the names (and variations thereof) of the months with their > numeric equivilants followed by a comma. So the above would become... > > 7, 19-22, 2009 > 7, 19th and 20th > 9, 19, 2009 - 9, 22, 2009 > 7, 19th, 2009 > 7/19/2009 > > Then replace all the th and nd and st with nothing... replace all the > ands with a dash... and eliminate spaces... and change / to , > Giving... > > 7,19-22,2009 > 7,19-20 > 9,19,2009-9,22,2009 > 7,19,2009 > 7,19,2009 > > Then explode on commas. If you have two elements populate the third > with the current year. (This "fixes" 7,19-20 to 7,19-20,2009). Not a > given example, but it would also fix 7/19 to 7,19,2009. > > When you have three elements then you have a "valid" date. Loop over > each element and populate begin and end, if you find a dash in the > current element then split on the dash and populate as needed. Yes > this would allow 7-8,19-20,2009 to create 7/19/2009 and 8/20/2009 but > I think its as safe as any assumption that "regular people" wouldn't > enter that as a date range. > > If you have more than three elements then split on the dash and as > long as you have have only two elements then consider each item by > itself. > > If it's not handled by the above rules then don't split it up. > > Thanks in advance. > > Matt Wow, first question is, why accept such a variety of inputs? Can't you force a particular standard for people that allows them to enter a range? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select and compare problems still ...
On 7/1/09 10:06 AM, "Phpster" wrote: On Jul 1, 2009, at 10:56 AM, "Miller, Terion" wrote: > Why doesn't this work? > > >$query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND > address = '$ucAddress' " ; > > $result = mysql_query($query) or die(mysql_error()); > > > echo $result; > $row = mysql_fetch_array ($result); > > > > $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, > notes, > critical, cviolations, noncritical) VALUES (" ; > $sql .= " '$ucName', > '$ucAddress', '$inDate', '$inType', '$notes', '$critical', > '$cleanViolations', '$noncritical')"; > > > >$result = mysql_query($sql) or die(mysql_error()); > > The error I keep getting is: > > You have an error in your SQL syntax; check the manual that > corresponds to > your MySQL server version for the right syntax to use > > And I have gone in the mySQL panel and let it make the query so > I'm > really stumped why it hangs ... > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Try removing the backticks from the tablename, I have found that if you include the backticks around the table name and not the field names, mysql will throw the occassional fit. Bastien Sent from my iPod Removed them and still getting the same error It returns one record then spits out the error...weird. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select and compare problems still ...
On Wed, Jul 1, 2009 at 11:23 AM, Andrew Ballard wrote: > On Wed, Jul 1, 2009 at 10:56 AM, Miller, > Terion wrote: >> Why doesn't this work? >> >> >> $query = "SELECT * FROM `restaurants` WHERE name ='$ucName' AND >> address = '$ucAddress' " ; >> >> $result = mysql_query($query) or die(mysql_error()); >> >> >> echo $result; >> $row = mysql_fetch_array ($result); >> >> >> >> $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, >> critical, cviolations, noncritical) VALUES (" ; >> $sql .= " '$ucName', >> '$ucAddress', '$inDate', '$inType', '$notes', '$critical', >> '$cleanViolations', '$noncritical')"; >> >> >> >> $result = mysql_query($sql) or die(mysql_error()); >> >> The error I keep getting is: >> >> You have an error in your SQL syntax; check the manual that corresponds to >> your MySQL server version for the right syntax to use >> >> And I have gone in the mySQL panel and let it make the query so I'm >> really stumped why it hangs ... >> >> >> > > The last example you posted said: > > You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use > near 's Roast Beef Restaurant #9459', ' 1833 W Republic Rd ', > '3/2/09', '' at line 1 > > This indicated that the value for $ucName contained an > apostrophe/single-quote character. (Perhaps it was supposed to be > "Arby's Roast Beef Restaurant #9459"?). > > Try this: > > > $data = array($ucName, $ucAddress, $inDate, $inType, $notes, > $critical, $cleanViolations, $noncritical); > > $sql = vprintf("INSERT INTO `restaurants` (name, address, inDate, > inType, notes, critical, cviolations, noncritical) VALUES ('%s', '%s', > '%s', '%s', '%s', '%s', '%s', '%s')", > array_map('mysql_real_escape_string', $data)); > > $result = mysql_query($sql) or die(mysql_error()); > > ?> > oops = make that vsprintf(), not vprintf(); Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Split up Date Range
It would be easier to standardize the input so you only have to run one regular expression check to validate and then split the data up. On Wed, Jul 1, 2009 at 10:33 AM, Ashley Sheridan wrote: > On Wednesday 01 July 2009 16:25:29 Matt Neimeyer wrote: > > I haven't been able to find anything by googling... Does anyone know > > of any libraries that will split up date ranges? We've got a project > > where "Date Of Attendance" is moving from a single type in character > > field to an automatically built field based on a DateBegin date field > > and a DateEnd date field. Some examples of what I'd like ideally... > > > > Given: July 19-22, 2009 > > Return: 7/19/2009 and 7/22/2009 > > > > Given: July 19th and 20th > > Return: 7/19/2009 and 7/20/2009 (we can safely assume current year for > > this project) > > > > Given: Sept 19, 2009 - Sept 22, 2009 > > Return: 9/19/2009 and 9/22/2009 > > > > Given: July 19th, 2009 > > Return: 7/19/2009 and 7/19/2009 > > > > Given: 7/19/2009 > > Return: 7/19/2009 and 7/19/2009 > > > > I could probably hack something together that would work most of the > > time... but why reinvent the wheel if some poor shlub has already done > > it. > > > > If such a thing doesn't exist... then I'm considering an algorithm > > like such... (and advice... yays and nays are appreciated) > > > > Replace the names (and variations thereof) of the months with their > > numeric equivilants followed by a comma. So the above would become... > > > > 7, 19-22, 2009 > > 7, 19th and 20th > > 9, 19, 2009 - 9, 22, 2009 > > 7, 19th, 2009 > > 7/19/2009 > > > > Then replace all the th and nd and st with nothing... replace all the > > ands with a dash... and eliminate spaces... and change / to , > > Giving... > > > > 7,19-22,2009 > > 7,19-20 > > 9,19,2009-9,22,2009 > > 7,19,2009 > > 7,19,2009 > > > > Then explode on commas. If you have two elements populate the third > > with the current year. (This "fixes" 7,19-20 to 7,19-20,2009). Not a > > given example, but it would also fix 7/19 to 7,19,2009. > > > > When you have three elements then you have a "valid" date. Loop over > > each element and populate begin and end, if you find a dash in the > > current element then split on the dash and populate as needed. Yes > > this would allow 7-8,19-20,2009 to create 7/19/2009 and 8/20/2009 but > > I think its as safe as any assumption that "regular people" wouldn't > > enter that as a date range. > > > > If you have more than three elements then split on the dash and as > > long as you have have only two elements then consider each item by > > itself. > > > > If it's not handled by the above rules then don't split it up. > > > > Thanks in advance. > > > > Matt > > Wow, first question is, why accept such a variety of inputs? Can't you > force a > particular standard for people that allows them to enter a range? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- - Adam Shannon ( http://ashannon.us )
Re: [PHP] Select and compare problems still ...
On 7/1/09 10:29 AM, "Andrew Ballard" wrote: $data = array($ucName, $ucAddress, $inDate, $inType, $notes, > $critical, $cleanViolations, $noncritical); > > $sql = vprintf("INSERT INTO `restaurants` (name, address, inDate, > inType, notes, critical, cviolations, noncritical) VALUES ('%s', '%s', > '%s', '%s', '%s', '%s', '%s', '%s')", > array_map('mysql_real_escape_string', $data)); > > $result = mysql_query($sql) or die(mysql_error()); Well I had wondered about the escape_string and did it like this, now I have a new problem, it is inserting all the records in the database (making duplicates) I want it to match the records and only insert the ones not there... Here's my code so far: $cleanViolations = str_replace('*', '', $cviolations);$ucName = ucwords($name);$ucAddress = ucwords($address);$mysql_name = mysql_escape_string($ucName);$mysql_address = mysql_escape_string($ucAddress);$mysql_inDate = mysql_escape_string($inDate);$mysql_inType = mysql_escape_string($inType); $mysql_notes = mysql_escape_string($notes);$mysql_critical = mysql_escape_string($critical);$mysql_cviolations = mysql_escape_string($cleanViolations);$mysql_noncritical = mysql_escape_string($noncritical); echo "$ucName "; echo "$ucAddress ";echo "$inDate ";echo "$inType "; echo "$notes ";echo "$critical ";//echo "$cviolations ";echo "$cleanViolations ";echo "$noncritical "; //compare entries and insert new inspections to the database //call what is in the database$query = "SELECT * FROM restaurants WHERE name LIKE '$mysql_name' AND address LIKE '$mysql_address' AND inDate LIKE '$mysql_inDate' AND inType LIKE '$mysql_inType'" ; $result = mysql_query($query) or die(mysql_error()); echo $result; $row = mysql_numrows($result); if ($row == 0){ $sql = "INSERT INTO `restaurants` (name, address, inDate, inType, notes, critical, cviolations, noncritical) VALUES (" ; $sql .= " '$ucName', '$ucAddress', '$inDate', '$inType', '$notes', '$critical', '$cleanViolations', '$noncritical')";$result = mysql_query($sql) or die(mysql_error()); } /**/ }; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Split up Date Range
On Jul 1, 2009, at 11:33, Ashley Sheridan wrote: On Wednesday 01 July 2009 16:25:29 Matt Neimeyer wrote: We've got a project where "Date Of Attendance" is moving from a single type in character field to an automatically built field based on a DateBegin date field and a DateEnd date field. Wow, first question is, why accept such a variety of inputs? Can't you force a particular standard for people that allows them to enter a range? I guess I wasn't as clear as I should have been. The previous maintainer allowed anything. We won't. But we want to fix what's already there or at least as much as possible. Matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cannot figure out permissions for fopen/fwrite
Hello, This is probably a dumb newbie question. I am running PHP 5.2.5 and Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache from source a while ago (as opposed to using the built-in web server that is included w/ Mac OS X). I have written the below PHP whose purpose is to read an existing comma separated (CSV) file and save the data into a text file that I can later copy and paste from into my website content management system. The problem is that on my Mac, I cannot seem to figure out what permissions I need to set in order to make the input CSV and the initially non-existant output text file readable and writable by Apache/PHP. I have Googled and come across many pages about different ways to set permissions and different permissions to set but none of the ways suggested that I tried seemed to work for me. As a temporary solution, I uploaded my PHP file to a Windows 2003 server running Apache and PHP and it worked flawlessly (and makes me suspicious that there is some huge security hole with the Windows box since it was able to execute with no permissions modifications). Any tips would be greatly appreciated. Thanks! Mari --- start my code --- $out = fopen("/Applications/apache/htdocs/wp-php/ tableToCutAndPaste.txt", "w"); $counter = 0; fwrite($out, "\n"); while(($data = fgetcsv($in)) !== FALSE) { $paperNumber = $data[0]; $authors = $data[1]; $title = $data[2]; $filename = $paperNumber . ".pdf"; if(($counter % 2) == 0) { fwrite($out, "\n"); } else { fwrite($out, "\n"); } fwrite($out, "http://www.example.com/workingpapers/ getWorkingPaper.php?filename=$filename\">$paperNumber\n"); fwrite($out, "$authors\n"); fwrite($out, "$title\n"); fwrite($out, "\n"); $counter++; } fwrite($out, "\n"); fclose($in); fclose($out); ?> --- end my code --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: cannot figure out permissions for fopen/fwrite
Mari Masuda wrote: > Hello, > > This is probably a dumb newbie question. I am running PHP 5.2.5 and > Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache > from source a while ago (as opposed to using the built-in web server > that is included w/ Mac OS X). I have written the below PHP whose > purpose is to read an existing comma separated (CSV) file and save the > data into a text file that I can later copy and paste from into my > website content management system. The problem is that on my Mac, I > cannot seem to figure out what permissions I need to set in order to > make the input CSV and the initially non-existant output text file > readable and writable by Apache/PHP. I have Googled and come across > many pages about different ways to set permissions and different > permissions to set but none of the ways suggested that I tried seemed to > work for me. As a temporary solution, I uploaded my PHP file to a > Windows 2003 server running Apache and PHP and it worked flawlessly (and > makes me suspicious that there is some huge security hole with the > Windows box since it was able to execute with no permissions > modifications). Any tips would be greatly appreciated. Thanks! > > Mari > > --- start my code --- > > $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r"); > $out = > fopen("/Applications/apache/htdocs/wp-php/tableToCutAndPaste.txt", "w"); > $counter = 0; > > > fwrite($out, "\n"); > > while(($data = fgetcsv($in)) !== FALSE) { > $paperNumber = $data[0]; > $authors = $data[1]; > $title = $data[2]; > $filename = $paperNumber . ".pdf"; > > if(($counter % 2) == 0) { > fwrite($out, "\n"); > } else { > fwrite($out, "\n"); > } > > fwrite($out, " href=\"http://www.example.com/workingpapers/getWorkingPaper.php?filename=$filename\";>$paperNumber\n"); > > fwrite($out, "$authors\n"); > fwrite($out, "$title\n"); > fwrite($out, "\n"); > > $counter++; > } > > fwrite($out, "\n"); > > > fclose($in); > fclose($out); > > ?> > --- end my code --- What are the permissions on /Applications/apache/htdocs/wp-php/ ? Apache needs write permissions on that dir in order to create the file tableToCutAndPaste.txt. It's probably not a secure idea to give write permissions to that dir, so maybe create a subdir of tmp and change those permissions (one way): mkdir /Applications/apache/htdocs/wp-php/tmp chmod a+w /Applications/apache/htdocs/wp-php/tmp -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: cannot figure out permissions for fopen/fwrite
Shawn McKenzie wrote: > Mari Masuda wrote: >> Hello, >> >> This is probably a dumb newbie question. I am running PHP 5.2.5 and >> Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache >> from source a while ago (as opposed to using the built-in web server >> that is included w/ Mac OS X). I have written the below PHP whose >> purpose is to read an existing comma separated (CSV) file and save the >> data into a text file that I can later copy and paste from into my >> website content management system. The problem is that on my Mac, I >> cannot seem to figure out what permissions I need to set in order to >> make the input CSV and the initially non-existant output text file >> readable and writable by Apache/PHP. I have Googled and come across >> many pages about different ways to set permissions and different >> permissions to set but none of the ways suggested that I tried seemed to >> work for me. As a temporary solution, I uploaded my PHP file to a >> Windows 2003 server running Apache and PHP and it worked flawlessly (and >> makes me suspicious that there is some huge security hole with the >> Windows box since it was able to execute with no permissions >> modifications). Any tips would be greatly appreciated. Thanks! >> >> Mari >> >> --- start my code --- >> > >> $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r"); >> $out = >> fopen("/Applications/apache/htdocs/wp-php/tableToCutAndPaste.txt", "w"); >> $counter = 0; >> >> >> fwrite($out, "\n"); >> >> while(($data = fgetcsv($in)) !== FALSE) { >> $paperNumber = $data[0]; >> $authors = $data[1]; >> $title = $data[2]; >> $filename = $paperNumber . ".pdf"; >> >> if(($counter % 2) == 0) { >> fwrite($out, "\n"); >> } else { >> fwrite($out, "\n"); >> } >> >> fwrite($out, "> href=\"http://www.example.com/workingpapers/getWorkingPaper.php?filename=$filename\";>$paperNumber\n"); >> >> fwrite($out, "$authors\n"); >> fwrite($out, "$title\n"); >> fwrite($out, "\n"); >> >> $counter++; >> } >> >> fwrite($out, "\n"); >> >> >> fclose($in); >> fclose($out); >> >> ?> >> --- end my code --- > > What are the permissions on /Applications/apache/htdocs/wp-php/ ? > > Apache needs write permissions on that dir in order to create the file > tableToCutAndPaste.txt. > > It's probably not a secure idea to give write permissions to that dir, > so maybe create a subdir of tmp and change those permissions (one way): > > mkdir /Applications/apache/htdocs/wp-php/tmp > chmod a+w /Applications/apache/htdocs/wp-php/tmp > Also, turn on error reporting so that you can see the exact problem. It may not be what you think. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: cannot figure out permissions for fopen/fwrite
On Jul 1, 2009, at 12:20, Shawn McKenzie wrote: Shawn McKenzie wrote: Mari Masuda wrote: Hello, This is probably a dumb newbie question. I am running PHP 5.2.5 and Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache from source a while ago (as opposed to using the built-in web server that is included w/ Mac OS X). I have written the below PHP whose purpose is to read an existing comma separated (CSV) file and save the data into a text file that I can later copy and paste from into my website content management system. The problem is that on my Mac, I cannot seem to figure out what permissions I need to set in order to make the input CSV and the initially non-existant output text file readable and writable by Apache/PHP. I have Googled and come across many pages about different ways to set permissions and different permissions to set but none of the ways suggested that I tried seemed to work for me. As a temporary solution, I uploaded my PHP file to a Windows 2003 server running Apache and PHP and it worked flawlessly (and makes me suspicious that there is some huge security hole with the Windows box since it was able to execute with no permissions modifications). Any tips would be greatly appreciated. Thanks! Mari --- start my code --- fopen("/Applications/apache/htdocs/wp-php/ tableToCutAndPaste.txt", "w"); $counter = 0; fwrite($out, "\n"); while(($data = fgetcsv($in)) !== FALSE) { $paperNumber = $data[0]; $authors = $data[1]; $title = $data[2]; $filename = $paperNumber . ".pdf"; if(($counter % 2) == 0) { fwrite($out, "\n"); } else { fwrite($out, "\n"); } fwrite($out, "href=\"http://www.example.com/workingpapers/getWorkingPaper.php? filename=$filename\">$paperNumber\n"); fwrite($out, "$authors\n"); fwrite($out, "$title\n"); fwrite($out, "\n"); $counter++; } fwrite($out, "\n"); fclose($in); fclose($out); ?> --- end my code --- What are the permissions on /Applications/apache/htdocs/wp-php/ ? Apache needs write permissions on that dir in order to create the file tableToCutAndPaste.txt. It's probably not a secure idea to give write permissions to that dir, so maybe create a subdir of tmp and change those permissions (one way): mkdir /Applications/apache/htdocs/wp-php/tmp chmod a+w /Applications/apache/htdocs/wp-php/tmp Also, turn on error reporting so that you can see the exact problem. It may not be what you think. -- Thanks! -Shawn http://www.spidean.com Thanks for the suggestions. I added the following lines to the very top of my code: error_reporting(E_ALL); mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true); chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w"); and I also changed the line where it tries to open the file to write to to go to the new directory: $out = fopen("/Applications/apache/htdocs/wp-php/tmp/ tableToCutAndPaste.txt", "w"); Below are the errors I got: --- start errors --- Warning: mkdir() [function.mkdir]: Permission denied in /Applications/ apache/htdocs/wp-php/generateTable.php on line 5 Warning: chmod() [function.chmod]: No such file or directory in / Applications/apache/htdocs/wp-php/generateTable.php on line 6 Warning: fopen(/Applications/apache/htdocs/wp-php/tmp/ tableToCutAndPaste.txt) [function.fopen]: failed to open stream: No such file or directory in /Applications/apache/htdocs/wp-php/ generateTable.php on line 9 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 13 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 22 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 27 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 28 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 29 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 30 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 35 Warning: fclose(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 39 --- end errors --- The permissions are as follows (sorry I didn't think to include them in my original message): [Wed Jul 01 12:28:29] ~: ls -la /Applications/apache/htdocs/wp-php/ total 64 drwxr-xr-x5 mari admin170 Jun 29 16:47 . drwxr-xr-x 24 mari admin8
Re: [PHP] Re: cannot figure out permissions for fopen/fwrite
Mari Masuda wrote: > On Jul 1, 2009, at 12:20, Shawn McKenzie wrote: > >> Shawn McKenzie wrote: >>> Mari Masuda wrote: Hello, This is probably a dumb newbie question. I am running PHP 5.2.5 and Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache from source a while ago (as opposed to using the built-in web server that is included w/ Mac OS X). I have written the below PHP whose purpose is to read an existing comma separated (CSV) file and save the data into a text file that I can later copy and paste from into my website content management system. The problem is that on my Mac, I cannot seem to figure out what permissions I need to set in order to make the input CSV and the initially non-existant output text file readable and writable by Apache/PHP. I have Googled and come across many pages about different ways to set permissions and different permissions to set but none of the ways suggested that I tried seemed to work for me. As a temporary solution, I uploaded my PHP file to a Windows 2003 server running Apache and PHP and it worked flawlessly (and makes me suspicious that there is some huge security hole with the Windows box since it was able to execute with no permissions modifications). Any tips would be greatly appreciated. Thanks! Mari --- start my code --- >>> $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r"); $out = fopen("/Applications/apache/htdocs/wp-php/tableToCutAndPaste.txt", "w"); $counter = 0; fwrite($out, "\n"); while(($data = fgetcsv($in)) !== FALSE) { $paperNumber = $data[0]; $authors = $data[1]; $title = $data[2]; $filename = $paperNumber . ".pdf"; if(($counter % 2) == 0) { fwrite($out, "\n"); } else { fwrite($out, "\n"); } fwrite($out, ">>> href=\"http://www.example.com/workingpapers/getWorkingPaper.php?filename=$filename\";>$paperNumber\n"); fwrite($out, "$authors\n"); fwrite($out, "$title\n"); fwrite($out, "\n"); $counter++; } fwrite($out, "\n"); fclose($in); fclose($out); ?> --- end my code --- >>> >>> What are the permissions on /Applications/apache/htdocs/wp-php/ ? >>> >>> Apache needs write permissions on that dir in order to create the file >>> tableToCutAndPaste.txt. >>> >>> It's probably not a secure idea to give write permissions to that dir, >>> so maybe create a subdir of tmp and change those permissions (one way): >>> >>> mkdir /Applications/apache/htdocs/wp-php/tmp >>> chmod a+w /Applications/apache/htdocs/wp-php/tmp >>> >> >> Also, turn on error reporting so that you can see the exact problem. It >> may not be what you think. >> >> -- >> Thanks! >> -Shawn >> http://www.spidean.com > > > Thanks for the suggestions. I added the following lines to the very top > of my code: > > error_reporting(E_ALL); > > mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true); > chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w"); > > and I also changed the line where it tries to open the file to write to > to go to the new directory: > > $out = > fopen("/Applications/apache/htdocs/wp-php/tmp/tableToCutAndPaste.txt", > "w"); > > Below are the errors I got: > --- start errors --- > Warning: mkdir() [function.mkdir]: Permission denied in > /Applications/apache/htdocs/wp-php/generateTable.php on line 5 > > Warning: chmod() [function.chmod]: No such file or directory in > /Applications/apache/htdocs/wp-php/generateTable.php on line 6 > > Warning: > fopen(/Applications/apache/htdocs/wp-php/tmp/tableToCutAndPaste.txt) > [function.fopen]: failed to open stream: No such file or directory in > /Applications/apache/htdocs/wp-php/generateTable.php on line 9 > > Warning: fwrite(): supplied argument is not a valid stream resource in > /Applications/apache/htdocs/wp-php/generateTable.php on line 13 > > Warning: fwrite(): supplied argument is not a valid stream resource in > /Applications/apache/htdocs/wp-php/generateTable.php on line 22 > > Warning: fwrite(): supplied argument is not a valid stream resource in > /Applications/apache/htdocs/wp-php/generateTable.php on line 27 > > Warning: fwrite(): supplied argument is not a valid stream resource in > /Applications/apache/htdocs/wp-php/generateTable.php on line 28 > > Warning: fwrite(): supplied argument is not a valid stream resource in > /Applications/apache/htdocs/wp-php/generateTable.php on line 29 > > Warning: fwrite(): supplied argument is not a valid stream resource in > /Applications/apache/htdocs/wp-php/generateTable.php on line 30 > > Warning: fwrite(): supplied argument is not a
Re: [PHP] Re: cannot figure out permissions for fopen/fwrite
On Jul 1, 2009, at 12:54, Shawn McKenzie wrote: Mari Masuda wrote: On Jul 1, 2009, at 12:20, Shawn McKenzie wrote: Shawn McKenzie wrote: Mari Masuda wrote: Hello, This is probably a dumb newbie question. I am running PHP 5.2.5 and Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache from source a while ago (as opposed to using the built-in web server that is included w/ Mac OS X). I have written the below PHP whose purpose is to read an existing comma separated (CSV) file and save the data into a text file that I can later copy and paste from into my website content management system. The problem is that on my Mac, I cannot seem to figure out what permissions I need to set in order to make the input CSV and the initially non-existant output text file readable and writable by Apache/PHP. I have Googled and come across many pages about different ways to set permissions and different permissions to set but none of the ways suggested that I tried seemed to work for me. As a temporary solution, I uploaded my PHP file to a Windows 2003 server running Apache and PHP and it worked flawlessly (and makes me suspicious that there is some huge security hole with the Windows box since it was able to execute with no permissions modifications). Any tips would be greatly appreciated. Thanks! Mari --- start my code --- \n"); while(($data = fgetcsv($in)) !== FALSE) { $paperNumber = $data[0]; $authors = $data[1]; $title = $data[2]; $filename = $paperNumber . ".pdf"; if(($counter % 2) == 0) { fwrite($out, "\n"); } else { fwrite($out, "\n"); } fwrite($out, "href=\"http://www.example.com/workingpapers/getWorkingPaper.php? filename=$filename\">$paperNumber\n"); fwrite($out, "$authors\n"); fwrite($out, "$title\n"); fwrite($out, "\n"); $counter++; } fwrite($out, "\n"); fclose($in); fclose($out); ?> --- end my code --- What are the permissions on /Applications/apache/htdocs/wp-php/ ? Apache needs write permissions on that dir in order to create the file tableToCutAndPaste.txt. It's probably not a secure idea to give write permissions to that dir, so maybe create a subdir of tmp and change those permissions (one way): mkdir /Applications/apache/htdocs/wp-php/tmp chmod a+w /Applications/apache/htdocs/wp-php/tmp Also, turn on error reporting so that you can see the exact problem. It may not be what you think. -- Thanks! -Shawn http://www.spidean.com Thanks for the suggestions. I added the following lines to the very top of my code: error_reporting(E_ALL); mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true); chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w"); and I also changed the line where it tries to open the file to write to to go to the new directory: $out = fopen("/Applications/apache/htdocs/wp-php/tmp/ tableToCutAndPaste.txt", "w"); Below are the errors I got: --- start errors --- Warning: mkdir() [function.mkdir]: Permission denied in /Applications/apache/htdocs/wp-php/generateTable.php on line 5 Warning: chmod() [function.chmod]: No such file or directory in /Applications/apache/htdocs/wp-php/generateTable.php on line 6 Warning: fopen(/Applications/apache/htdocs/wp-php/tmp/tableToCutAndPaste.txt) [function.fopen]: failed to open stream: No such file or directory in /Applications/apache/htdocs/wp-php/generateTable.php on line 9 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 13 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 22 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 27 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 28 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 29 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 30 Warning: fwrite(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 35 Warning: fclose(): supplied argument is not a valid stream resource in /Applications/apache/htdocs/wp-php/generateTable.php on line 39 --- end errors --- The permissions are as follows (sorry I didn't think to include them in my original message): [Wed Jul 01 12:28:29] ~: ls -la /Applications/apache/htdocs/wp-php/ total 64 drwxr-xr-x5 mari admin170 Jun 29 16:47 . drwxr-xr-x 24 mari admin816 Jun 29 16:47 .. -rw-r--r--1 mari admin 6148 Jun 28 21:
[PHP] Call for testing: New PHP 5.3 debian packages
(Please excuse the gratuitous cross-post) Now that PHP 5.3 has been officially released[1], the Debian PHP packaging team would like to announce the availability of PHP 5.3 packages for initial public testing. The packages are currently available for both amd64 and i386 users of testing/unstable, via the "experimental" release section of the debian packaging archive. To install these packages on your system, add the following line to /etc/apt/sources.list: deb http://ftp.debian.org/debian/ experimental main you should then be able to install these packages with apt-get install -t experimental php5 (and you can replace php5 with a more specific package selection of course) DISCLAIMER: You should not install these packages on a production system, until they have recieved wider testing and review. I have given the packages limited local testing but due to the nature of the 5.3 upgrade it's possible that you may have problems with either the packaging or one of the many changes in this update! As time progresses we may set up an alternate location dedicated for php5.3 related packages, depending on demand, how many additional packages we need to rebuild for testing (all debian packages that build against the php API/ABI need to be updated) and how long we delay the transition to 5.3 in debian unstable. I should emphasize that we don't have plans to transition to PHP 5.3 in debian testing/unstable in the immediate future; at least not until we feel comfortable that the packages and software are reasonably stable and tested. So if you want to see this happen faster the best thing you can do is report to us with your problems (and successes!) using these packages. Please forward any and all feedback/problems to the Debian PHP team's mailing list[2] and if you're convinced that there's a problem, the debian bug tracking system[3] and/or the PHP bug tracking system[4] depending on who you think should get the blame :). Sean Finney (and the rest of the Debian PHP Maintainers) [1] http://www.php.net/archive/2009.php#id2009-06-30-1 [2] pkg-php-ma...@lists.alioth.debian.org [3] "reportbug php5" [4] http://bugs.php.net signature.asc Description: Digital signature
[PHP] Apache module PHP 5.3 on Windows
Hi, I just downloaded the new stable version of PHP 5.3 and I couldnt find the php5apache2_2.dll file. Is the apache module on windows no longer supported? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache module PHP 5.3 on Windows
What version, VC6 or VC9, TS or NTS? I use VC6 TS and the dll is there... On Wed, Jul 1, 2009 at 7:31 PM, Pablo Viquez wrote: > Hi, > > I just downloaded the new stable version of PHP 5.3 and I couldnt find the > php5apache2_2.dll file. > > Is the apache module on windows no longer supported? > > Thanks! > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache module PHP 5.3 on Windows
Yes, you need to use the V6 installer, I did the same thing with the V9 and it won't work. Only after uninstalling PHP did I see that line of text saying which one to use... On Wed, Jul 1, 2009 at 5:54 PM, Jonathan Tapicer wrote: > What version, VC6 or VC9, TS or NTS? I use VC6 TS and the dll is there... > > On Wed, Jul 1, 2009 at 7:31 PM, Pablo Viquez > wrote: > > Hi, > > > > I just downloaded the new stable version of PHP 5.3 and I couldnt find > the > > php5apache2_2.dll file. > > > > Is the apache module on windows no longer supported? > > > > Thanks! > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- - Adam Shannon ( http://ashannon.us )
[PHP] removing an array from a compound array
I have a compound array, that is, an array of an array of an array, etc, that is about 5 arrays deep. I currently search thru all of these arrays, and based on some criteria, I want to delete one of the arrays (along with all of its sub-arrays) in the middle. What is the easiest way to delete such an "embedded" array? array_splice() looked like a possibility, however, it requires that I specify the array for removal by using offsets which seems odd to me. Isn't there a way to remove array A from array B? Thanks, -Andres -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache module PHP 5.3 on Windows
Sorry my mistake, I was looking in the wrong built. Thank you! - Original Message - From: "Adam Shannon" Newsgroups: php.general To: "Jonathan Tapicer" Cc: "Pablo Viquez" ; Sent: Wednesday, July 01, 2009 5:50 PM Subject: Re: [PHP] Apache module PHP 5.3 on Windows Yes, you need to use the V6 installer, I did the same thing with the V9 and it won't work. Only after uninstalling PHP did I see that line of text saying which one to use... On Wed, Jul 1, 2009 at 5:54 PM, Jonathan Tapicer wrote: What version, VC6 or VC9, TS or NTS? I use VC6 TS and the dll is there... On Wed, Jul 1, 2009 at 7:31 PM, Pablo Viquez wrote: > Hi, > > I just downloaded the new stable version of PHP 5.3 and I couldnt find the > php5apache2_2.dll file. > > Is the apache module on windows no longer supported? > > Thanks! > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - Adam Shannon ( http://ashannon.us ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exasperated again
PJ wrote: Could somebody please explain to me what is wrong with this code? In my script it works, returns the correct id, but when I try it in a test pages, nothing in the world gets it to work. This is rather frustrating, again: THIS WORKS IN ANOTHER PAGE; IN THE TEST PAGE ID DOES NOT. $sql = "SELECT id FROM publishers WHERE publisher = 'whoever'"; $result = mysql_query($sql,$db); $row = mysql_fetch_assoc($result); if (mysql_num_rows($result) !== 0) { $pub = $row['id']; Syntax is ok, echo "hello"; works. This works in the test page: $aid = array(); $ord = array(); $sql = "SELECT authID, ordinal FROM book_author WHERE bookid = 624 ORDER BY ordinal ASC"; $result = mysql_query($sql, $db); //$row = mysql_fetch_assoc($result); while ( $row = mysql_fetch_assoc($result) ) { $aid[]=$row['authID']; $ord[]=$row['ordinal']; } var_dump($aid); echo ""; var_dump($ord); echo $aid[0], " - "; echo $ord[0]; This does not: $fi="joe"; $la="joe"; $sql = "SELECT id FROM author WHERE first_name = '$fi' && last_name = '$la'"; $result = msql_query($sql, $db); $row = mysql_fetch_assoc($result); $count=mysql_num_rows($result); echo $count; if (mysql_num_rows($result) > 0) { $a_id=$row['id']; } echo $a_id, ""; The test page prints out echo "some text"; but no results when the results are there Tell me I have missed something simple here, or is this normal for php ? I have checked the queries on Mysql command line and they are fine. I have verified the syntax and Netbeans tells me it is fine. Same results Firefox3 (2 machines) & IE 8. What is not fine? I was preaching this to you months ago. You should have error reporting turned on in a development area. by that I mean php should be set to display_errors = on and error_reporting = E_ALL Give this a try in a development area and "you will see the errors of your ways..." -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exasperated again
2009/6/30 PJ : > Could somebody please explain to me what is wrong with this code? > In my script it works, returns the correct id, but when I try it in a > test pages, nothing in the world gets it to work. This is rather > frustrating, again: > THIS WORKS IN ANOTHER PAGE; IN THE TEST PAGE ID DOES NOT. > $sql = "SELECT id FROM publishers > WHERE publisher = 'whoever'"; > $result = mysql_query($sql,$db); > $row = mysql_fetch_assoc($result); > if (mysql_num_rows($result) !== 0) { > $pub = $row['id']; > Syntax is ok, echo "hello"; works. > > > This works in the test page: > $aid = array(); > $ord = array(); > $sql = "SELECT authID, ordinal > FROM book_author WHERE bookid = 624 ORDER BY ordinal ASC"; > $result = mysql_query($sql, $db); > //$row = mysql_fetch_assoc($result); > while ( $row = mysql_fetch_assoc($result) ) { > $aid[]=$row['authID']; > $ord[]=$row['ordinal']; > } > var_dump($aid); > echo ""; > var_dump($ord); > echo $aid[0], " - "; > echo $ord[0]; > > This does not: > $fi="joe"; $la="joe"; > $sql = "SELECT id FROM author > WHERE first_name = '$fi' && last_name = '$la'"; > $result = msql_query($sql, $db); > $row = mysql_fetch_assoc($result); > $count=mysql_num_rows($result); > echo $count; > if (mysql_num_rows($result) > 0) { > $a_id=$row['id']; > } > echo $a_id, ""; > The test page prints out echo "some text"; but no results when the > results are there > Tell me I have missed something simple here, or is this normal for php ? > I have checked the queries on Mysql command line and they are fine. > I have verified the syntax and Netbeans tells me it is fine. > Same results Firefox3 (2 machines) & IE 8. > What is not fine? > > -- > Hervé Kempf: "Pour sauver la planète, sortez du capitalisme." > - > Phil Jourdan --- p...@ptahhotep.com > http://www.ptahhotep.com > http://www.chiccantine.com/andypantry.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Is that exactly your code? see your 4th line: > $result = msql_query($sql, $db); you forgot the "y" in mysql_query function... if you have a 500 error code maybe this is the problem -- Maximiliano Churichi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP --info giving segmentation fault
Hi All, I am using CentOS 5.3-x8664. I installed PHP and Apache httpd. The following are the version informations present on the system: #httpd -v Server version: Apache/2.2.3 # php -v PHP 5.1.6 (cli) (built: Jan 21 2009 01:45:01) The problem is when accessing through web page it is giving blank, i am getting the following error messages in /var/log/httpd/error_log: ... ... [Wed Jul 01 00:48:58 2009] [notice] child pid 4408 exit signal Segmentation fault (11) [Wed Jul 01 00:49:10 2009] [notice] child pid 4411 exit signal Segmentation fault (11) [Wed Jul 01 00:55:32 2009] [notice] caught SIGTERM, shutting down [Wed Jul 01 00:55:43 2009] [notice] Digest: generating secret for digest authentication ... [Wed Jul 01 00:55:43 2009] [notice] Digest: done [Wed Jul 01 00:55:43 2009] [notice] Apache/2.2.3 (CentOS) configured -- resuming normal operations *** glibc detected *** /usr/sbin/httpd: double free or corruption (out): 0x2ab491c70cf0 *** ... ... >From the command prompt when i ran the following i got the following error as the root cause: # php --info . . curl CURL support => enabled CURL Information => libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 date *** glibc detected *** php: munmap_chunk(): invalid pointer: 0x2b605055cc00 *** === Backtrace: = /lib64/libc.so.6(cfree+0x1b6)[0x3bd2675a36] php(timelib_builtin_db+0x283)[0x46f5d3] php(zm_info_date+0xa3)[0x456b23] php[0x4f3614] php(zend_hash_apply_with_argument+0x3f)[0x58360f] php(php_print_info+0xa04)[0x4f4a04] php(main+0x400)[0x5f26d0] /lib64/libc.so.6(__libc_start_main+0xf4)[0x3bd261d974] php[0x437bc9] === Memory map: 0040-00684000 r-xp 08:01 2021503 /usr/bin/php 00883000-008a6000 rw-p 00283000 08:01 2021503 /usr/bin/php 008a6000-008b3000 rw-p 008a6000 00:00 0 00aa5000-00ab8000 rw-p 002a5000 08:01 2021503 /usr/bin/php 0e082000-0e1ed000 rw-p 0e082000 00:00 0 [heap] 3bd220-3bd221c000 r-xp 08:01 2512616 /lib64/ld-2.5.so 3bd241b000-3bd241c000 r--p 0001b000 08:01 2512616 /lib64/ld-2.5.so 3bd241c000-3bd241d000 rw-p 0001c000 08:01 2512616 /lib64/ld-2.5.so 3bd260-3bd274c000 r-xp 08:01 2512617 /lib64/libc-2.5.so 3bd274c000-3bd294c000 ---p 0014c000 08:01 2512617 /lib64/libc-2.5.so 3bd294c000-3bd295 r--p 0014c000 08:01 2512617 /lib64/libc-2.5.so 3bd295-3bd2951000 rw-p 0015 08:01 2512617 /lib64/libc-2.5.so . . Aborted Can someone help me in resolving the above errors. Thanks and Regards, Vivek -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Raw-listing Problem
Hi there everyone, First of all, let me thank you for your always-present help in this list; I (as a newbie) appreciate it very much! :) However, pardon me for I need to trouble you with another piece of text that doesn't do what it should do: I need to parse the raw-listing of an FTP into it's parts (the code comes from the book published by Wrox, however, I don't have the book in my posession to check the two versions against each other), but it returns an empty list. Here is the code: [code] switch ($this->systype){ //Parse raw dir listing into fields case 'Windows_NT': //Handle WinNT FTP servers $re = '/^.' . '([0-9-]+\s+)'. //Get last mod date '\d\d:\d\d..)\s+' . //Get last mod time '(\S+)\s+' .//Get size or dir info '(.+)$/';//Get file/dir name break; case 'UNIX': //Handle UNIX FTP servers default://case UNIX falls through to default $re = '/'. //Regax to parse common server dir into '^(.)' . //Get entry type info (file/dir/etc.) '(\S+)\s+' . //Get permissions info '\S+\s+'. //Find, but don't capture hard link info '(\S+)\s+' . //Get owner name '(\S+)\s+' . //Get group name '(\S+)\s+' . //Get size '(\S+\s+\S+\s+\S+\s+)' . //Get file/dir last mod time '(.+)$/'; //Get file/dir name break; } //Map short identifiers to full names $type = array('-'=>'file','d'=>'directory'); $listing = array(); foreach ($temp as $entry) { //loop through raw listings //try to parse raw data into fields $match=preg_match($re,$entry,$matches); if(!$match) { //if we could not parse the listings user_error("The directory listings could not be parsed."); return array(); } switch ($this->systypes){ //Give fileds sensible names case 'Windows_NT';//Handle WinNT-style dir listings $listings[] = array( //Put parsed data into readable format 'type' => is_numeric($matches[2]) ? 'file' : 'directory','permissions' => null,'owner' =>NULL,'group'=>null,'size'=>(int)$matches[2], 'last mod' => $matches[1],'name'=>$matches[3]); break; case 'UNIX': //Handle UNIX FTP-style dir listings default: //case UNIX fails through to default $strings[] = array( //Put data into readable format 'type' =>$type[$matches[1]],'permissions' => $matches[2],'owner' =>$matches[3],'group' => $matches[4],'size' => $matches[5], 'last mod' =>$matches[6],'name'=>$matches[7]); break; } } return $listings; [/code] Since this function is called Is($directory); I tried this: var_dump($ftp_server->Is($ftp_server->cwd)); However, I get null. Why? (It's not that I understand how the raw-listing is being parsed using regular expressions, so it's why I'm asking :) ) Thanks! -- --- Contact info: Skype: parham-d MSN: fire_lizard16 at hotmail dot com email: parham90 at GMail dot com