Re: [PHP] PhpMyAdmin Help Needed
On Wednesday, Oct 16, 2002, at 23:08 Europe/London, Pushpinder Singh Garcha wrote: > I am wanting to use PhpMyAdmin for my project . I am developing using > PHP and MySQl and the OS is Jaguar > I have downloaded the latest version of phpmyadmin and have made > necessary changes in the 'config.inc.php' file > When I try to access PhpMyAdmin using " > http://localhost/~pgarcha/phpmyadmin/index.php"; I get the folowing > error > > Not Found > The requested URL /~pgarcha/phpmyadmin/index.php was not found on this > server. That error is being generated by Apache and is therefore nothing to do with the phpMyAdmin configuration file. My guess is that you have the case wrong. Try http://localhost/~pgarcha/phpMyAdmin/index.php -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Free compiler for Win
On Wednesday, Oct 30, 2002, at 23:02 Europe/London, R B wrote: I need to know how to compile php code with ms visual studio 6.0. Do you want to compile PHP or PHP code? If you want to compile PHP itself full instructions are included in the source distribution. If you want to compile PHP code then I believe there are a couple about - Google should be able to find them for you - but I'm pretty sure none of them work within Visual Studio. If you are looking for a speed increase for a web site your best bet is the Zend accelerator: http://www.zend.com/store/products/zend-accelerator.php I hope that helps. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular expression problem
I just moved some *working* code from a Win2k server running PHP 4.2.1 to a FreeBSD server running 4.2.3 and the following code no longer works... $templatetext = preg_replace("//e", "g_includecallback(\"\\1\")", $templatetext); if (!preg_match("/([[:ascii:]]+?)([[:ascii:]]+?)([[:ascii:]]+?)$/i", $templatetext, $matches)) { // Report the error and stop processing the page g_Halt("Could not find set definition in set list template: $g_setlisttemplate"); } The first line that processes includes works and after that line $templatetext contains the full template with the include statements replaced with the contents of the file. After the preg_match statement has run (and succeeded), $matches[0] should contain the same as $templatetext did after the previous line. However, this is not the case. A sizable chunk of the text at the start of the variable has been lost and I cannot figure out why. Can anyone give me any pointers? Thanks. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting multiple images
On Thursday, Nov 7, 2002, at 14:49 Europe/London, <[EMAIL PROTECTED]> wrote: I've found a little problem that's not explicitly a php problem but I was hoping that php may be the solution. Someone is shown an image and then asked if they wish to change that image. If they answer yes they are taken to an upload form and the new image is upload to the server overwitting the old image using the same filename. They are then taken to a page to show them the image they just uploaded but the old image is diplayed from cache instead of the new photo being shown. I'm using absolute path to the image on the server, not URL. Is there a way to get the script to load in the new photos? When you create the src tag in for the image, add a random number query string - that will cause the browser to request the image instead of using the cached version. I.e... echo ''; -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Other Notice problem...
On Friday, Nov 8, 2002, at 16:44 Europe/London, R B wrote: if i have 2 pages: p01.php and p02.php, with p01.php code: ... ... link ... ... and p02.php code: ... ... echo "$pp"; ... ... If i have register_globals=off, then when i click the link, in p02.php page, the echo command display nothing. If i have register_globals=on, then the echo command displays the value buy this way is deprecated. How can i run the script without problems having register_globals=off? p02.php code: ... ... echo $_GET['pp']; ... ... -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Other Notice problem...
On Friday, Nov 8, 2002, at 16:56 Europe/London, R B wrote: And without using the $_GET[] array. Why don't you want to use the $_GET array? If you really don't want to use it you can use the extract function but if you're going to do that you might as well have register_globals on. -- Stuart p02.php code: ... ... echo $_GET['pp']; ... ... -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Other Notice problem...
On Friday, Nov 8, 2002, at 17:59 Europe/London, R B wrote: It's ok. I understand that i can't use plain variables with register_globals=on, but this is only for GET variables or to all variables? The value of register_globals only affects the CGI variables (get, post, server, cookies, etc). You can use other variables in the same way as you ever did. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
On Friday, Nov 8, 2002, at 21:17 Europe/London, Marco Tabini wrote: I don't think that has to with it... the setting is --with_config_file_path=path if you grep PHP_CONFIG_FILE_PATH config.status in your PHP source folder, you should see where PHP is expecting php.ini to be--and you won't probably find it there, you'll have to copy it there yourself. The easiest way to find out where PHP expects your php.ini to be is to create a page that calls phpinfo() - the configuration file location is near the top of the output. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] catching a robot or spider
On Tue, 19 Nov 2002 14:54:49 +0100 "Wilbert Enserink" <[EMAIL PROTECTED]> wrote: Hi all, does anybody know a way to make a distinction between robots and users? should I use the user agent? Or is this not a safe method. If the visitor is a spider/robot I want to include some script containing extra URL's for the robot. The best way I've found of doing this is to include the links as 1x1 transparent gifs on the index page. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Windows Environment Variables
Rodney Green wrote: $blah = shell_exec ("echo %ComputerName%"); Eww, evil. Try http://php.net/getenv -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wrong output with a - PLEASE HELP
A. Mikkelsen wrote: But when I ECHO 'new_loc_path' in a function I get S:\\Script\\License\\ But I want go get S:\Script\License\ http://php.net/strip_slashes You might also want to look into the magic_quotes_gpc option in php.ini. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wrong output with a - PLEASE HELP
Stuart wrote: http://php.net/strip_slashes http://php.net/stripslashes (oops, sorry) -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing User Agent for fopen
Gohaku wrote: There are some pages I would like to extract links from but I can't access the page using the following: ini_set('php.user_agent', 'Mozilla/5.0'); $url = "http://www.google.com/search?q=php";; $fp = fopen($url,"r"); $buffer = fread($fp,100); echo $buffer; 1) The php.ini option is user_agent, not php.user_agent. Changing that has the desired effect. 2) If you want to query google you're better off using the google SOAP API - it's legal for a start. See the following for more info... http://www.google.com/apis/ http://www.devshed.com/Server_Side/PHP/GoogleAPI/page1.html Also, what is the best number to use when allocating Buffer space for a URL? Is 100 too much? Thanks. -Gohaku 3) You're better off looping to get the full contents than trying to 'guess' how big the file will be. Try the following... http://www.google.com/search?q=php'; $fp = fopen($url, "r"); while (!feof($fp)) { $buffer = fread($fp, 1024); echo $buffer; } ?> -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing User Agent for fopen
Nick Wilson wrote: * and then Stuart declared 2) If you want to query google you're better off using the google SOAP API - it's legal for a start. See the following for more info... http://www.google.com/apis/ http://www.devshed.com/Server_Side/PHP/GoogleAPI/page1.html and http://dietrich.ganx4.com/nusoap/index.php An excellent SOAP tookit. Indeed, as used in the DevShed article :) -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to use anchor with php post string to jump to a page???
Scott Fletcher wrote: Sample script I have here is this... --snip-- http://www.yourserver.com/yourpage.htm#RowNum3"; target="doc">Jump http://www.yourserver.com/yourpage.htm";> --snip-- Where yourpage.htm have this "blah blah" So, question here is how do I pass the post string to the Iframe, like "&color=red" in this example, this example doesn't work... The iframe is the target method --snip-- http://www.yourserver.com/yourpage.htm#RowNum3&color=red target="doc">Jump --snip-- The anchor goes after the query string, like so... http://www.yourserver.com/yourpage.htm?color=red#RowNum3 target="doc">Jump -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] enable_trans_sid problem
Ewald Geschwinde wrote: The problem is the /> at the end. Has anyone seen this before? What can I do against it? Why do you want to get rid of it? It's there to make it valid XHTML. It shouldn't cause any problems. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP LDAP query - need to add Exchange fields
Ben Crothers wrote: At the moment it works fine and extracts fields like first- and surname, title, department, etc. I need to add the 'office' field, and added it at the end of this filter line: --- $filter = "(|(sn=$search[$i]*)(givenname=$search[$i]*)(title=$search[$i]*)(department= $search[$i]*)(office=$search[$i]*))"; ...but so far it's not working. I *know* there's data in the 'office' field -- any ideas as to what I'm missing? Not all of the fields in Exchange are exposed through LDAP (this is from experience, I have no reference to back this up but would appreciate it if someone else has any info on the LDAP implementation in Excahnge 5.5+). I would guess from your question that 'office' is one of the fields that is not. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] _ENV
Diana Castillo wrote: Can someone tell me the name of the environmental variable that tells you the path that you are in? http://php.net/getcwd or for the virtual path to the script... dirname($_SERVER['SCRIPT_NAME']); or for the document root of the current site... $_SERVER['DOCUMENT_ROOT'] -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deamon / server
Decapode Azur wrote: Is it possible to make php scripts working like deamons and build something like a server? Yes. http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-answers.html -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fw: Intermitent problems retreiving PDF's from a MySQL database.
Donald Tyler wrote: I thought that maybe the PDF had been corrupted somehow, but the problem miraculously fixed itself so I didnt have a change to check that out. Now I got a call from one of my users complaining of the exact same problem, which once again miraculously fixed itself after reloading internet explorer. There are no error messages in the apache log or the mysql log. Does anyone have any idea what is going on?!? This is most likely an issue with the client-side (i.e. the Acrobat IE plugin) and not PHP given that restarting IE (i.e. restarting the plugin) solves it. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] picturing webpage
Mike Brum wrote: It could be similar to how you can build a PDF. They could just take your HTML and then use that to build a .JPG. I'm sure it's a very *expensive* process (server & CPU -wise) though. There's an addon for LiveStats (www.mediahouse.com) that does this so it can display thumbs of pages on your site in its reports. It runs on Windows and appears to load the page in and embedded IE instance then takes a screenshot. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Uplaod
Rick Laird wrote: I am trying to uplaod a 3 MB file to a server running apache and PHP. I seem to hitting a 1.7 MB limit on the file size. I do not have max_file_size set in my php.ini. Not having upload_max_filesize set (which I assume is the setting you are referring to) will cause PHP to use the default value of 2MB. Try setting it and see what happens. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php doesn't work in html files
Nico Berg wrote: Hi there all, This index.html look's like this: This is a line Output is: This is a line So the php part is not done at all. Is that right? I always believed php should work in html? Assuming you have the web server set up according to PHP's installation docs, you either need to rename index.html to index.php or tell the web server to run .html files through PHP (refer to the PHP manual for details on how to do this). -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] picturing webpage
PHP Email List wrote: Not sure that you wanted to know this or if this was mentioned already as I'm just now going through my 13,000+ emails from this list, but this isn't done dynamically. I'm betting that this Alexa company gets the urls that are posted for viewing and then goes out to grab the site's pictures manually, I tried 4 sites in my own town and none had pictures, but said "Coming soon" where the pic was to be. I highly doubt they do it manually. I would say it's more likely that the first request for a site gets it added to a queue to be grabbed at some later date and is then periodically updated unless no requests are made for it after a certain period. But I'm just making a slightly educated guess. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Key Test
Cameron B. Prince wrote: How would I go about determining if a specific key exists in an array? http://php.net/isset I want to see if $conf['hOpt'] is defined. is_array only works at the $conf level. I tried count(array_keys($conf, 'hOpt')), but always get 0. if (isset($conf['h0pt'])) -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Accessing a website from within a php script
Børge Strand wrote: Here's what I do next with it. Only now this file (www.boggle.no/test6.php) times out in the brower. Do you see something that it obviously wrong here? ' . "\n"; print 'test6.php'; $fp = fopen("http://www.boggle.no/message.txt";, "r"); $contents = fread($fp); print $contents; fclose ($fp); print '' . "\n"; ?> fread takes 2 parameters: the file pointer and the number of bytes to read. See http://php.net/fread for full info. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to compare between two values?
SASSINC Internet Solutions - Arabic Department wrote: How to compare between two values, One imported from a mySQL DB and the other grabbed by GET (http://www.sitename.com/test.php?value2=3342g345) Waiting your replies.. It is clear that you have not followed Richards advice and downloaded the PHP manual. If you continue to ask questions as basic as this without showing any signs of having read the manual it's likely you won't get an answer. I urge you to get the manual from http://php.net/docs and try to find your answer in there. I would also recommend buying an book that will introduce you to the fundamentals of PHP. There is a list of titles here: http://php.net/books -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Schedule an Event with PHP
Alex Pilson wrote: Say I want a MySQL database to have a table that holds certain events, the Event table. And in the event table, one of the records is an event that has a startdate of today, I want to check against that date, if it equals now, then do this Besides using CRON to hit that particular event table, is there any other method I am not thinking of that can be used with PHP? I want to check that event table every 5 minutes. Please don't reply to a message to start a new topic - it really screws up the threading built into decent mail clients. There are other methods like running a PHP script as a daemon and getting web requests to check each time but neither of those are anywhere near as reliable or efficient as cron. Why don't you want to use cron? -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What is wrong with these Codes!!!!???
Radwan Aladdin wrote: I made these three PHP files.. but I don't know where is the problem Now that's a lie isn't it. Nearly all PHP errors/warnings/notices display the script filename and line number where the problem was encountered. If you can't figure out where the problem is from that you might as well pack up and go home now. Now.. The Login.php page is saying : *Parse error*: parse error in *c:\apache\htdocs\user\login.php* on line *20* ** This could mean one of many things. Check that line for any typos. If you don't find any check the line(s) that precede it. The Activate.php page is saying : *Warning*: Supplied argument is not a valid MySQL-Link resource in *c:\apache\htdocs\admin\activate.php* on line *31* The Deactivate.php is saying the same as the Activate.php error. This error means your SQL query failed. You should be checking the that the result from mysql_query !== false (note the 2 = signs). Check your SQL and fix it. If you can't see a problem try running the query from the mysql command line. So I don't know where is the problem!!! everything is okay.. And there is no errors in the scripts.. so can you please take a look at them..maybe there is some falts.. Hmm. There clearly are errors in the scripts or PHP would not be complaining about them. I attached the THREE PHP files with the TWO HTM files for the activation (POST the UserName for the Activation and Deactivation) Also with the .sql file of the database No you didn't... which is actually a good thing. Feel free to include snippets of code, ideally 3-4 lines before and after the line specified in the error message, but I (and I'm sure many others) on this list would prefer it if you didn't send attachments - I get enough crap in my mailbox as it is. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cookie Guestion
CPT John W. Holmes wrote: From: "Chris W" <[EMAIL PROTECTED]> I am still new to web programing but I have a lot of experience in developing non web based applications. So I think I am a reasonably clever programmer and I have now done enough web programming that I understand the cookie mechanism. What I can't figure out is why so many people are paranoid about cookies. I don't really see much of anything that can be done with cookies to invade someones privacy. Am I missing something here? Exactly. The problem isn't the mechanism, it's the implementation by the programmer. If you save my favorite color in a cookie, no big deal. If you save my username and password in a cookie, that is a big deal. Cookies are sent back and forth between the web server and client in plain text, so it can be captured. The other thing to realize is that cookies can be changed; they come from the client. So if you set my "id" to 555 in a cookie and that determines who I am for you site, I can change the "id" to 333 and become another person. Again, it's a problem with the implementation by the program, not cookies themselves. And don't forget the effect media hype had on their reputation. Cookies were portrayed as bad guys. As John says, they're not if they're used correctly, but it only takes one high-profile example of improper use to tarnish a reputation forever. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running PHP as a CGI, chasing my own tail....
pw wrote: In my httpd.conf file I have placed the lines: AddHandler phtml-script .phtml Action phtml-script /cgi-bin/php I have a symlink in my cgi-bin directory to the php executable. Am I missing anything else to make this work? A clue-by-four about security. If that was to work you would be opening your server up to any kind of attack an attacker could thinking of. We're talking *wide* open. 1) Why can't you use the PHP module? 2) What version of Apache are you using? If Apache 1.3, the manual[1] gives clear instructions on how to set this up... ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .php .phtml Action application/x-httpd-php "/php/php.exe" See here: http://uk.php.net/manual/en/install.apache.php If Apache 2, I'm not sure what they steps are, but I ask again, why can't you use the module? [1] http://uk.php.net/manual/en/install.apache.php -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running PHP as a CGI, chasing my own tail....
pw wrote: I can't use the php module because a third party application requires php to be available via CGI. CGI or CLI? I'm betting on the latter because I'm not aware of any feature a script could require that is only provided by the PHP executable and not the module. In which case you can have both the module and the CLI version running at the same time. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestion on executing external programs from within php
John Clegg wrote: I would like to be able to execute 2 system calls simultaneously. I am not interested in the output and I would like to do the equivalent of a fork as these programs take a long time. system('/usr/local/bin/process_file file1'); system('/usr/local/bin/process_file file2'); system('/usr/local/bin/process_file file1 &'); system('/usr/local/bin/process_file file2 &'); Should work in theory. Haven't test it though. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] newbie issues with control structures & HTML form
Jonno Agnew wrote: if ($guessnumb) { Try $_GET['guessnumb'] or $_POST['guessnumb'] if the form is posted. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Weird problem with objects
Mark Cubitt wrote: $this->$database = new database(); $this->$accessory = new accessory(); $this->$order = new order(); These should be... $this->database = new database(); $this->accessory = new accessory(); $this->order = new order(); You don't want the $ unless $database, $accessory and $order are strings containing the class attribute names. Additionally, you might want to assign the reference of the new objects otherwise PHP will create a new object and then make a copy of it - not very efficient. Like so... $this->database = & new database(); $this->accessory = & new accessory(); $this->order = & new order(); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RE : [PHP] Weird problem with objects
Vincent DUPONT wrote: what do you mean by this :Additionally, you might want to assign the reference of the new objects otherwise PHP will create a new object and then make a copy of it - not very efficient. Like so... $this->database = & new database(); $this->accessory = & new accessory(); $this->order = & new order(); The = operator makes a copy of the right side and puts it into the left side. So the "new database()" bit will create a new object of type database. The = operator will then make a copy of that object and put it into $this->database. So it's actually creating 2 database objects one of which will get deleted at the end of the function. By assigning the reference (that's what the & gets) only one object is created. Does that make sense now? -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestion on executing external programs from within php
John Clegg wrote: I have finally had a chance to test your suggestion and I am still getting a browser timeout ? The 1st program runs to completion even though the broswer times out. So it doesn't execute the second program :-( I have also tried `/usr/local/bin/process_file file1 &` exec('/usr/local/bin/process_file file1 &') Any ideas?? Yup. Having checked the system function in the manual (http://php.net/system), it says this... "Note: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends." So try this... system('/usr/local/bin/process_file file1 > /dev/null &'); system('/usr/local/bin/process_file file2 > /dev/null &'); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Shared mod_php doesn't always load php.ini
Matt Matijevich wrote: Hi, I noticed that often mod_php loaded as a shared library by apache doesn't load php.ini, and I have to restart apache to make it work. Apache version is 1.3.28 and Php is 4.3.4, all compiled by me. They are running on an updated RedHat 7.3. Is it a known (and solved) problem? I may be way off base here (I am far from an expert on apache), but I think when you use mod_php, the php.ini is only loaded one time, right when apache starts up. Some of the other posters can probably tell you if I am correct or not. Yup, that's correct. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why we love Microsoft (0t)
Ryan A wrote: Anyway, a 17yr old kid by the name of Mike Rowe opens up a webdesigning company and names it MikeRoweSoft (say it out loud..if you're really daft not to get it just be reading it)..then registers mikerowesoft.com...a couple of days later he gets an email from microsoft's lawyers to hand over the domain for 10$...he refuses and says no way, how about 10,000? a couple of days later he gets a legal document of around 25 pages from the lawyers!! They are going after him extortion!! Read the whole thing at mikerowesoft.com its pretty amusing, gives a totally new meaning to scumbags, sons of bitches and cheap bastards...oops, hope i dont get sued for saying that. Another case of hearing only one side of the story. The following was posted in the forums at mikerowesoft.com (now removed, unsurprisingly)... "I listened to your interview on CBC radio. You said, on live radio, that you did choose the domain name because of Microsoft's public profile. Then, less than a minute later, you claimed to have been surprised that Microsoft was suing you. But, you had admitted everything in the first minute of your interview. Then, you went on to say that you didn't expect you would be able to keep the domain. This sounds suspicious and I think Microsoft has every right to say that you were looking for a pay off at a later date -- not to mention, the publicity." His case fell apart the moment he admitted that that was the reason he chose that domain name. I see now that he has settled with MS which is a shame because I think he should be made an example of. MS are only doing this to save their public face. As for the argument that he's only 17, what the hell does that matter? His motivation was clearly to cash in on either the similarity or the publicity from the action MS would take. The lucky fscker got the latter. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HTTP Error 500 - IsapiModule
2008/12/19 Gary Maddock-Greene : > Thanks Stuart, > > Logs are no enabled and I generate this line: > > #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port > cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status > time-taken > > Sorry this is only my 2nd day with php/MySQL and I really need to get this > working so I appreciate the help. That's the IIS log not the PHP log. See here for details: http://uk.php.net/errorfunc.configuration Look for log_errors and error_log. They work together to give you a PHP error log file. Did you try using php -l on the file? -Stuart -- http://stut.net/ > "Stut" wrote in message > news:a5f019de0812190459w486205a4n5fe8fea317890...@mail.gmail.com... >> >> Please include the list when replying. >> >> 2008/12/19 G. Maddock-Greene : >>> >>> You may be right Stuart ... I am thinking this too. I can access my >>> database >>> with an auto generated call using say Dreamweaver, but my hand code is >>> throwing the error ... though I cannot see why!! It's really frustrating >> >> Look in your php.ini and make sure log_errors is on and the filename >> it's directed at is writable by IIS. Restart IIS and PHP errors should >> then appear in that file. >> >> Alternatively use the PHP command line executable with the -l (lint) >> argument to check the syntax of a file. >> >> -Stuart >> >> -- >> http://stut.net/ >> >>> - Original Message - From: "Stut" >>> Newsgroups: php.general >>> To: >>> Cc: >>> Sent: Friday, December 19, 2008 11:58 AM >>> Subject: Re: [PHP] Re: HTTP Error 500 - IsapiModule >>> >>> >>>> 2008/12/19 David Robley : >>>>> >>>>> Gary Maddock-Greene wrote: >>>>> >>>>>> Hi, Don't know if this is the right group but I am having real >>>>>> problems >>>>>> trying to connect to my MySQL db with php. I am trying to create a >>>>>> search >>>>>> form. I can connect and display in my browser a simple call to a db >>>>>> record >>>>>> but when I try to execute my search script I get a 500 Internal Server >>>>>> error: IsapiModule / ExecuterequestHandler. I'm stumped! Any help >>>>>> please >>>>>> or pointers. Thanks Gary >>>>> >>>>> The first thing when you get a 500 error, which is a server error not >>>>> php, >>>>> is to check the server error log. >>>> >>>> I might be wrong but I think syntax errors can cause a 500 status when >>>> using ISAPI. >>>> >>>> -Stuart >>>> >>>> -- >>>> http://stut.net/ >>> >>> > > > -- > 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] Re: HTTP Error 500 - IsapiModule
2008/12/19 Gary Maddock-Greene : > Ok error log reads: > > [19-Dec-2008 13:31:08] PHP Parse error: parse error in > C:\inetpub\wwwroot\search\search.php on line 20 So that's what your problem is. Go look at line 20 - there's a syntax error on it. > Sorry didn't try your suggestion php -1 ... not sure how to!! Fair enough, just use the error log. -Stuart -- http://stut.net/ > "Stuart" wrote in message > news:a5f019de0812190516r3cdcdacana356320f39a8d...@mail.gmail.com... >> >> 2008/12/19 Gary Maddock-Greene : >>> >>> Thanks Stuart, >>> >>> Logs are no enabled and I generate this line: >>> >>> #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port >>> cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status >>> time-taken >>> >>> Sorry this is only my 2nd day with php/MySQL and I really need to get >>> this >>> working so I appreciate the help. >> >> That's the IIS log not the PHP log. See here for details: >> http://uk.php.net/errorfunc.configuration >> >> Look for log_errors and error_log. They work together to give you a >> PHP error log file. >> >> Did you try using php -l on the file? >> >> -Stuart >> >> -- >> http://stut.net/ >> >>> "Stut" wrote in message >>> news:a5f019de0812190459w486205a4n5fe8fea317890...@mail.gmail.com... >>>> >>>> Please include the list when replying. >>>> >>>> 2008/12/19 G. Maddock-Greene : >>>>> >>>>> You may be right Stuart ... I am thinking this too. I can access my >>>>> database >>>>> with an auto generated call using say Dreamweaver, but my hand code is >>>>> throwing the error ... though I cannot see why!! It's really >>>>> frustrating >>>> >>>> Look in your php.ini and make sure log_errors is on and the filename >>>> it's directed at is writable by IIS. Restart IIS and PHP errors should >>>> then appear in that file. >>>> >>>> Alternatively use the PHP command line executable with the -l (lint) >>>> argument to check the syntax of a file. >>>> >>>> -Stuart >>>> >>>> -- >>>> http://stut.net/ >>>> >>>>> - Original Message - From: "Stut" >>>>> Newsgroups: php.general >>>>> To: >>>>> Cc: >>>>> Sent: Friday, December 19, 2008 11:58 AM >>>>> Subject: Re: [PHP] Re: HTTP Error 500 - IsapiModule >>>>> >>>>> >>>>>> 2008/12/19 David Robley : >>>>>>> >>>>>>> Gary Maddock-Greene wrote: >>>>>>> >>>>>>>> Hi, Don't know if this is the right group but I am having real >>>>>>>> problems >>>>>>>> trying to connect to my MySQL db with php. I am trying to create a >>>>>>>> search >>>>>>>> form. I can connect and display in my browser a simple call to a db >>>>>>>> record >>>>>>>> but when I try to execute my search script I get a 500 Internal >>>>>>>> Server >>>>>>>> error: IsapiModule / ExecuterequestHandler. I'm stumped! Any help >>>>>>>> please >>>>>>>> or pointers. Thanks Gary >>>>>>> >>>>>>> The first thing when you get a 500 error, which is a server error not >>>>>>> php, >>>>>>> is to check the server error log. >>>>>> >>>>>> I might be wrong but I think syntax errors can cause a 500 status when >>>>>> using ISAPI. >>>>>> >>>>>> -Stuart >>>>>> >>>>>> -- >>>>>> http://stut.net/ >>>>> >>>>> >>> >>> >>> -- >>> 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HTTP Error 500 - IsapiModule
2008/12/19 Gary Maddock-Greene : > $sql_query = mysql_query("SELECT * FROM products WHERE > MATCH(product_name,product_image) AGAINST('$search_term')"); > > // This is line 20 where I am getting the parse error > > many mathces (too many matches cause returning of 0 results) That line is not valid code. I'm guessing it's part of a comment that has mistakenly been broken across 2 lines. -Stuart -- http://stut.net/ > "Stuart" wrote in message > news:a5f019de0812190516r3cdcdacana356320f39a8d...@mail.gmail.com... >> >> 2008/12/19 Gary Maddock-Greene : >>> >>> Thanks Stuart, >>> >>> Logs are no enabled and I generate this line: >>> >>> #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port >>> cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status >>> time-taken >>> >>> Sorry this is only my 2nd day with php/MySQL and I really need to get >>> this >>> working so I appreciate the help. >> >> That's the IIS log not the PHP log. See here for details: >> http://uk.php.net/errorfunc.configuration >> >> Look for log_errors and error_log. They work together to give you a >> PHP error log file. >> >> Did you try using php -l on the file? >> >> -Stuart >> >> -- >> http://stut.net/ >> >>> "Stut" wrote in message >>> news:a5f019de0812190459w486205a4n5fe8fea317890...@mail.gmail.com... >>>> >>>> Please include the list when replying. >>>> >>>> 2008/12/19 G. Maddock-Greene : >>>>> >>>>> You may be right Stuart ... I am thinking this too. I can access my >>>>> database >>>>> with an auto generated call using say Dreamweaver, but my hand code is >>>>> throwing the error ... though I cannot see why!! It's really >>>>> frustrating >>>> >>>> Look in your php.ini and make sure log_errors is on and the filename >>>> it's directed at is writable by IIS. Restart IIS and PHP errors should >>>> then appear in that file. >>>> >>>> Alternatively use the PHP command line executable with the -l (lint) >>>> argument to check the syntax of a file. >>>> >>>> -Stuart >>>> >>>> -- >>>> http://stut.net/ >>>> >>>>> - Original Message - From: "Stut" >>>>> Newsgroups: php.general >>>>> To: >>>>> Cc: >>>>> Sent: Friday, December 19, 2008 11:58 AM >>>>> Subject: Re: [PHP] Re: HTTP Error 500 - IsapiModule >>>>> >>>>> >>>>>> 2008/12/19 David Robley : >>>>>>> >>>>>>> Gary Maddock-Greene wrote: >>>>>>> >>>>>>>> Hi, Don't know if this is the right group but I am having real >>>>>>>> problems >>>>>>>> trying to connect to my MySQL db with php. I am trying to create a >>>>>>>> search >>>>>>>> form. I can connect and display in my browser a simple call to a db >>>>>>>> record >>>>>>>> but when I try to execute my search script I get a 500 Internal >>>>>>>> Server >>>>>>>> error: IsapiModule / ExecuterequestHandler. I'm stumped! Any help >>>>>>>> please >>>>>>>> or pointers. Thanks Gary >>>>>>> >>>>>>> The first thing when you get a 500 error, which is a server error not >>>>>>> php, >>>>>>> is to check the server error log. >>>>>> >>>>>> I might be wrong but I think syntax errors can cause a 500 status when >>>>>> using ISAPI. >>>>>> >>>>>> -Stuart >>>>>> >>>>>> -- >>>>>> http://stut.net/ >>>>> >>>>> >>> >>> >>> -- >>> 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Since I speak with some of you more than people I see in person....
2008/12/30 Daniel Brown : >This has been a roller-coaster year for some of us --- certainly > myself included --- but the year has come to a close. I want to take > a moment to wish each and every one of you a safe and wonderful new > year. May 2009 be ten times healthier, happier, and more prosperous > to you and yours than the three best years of your life so far, and > may each year beyond that be better even than the one before. Did you forget to remove the fortune in your cookie before you ate it? >And as a side note (some of you already know): for my wife and I > closing out the year, we heard the heartbeat of our first child for > the first time today in the ultrasound. Nothing else will ever again > matter as much to me as what I am about to embark upon. I don't think > any song or sound I've ever heard in my entire life was as beautiful > as those few seconds. My heart literally feels so full that it could > burst at any moment. Dammit, I promised myself I wouldn't cry this year!! Seriously mate, that rocks. Good luck with it all, and keep us posted. My sister's having one in Feb but I think they're more scared than anything else at the moment. >To all of you, thank you for being a part of the PHP project, and > many of you professional and personal parts of my life. Of all of the > communities I've been involved in the last sixteen years or so, this > has always been my favorite. And it's because of you folks. Aww, shucks! >From the bottom of my (bursting!) heart, thank you, and I look > forward to working alongside all of you in 2009. Likewise. Personally I have a lot of change planned for 2009 so I already know it's gonna be turbulent and difficult, but nothing worthwhile comes easy and I know it's gonna be worth it! Anyone got an interesting resolution beyond the usual drinking/smoking/eating less? I intend to spend less non-work hours sat in front of a computer and blog/twitter more. Those two are probably mutually exclusive but I'm giving it a shot ;-) Happy new year all. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
2009/1/5 Frank Stanovcak : > It's been a while since I've programed (VB was on version 4) I was wondering > if any one could tell me what the diff is between char, varchar, and text in > mysql. > I know this isn't a mysql news group, but since I am using php for the > interaction it seemed like the place to ask. Thanks in advance, and have a > great day! char: the space required for the length of the field is allocated for each row no matter how much of it is used. varchar: only the space required for the content of the field is allocated per row but these fields are limited to 255 chars (IIRC) in length. text: for all intents and purposes these have unlimited length (4GBish IIRC). There is a page in the MySQL manual that explains all of the data formats. Google for mysql data formats and you'll likely get it. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Request A Collection of YouTube Videos From Multiple User Accounts using YouTube API
2009/1/7 L. Herbert : > Does anyone know if it is possible to get a collection of YouTube videos > from multiple user accounts? If so, can you provide some insight and > direction? > > Someone more knowledgeable than me on this topic indicated that it is only > possible get a collection of YouTube videos on a per account basis. On its > face this make sense to me but I'm just getting a second opinion. > > I realize I can loop requests via the API and format the results as needed, > but was hoping for a more streamlined option. This question has nothing to do with PHP. I suggest you try the YouTube developers site - I'm sure there's a resource there that can help you... http://youtube.com/dev -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Request A Collection of YouTube Videos From Multiple User Accounts using YouTube API
2009/1/7 L. Herbert : > Let me clarify, I am using PHP to call/receive via the YouTube API and to > format/display the return data within my PHP application. I believe that > has a little something to do with PHP. Forgive my presumption if otherwise. As I understand it you're wanting to request a collection of videos from multiple user accounts in a single API call. PHP cannot help you if the API does not support doing that, so you need to direct the question at people who maintain and use the API. PHP can do a great many things, but it cannot remotely change the functionality of a third party API. -Stuart -- http://stut.net/ > On Jan 7, 2009, at 4:40 AM, Stuart wrote: > >> 2009/1/7 L. Herbert : >>> >>> Does anyone know if it is possible to get a collection of YouTube videos >>> from multiple user accounts? If so, can you provide some insight and >>> direction? >>> >>> Someone more knowledgeable than me on this topic indicated that it is >>> only >>> possible get a collection of YouTube videos on a per account basis. On >>> its >>> face this make sense to me but I'm just getting a second opinion. >>> >>> I realize I can loop requests via the API and format the results as >>> needed, >>> but was hoping for a more streamlined option. >> >> This question has nothing to do with PHP. I suggest you try the >> YouTube developers site - I'm sure there's a resource there that can >> help you... http://youtube.com/dev >> >> -Stuart >> >> -- >> http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Remote File Variable Injection Safety?
2009/1/7 Daniel Kolbo : > suppose there is a file at http://otherhost.com/remote.php that looks like > this: > > if (!isset($safe_flag)) > { > die("hacking attempt"); > } > echo "You are in"; > ?> > > Suppose i executed the following php file at http://myhost.com/local.php > > require_once("http://otherhost.com/remote.php";); > ?> > > Is there any way to get local.php to display "You are in", by only modifying > local.php? That is, is there a way to set $safe_flag on the remote host as > one requests a file from the remote host from within local.php? > > I have genuine, academic, non-belligerent intentions when asking this > question. Doing this is evil and should be avoided if at all possible. However, assuming you really need to do it this way... The best way to validate inclusion is to check the value of $_SERVER['REMOTE_ADDR'] in the remote script and only allow known IPs. This is not foolproof but will kill off casual attempts to get the code. Alternatively if you change the test for $safe_flag to $_GET['safe_flag'] and add ?safe_flag=1 to the end of the URL in the require call that should also work, but is easily copied. You could randomise "safe_flag" and the value to make it more difficult, but checking the IP is far better IMHO. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Because you guys/gals/girls/women/insert pc term here are a smart lot
2009/1/7 Ross McKay : > Oh, and for a column with a limited range of values, enum beats 'em all! Got anything to back that up? http://www.mysqlperformanceblog.com/2008/01/24/enum-fields-vs-varchar-vs-int-joined-table-what-is-faster/ -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] redoing website after 7 years
2009/1/7 Lamp Lists : > hi guys, > I did php/mysql based website for one my client 7 years ago, in time when > register_globals was on by default. > hosting company upgraded server to php5/mysql5 and turned globals off. the > site is doesn't work any more. > I can define globals on again in .htaccess but rather not because it could be > a big risk. The first point to make is that the risk is no higher now than it has been for the previous 7 years. Register_globals is not inherently insecure, it's the way people code their scripts which makes it open to abuse. > to work again I have to spend a lot of hours to modify the code. boring job. > but, I'm more concern does client has to pay the changes/upgrade or it's > still "my obligation"? > anybody had similar experience? Personally I'd tell the client that the host has upgraded the server software which has broken the site. It needs work and they need to pay for it. If they object tell them you can work around the issue but it means potentially exposing the site to potentially fatal security risks. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Remote File Variable Injection Safety?
2009/1/7 Shawn McKenzie : > Daniel Kolbo wrote: >> Hello, >> >> suppose there is a file at http://otherhost.com/remote.php that looks >> like this: >> >> > if (!isset($safe_flag)) >> { >>die("hacking attempt"); >> } >> echo "You are in"; >> ?> >> >> Suppose i executed the following php file at http://myhost.com/local.php >> >> > require_once("http://otherhost.com/remote.php";); >> ?> >> >> Is there any way to get local.php to display "You are in", by only >> modifying local.php? That is, is there a way to set $safe_flag on the >> remote host as one requests a file from the remote host from within >> local.php? >> >> I have genuine, academic, non-belligerent intentions when asking this >> question. > > local.php > > > $safe_flag = 1; > require_once("http://otherhost.com/remote.php";); > > ?> If the remote side is returning the code rather than running it then anyone can see exactly what to do to get it to work. There is no security there. OP: Does otherhost.com run the code or return it? -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
2009/1/14 Thodoris : > >> hi php lovers, >> >> I have a debian lamp stack and I want to use php to send a form to my >> email server > > Do you mean that you need to send a mail directly from a web form? > > If that is the case check this out: > > http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_mail > > Doesn't even need php. But it does require the user to have an email client set up which is not necessarily the case. >> that is on the same network. Someone suggested to me why don't i use >> php.ini mail function. >> But it says in the php.ini file for win 32 only. > > What did you find in php.ini that works only for windowz? The SMTP host only works on Windows. >> Does anyone know how I can get php to direct my forms request across the >> network >> to the email server? > > I am not sure what you mean by that... They mean not using sendmail but instead talking SMTP with a remote mail server. I believe PHPMailer supports this - check it out... http://phpmailer.codeworxtech.com/ -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Basic Authentication
2009/1/14 tedd : > Let's say that I don't want to use the htpasswd command from the UNIX shell > to generate an encoded password -- how else can I create an encoded password > string that would work in a .htaccess file using basic authentication? AFAIK it's an MD5 hash, nothing more complicated than that. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Opinions / Votes Needed
already a way to get it, we just don't know about it. >> Why do you need a unique reference string for each variable? WTF! > > well because $a = 's'; $b = 's'; both are unique, internally php must hold a > reference of some sort to each variable and where it's stored that is > entirely unique; it would simply be a case of exposing this functionality > /or/ adding functionality based on this. > >>> c: Method overloading >>> TBH it's something I could live without, whereas a/b aren't, but it would >>> be an ideal addition to php? >> >> PHP does not need method overloading as is found in other languages as it >> has optional parameters with defaults. It is also possible to cast each >> parameter into wahetever type is necessary. It achieves the same result but >> using a different method. > > the same functionality can be achieved, however not without a lot of > additional code to test variable types using conditional blocks with lots of > is_ and instanceof comparisons; adding method overloading is by no means > needed but would majorly simplify the code of scripts which need this > functionality. You can't have both method overloading and variable argument lists - they're just not compatible. You can simulate overloading by putting the common code into a private method and having several differently named public methods that all use the private method. Alternatively you can use variable arguments to get around it. Either way I definitely prefer support for variable and undefined arguments than overloading. >> Absolute rubbish! You have obviously been used to a different language and >> have recently moved to PHP, but cannot get used to the fact that it *IS* a >> different language, therefore it has different syntax and achieves similar >> things in different ways. If your feeble brain can't handle the differences >> then I suggest you stick with your previous language and LEAVE PHP ALONE! > > actually I've been a senior php dev for 5 years and muddled along trying to > help people out on this list for a long time too - it is my primary > language, PHP always changes and the beauty of the language is that it tries > to allow people to program the way they want, hence it being both procedural > and object orientated, obviously there's a need for this otherwise Type > Hinting would never have been introduced. Type hinting is the happy medium between untyped and strongly typed variables. Also, PHP is procedural with OO capabilities due to its history and the engine developers commitment to maintaining backwards compatibility whenever possible. > PHP could easily be a one for all language and AFAIK the only major > functionality missing is static typing..? I'm not trying to knock PHP, > simply expand it's functionality and scope by having additional *optional* > functionality implemented - like namespaces, if you don't like 'em don't use > 'em. Namespaces have a distinct and discrete advantage for all PHP users... they will allow code to insure against naming clashes. All IMHO - PHP FTW!! -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Opinions / Votes Needed
2009/1/17 Nathan Rixham : > Per Jessen wrote: >> >> Nathan Rixham wrote: >> >>> Tony Marston wrote: >>>> >>>> If you really *need* to used a staticly typed language then don't use >>>> PHP, and don't try to change PHP to match your needs. >>> >>> why not? >> >> Because your desired functionality is already satisfied by other >> programming languages. PHP is an interpreted language with all the >> strengths and weaknesses that come with it. A need for static or >> compile-time typing is a need for a different language, honestly. >> >> /Per Jessen, ZĂĽrich >> > > why so strongly against having *optional* static typing? If it ain't broke don't fix it. I still fail to get why you're so strongly for them. > type hinting is already there + internal functions and classes are all > staticly typed, function params, return types the whole lot. Internal functions and classes are not statically typed - they check their inputs and raise errors if they're wrong, which IMHO is what all code should do. > IMHO if it was to classify all the languages (specifically server side > languages for web apps), PHP has 95% of the features i need, the rest come > no where near, so it's the obvious candidate to get this remaining 5% that'd > make it perfect and open it up to a whole set of new users and markets. > Unless it's technically impossible why not? That remaining 5% is the remaining 5% for you but you can't assume that for everyone else, and it's pretty arrogant for you to think you know what everyone wants. At the end of the day PHP is open source and if there are features you think will be welcomed by the whole community you can either suggest them on the internals list, develop them yourself and submit patches or pay/convince someone else to develop them and have them submit patches. Just don't be surprised when you discover that your "simple" enhancements have unexpected side effects that make them anything but simple, especially when you need to maintain BC as much as possible. Also, ignore Tony... PHP won't get better without people making suggestions, even if they turn out to be impractical or unpopular, so don't ever "LEAVE PHP ALONE"!! ;-) -Stuart -- http://stut.net/
Re: [PHP] Re: Opinions / Votes Needed
2009/1/17 Nathan Rixham : > Stuart wrote: >> >> 2009/1/17 Nathan Rixham : >>> >>> Tony Marston wrote: >>>> >>>> "Nathan Rixham" wrote in message >>>>> >>>>> a: Optional Static Typing >>>>> I'm finding an ever increasingly need to be able to staticly type >>>>> properties, parameters, return types etc (in classes) I know there is >>>>> type >>>>> hinting but it's just not enough to do what one needs. Additionally >>>>> support >>>>> for staticly typing primatives. Here's an example: >>>> >>>> If you really *need* to used a staticly typed language then don't use >>>> PHP, >>>> and don't try to change PHP to match your needs. >>> >>> why not? php fills 95% of my needs in most instances, I'm as much a valid >>> user of php as you and php *could* change to fit my needs and others, not >>> without some appreciated work mind you, but it could (and without >>> affecting >>> anybody else in this case) >> >> You may think it's a simple need but it has consequences for all users >> of PHP. You may be able to implement typed variables while still >> allowing untyped, but it will impact performance at the very least, >> probably more. > > hmm.. debatable on this one TBH, as the method signature (infact everywhere > you can use static) is already getting tokenized for public static function > etc so I'd assume that if a type token wasn't included then the internal > code to do with it would be bypassed in any implementation; thus no > performance hit at all - this is me assuming though only the internal dev's > could say one way or the other for sure. But you've added an extra piece of information to every zval floating around the system - what type it is, if any. Huge amounts of code would need to be changed to check that value and deal with it in an appropriate way. Not a huge performance hit per variable but repeated across a large CMS or framework the effect could be pretty huge. I don't even pretend to know enough about the internals of PHP to determine stuff like that, but I've been coding long enough to recognise that everything code does takes time so the less you can have it do the better. >>> it's a simple need: if I can type that my variable can only contain an >>> int, >>> then I know it's always an int without tonnes of checks to check it >>> actually >>> contains an int / is getting set with an int throughout the rest of the >>> app >>> (especially when multiple dev's are working on it). >> >> I would argue that what you have is a want based on your current >> implementation strategy, rather than a "need". I've never come across >> any situation where static types would make my code more secure. If >> your code can't control what you're putting into variables then you >> have bigger problems than the 5% of your "needs" PHP doesn't meet. > > won't make code more secure to the outside world, but it will ensure all > developers using my code use it correctly; I can currently control it using > PHP however it's v complex to do correctly throughout an application > compared to having static types. Then your functions/methods should be checking their inputs in the same way you check the inputs from users. I recall a function I wrote a while ago which allowed the first line of each function and method did something like this... check_args(func_get_args(), 'error', 'int', 'string:30', 'int:5-100', 'bool'); First argument is the array of arguments. Second it what the function should do in the case of an incorrect argument - in this case to trigger a user error. Other options here were 'warning', 'notice', 'email:u...@domain.com' and true. Most of those should be self-explanatory, and if true is passed then an error message is returned. The rest of the arguments should be one per function argument stating what's allowed. The options here were numerous and I can't remember them all, but you get the idea. This single function made validating arguments for any function or method a doddle and extremely flexible. Could your static types validate the length of a string or ensure an integer it within a range? >> Any data coming from the user would need the same amount of validation >> regardless of whether you were stuffing it into untyped or typed >> variables. IMHO the same goes for any uncontrolled inputs to isolated >>
Re: [PHP] Re: Opinions / Votes Needed
ly extend, with (if >>>>>>> nothing else) a unique id / hashcode for each object (much like the >>>>>>> Java >>>>>>> Object class). Failing this some form of function to get a unique >>>>>>> reference >>>>>>> string for any variable. Example >>>>>> >>>>>> Why should each class automaticaly extend a base class? For what >>>>>> purpose? >>>>>> For what benefit? I can achieve what I want without this *feature*, so >>>>>> I >>>>>> don't need it. >>>>> >>>>> 2 reasons: >>>>> 1: it would allow all objects to have this uniqueid/hashcode i need >>>> >>>> Really don't see why this is necessary. Please elaborate on why you want >>>> this? >>> >>> said to jochem before, same reasons spl_object_hash was created etc etc / >>> orms, persitance etc >> >> IMHO an ORM should be wrapping scalar values in objects but that's >> probably just me. > > exactly! I agree completely, this is half the point, static types would > allow one to make Classes for each of the scalar/primative types and have > them automatically converted to there db specific value by the orm; Don't need types to do that, you have the is_string, is_integer, etc functions so you can already handle that. > extra: would open up the door for having an magic method __cast on all > objects so you could cast (String)'a string' - where String is the object > wrapper for scalar string :) I think you're basically asking for PHP to change so all basic types are objects. I've often thought this would be a good idea but it potentially raises some BC issues and would likely be a substantial and unnecessary performance hit, especially for purely procedural code. >>>>>> Absolute rubbish! You have obviously been used to a different language >>>>>> and >>>>>> have recently moved to PHP, but cannot get used to the fact that it >>>>>> *IS* >>>>>> a >>>>>> different language, therefore it has different syntax and achieves >>>>>> similar >>>>>> things in different ways. If your feeble brain can't handle the >>>>>> differences >>>>>> then I suggest you stick with your previous language and LEAVE PHP >>>>>> ALONE! >>>>> >>>>> actually I've been a senior php dev for 5 years and muddled along >>>>> trying >>>>> to >>>>> help people out on this list for a long time too - it is my primary >>>>> language, PHP always changes and the beauty of the language is that it >>>>> tries >>>>> to allow people to program the way they want, hence it being both >>>>> procedural >>>>> and object orientated, obviously there's a need for this otherwise Type >>>>> Hinting would never have been introduced. >>>> >>>> Type hinting is the happy medium between untyped and strongly typed >>>> variables. >>> >>> yup-ish, could do with that type hinting on vars, properties and return >>> types too (infact if you had it on vars and properties you could forget >>> return types theoretically, wouldn't be quite as contracted but the >>> functional need would be covered).. >> >> Something just occurred to me... what would you want the engine to do >> if a type was not correct at runtime? Throw an exception? Raise a >> fatal error? Or just a notice? Personally I prefer to be in full >> control of what occurs when something unexpected happens. > > same as it currently is for Type Hints on methods, catchable fatal error. > > and you would be in control, catch it. Ahh, but you can't catch those inline so you have to build a generic handler. Let's take the example of a form handler. I have a script that grabs the data posted to the form which calls a method on a class to act on that data. With typed arguments you're forcing the validation to occur outside the method which is where it really ought to be done. This means it will likely need to be duplicated everywhere you need to call that method. Chances are you'll end up writing a non-typed method to handle that, so why not just do the validation in the actual method that's being called all over the place?!! You can ignore the need to validate on the basis that the typed arguments will catch any problems, but then you need to craft your error handler generically and create a very poor user experience. IMHO an exception would be a better choice, at least then I can deal with it in the correct place and maintain the flow of the script. However, I remember reading a while back that having the engine throw an exception into user space is less than simple, but I can't recall the details. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Opinions / Votes Needed
it's a damn good language. >> >> c: nothing I'm suggesting would have any effect on you're php the cobol >> way approach, I can easily cope with the difference, can you comprehend >> that it wouldn't be changing any existing functionality only adding new >> *optional* functionality. > > As others have already pointed out it would simply not be feasible to change > PHP so that it can be switched between dynamic typing to static typing at > the flick of a switch. PHP is dynamicly typed, so either get used to it or > switch to a different language. I don't recall seeing anyone say it's not feasible, just that it comes with costs other PHP developers might not be happy with. Performance makes it tricky, BC could make it tricky and there's probably a whole bunch of other issues that might make it difficult, but it's certainly possible. As far as your "if I can do it why can't you" comment goes, I don't think anything has been said that would imply Nathan is not just as capable of developing complex systems as you think you are. He has expressed a wish for some additional features in PHP because he's used other languages with those features and he likes them. Does this mean he's inexperienced or incapable? No, and it's a shame you can't see past the end of your superiority complex and acknowledge that. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Opinions / Votes Needed
2009/1/18 Tony Marston : > In case you have forgotten what this thread is about, the OP gave a list of > suggested "improvements" to PHP and asked for opinions. I merely gave my > opinion that these "improvements" would be a waste of time as they would add > nothing to the language (IMHO, of course). How many in this frum have > expressed any support for any of these "improvements"? That's not the point. You attacked the suggester not the suggestions. That's all I'm trying to point out. There's a way to disagree in a reasonable manner. > "not be feasible" covers "loss of performance", "loss of BC" and "a whole > bunch of other issues". If the cost of implementing your "improvements" is > not worth the dubious benefit then why should they considered? Without adequate investigation or comment from people who actually know about this stuff it's impossible to say whether the costs are too great to make them acceptable against the benefits. OO had a massive negative effect on performance, but it still happened because the benefits greatly outweighed the costs. IMHO all ideas should be properly considered, regardless of my gut reaction to them. >> As far as your "if I can do it why can't you" comment goes, I don't >> think anything has been said that would imply Nathan is not just as >> capable of developing complex systems as you think you are. He has >> expressed a wish for some additional features in PHP because he's used >> other languages with those features and he likes them. Does this mean >> he's inexperienced or incapable? No, and it's a shame you can't see >> past the end of your superiority complex and acknowledge that. > > I never said that I am superior, just that the lack of these requested > features has not stopped me, or many other PHP programmers I would imagine, > from writing large, complex applications with PHP. I have used many > languages in my 35+ year career, and I am far more productive with PHP than > I have been with all the others. People rarely say they're superior, but that opinion often comes across in the way they interact with others. I don't care how long your career has been, there's a way to productively deal with other people. Coming back to the OO example, a lot of us got a lot done before that came along, but that didn't make it any less welcome when it arrived, and someone had to take the first step and suggest it. Attack people for making suggestions and you'll quickly lose a valuable source of ideas. I'm done with this now as you're clearly set in your ways and it's not adding value to the discussion. Nathan: I see you've taken this over to the internals list. I wish you luck with your suggestions. Keep 'em coming. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple queries in PHP
2009/1/25 Ashley Sheridan : > I've run into a bit of a problem. I put together a query using mysql > variables in the form set @m:= 0; with the select that uses it directly > after. For any wondering, the select was using it as an incremental > value which can't be hard coded, as the value will depend on the > ordering of the results of the query itself. > > The problem seems to be that while phpMyAdmin would execute this double > query perfectly well, php using mysql_query() was having problems, as > apparently it can't actually run multiple queries. > > Now the full query looks something like this: > > > mysql_query("SELECT @m:=0;"); > > $query = "SELECT * FROM( >SELECT profiles.id, ROUND(AVG(rated.score)) AS `rating`, > COUNT(rated.score) AS `total`, @m:=...@m+1 AS rank FROM `rated` LEFT JOIN > `profiles` ON (profiles.id = rated.profile_id) GROUP BY rated.profile_id > ORDER BY rating DESC, total DESC) AS ranking WHERE ranking.id=$id"; > $result = mysql_query($query); > > > which seems to be working OK so far, but does anyone know of any > potential pitfalls I might face when doing something like this? It's a security feature to prevent SQL injection. AFAIK you'll have no problems so long as all calls to mysql_query happen on the same DB connection so you might want to start using the linkid parameter. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Non-traditional software accessing my website
2009/1/26 R B : > Is there a way to be sure that a website is going to be accessed only by > traditional browsers and not from another > software that send to the server the same headers of any of the traditional > browsers? > For example, supose that i only want to give access to my site users from > firefox, ie, chrome and safari, because > i know that the users can´t download the copyright information of the > website to the temporary files with anyone > of this browsers. > > How can i be sure that someone that develop a mini-browser or a software > can´t access my site sending the same > header information of traditional browsers? > > In this case, the validation of HTTP_USER_AGENT isn´t a solution. As Rob has so eloquently said, you can't. Might I suggest you address the problem you've created, that of viewing the copyright info, rather than trying to control what people do with your publicly accessible site, which is a battle you can't win. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Kinda 0.T... php site and maintenance
2009/1/26 Ryan S : > One thing you forgot to mention, how much would it be for "maintenance" per > year? > Feel free to add anything you think you might have forgotten in your first > emails to me. Depends what you mean by "maintenance". Will you be updating the site for them often? To be honest putting a fixed cost on a years worth of maintaining a website is next to impossible. What happens if visitor numbers explode - you're stuck maintaining a busy site for the cost of a much smaller site. IIWY I'd charge per update and an hourly fee for sysadmin work. Unless you feel like gambling that you'll get more with a fixed annual fee. But remember that it is a gamble. Either way make sure there's a written agreement that details exactly what's included in any fixed fee. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Make New-Age Money Online with Google
2009/1/27 clive : > Ashley Sheridan wrote: >> >> On Sat, 2009-01-24 at 10:14 +0200, Dora Elless wrote: >> >>> >>> That's why I am sending this email only to people I know and care >>> about. >>> >> >> And they send to a mailing list. Come again? >> >> > > So Funny, they went through all the trouble of signing up, unless hey have > bots now that can sign up to mailing lists? Yes they do - it's not hard, but you don't actually need to subscribe to PHP mailing lists to post to them. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need Help resolving the "undefined variable" and "getting property of non-object" errors
2009/1/27 Terion Miller : > I am having problems resolving errors with some images causing the Undefined > variable and getting property of non-object errors, I am trying to make a > copy function so that an order can be viewed then resubmitted as a new order > with minimal changes if needed. > Here's my code: --could it be out of order as in the select should be above > the insert? I bolded where the errors are happening. Holy crap on a cracker, I'm not gonna read all that. An undefined variable notice basically means you're trying to use a variable before it's been given a value, so look for that on and around the line it complains about and either display the variables or trace them back to confirm they contain what you think they do. The other error indicates that you're trying to use object notation (->) on a scalar (number, string or array). Again, look at the line it points you to and confirm the variables it contains have the values you think they should. This is basic debugging. Spending time resolving these errors yourself is time well spent, and the more you do it the easier it becomes. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New to PHP question
2009/1/28 Stephen : > Don Collier wrote: >> >> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I have >> a question regarding the formatting of text. Actually it is a couple of >> questions. >> >> First, when I use the \n and run the script from the command line it works >> great. When I run the same code in a browser it does not put the newline in >> and the text runs together. I know that I can use to do the same >> thing, but why is it this way? >> >> The second question is closely related to the first. When formatting text >> using printf the padding works great when running from the command line but >> not at all when in a browser. >> Here is the code that I am working with: >> > Browsers **only** support HTML. > > They do not understand things like "\n" to be anything special, so they just > print as it is sent to the browser. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] calculate the time that day ends
2009/2/3 Thodoris : > I was wondering if there is way to find out what is the time that every > day ends? I am planning to add this to the first page on an interface I am > developing. Most days end at midnight, but there may be some exceptions ;-) Seriously though, not really sure what you're asking. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Throwing an exception seems to defeat output buffering
2009/2/3 Wickland, Leif : > I would expect that if I turn on output buffering, echo something, throw an > exception, and catch the exception, nothing will have been actually output.. > That doesn't seem to be the case. Throwing an exception seems to defeat > output buffering. > > In the following code, I would not expect to see the , but I do. > > > > try { >ob_start(); >echo 'You should not see this!'; >throw new Exception('This should be the first output.'); >exit( 'Contents: ' . ob_get_clean()); > } > catch (Exception $ex) { >exit('Exception:' . $ex->getMessage()); > } > > > I'm exercising that code on PHP 5.2.4 and 5.2.8. > > Does anybody know why throwing an exception seems to override ob_start(), > flushing the buffered output? It doesn't, but the end of the script performs an implicit flush. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to send POST vars through a header redirect?
2009/2/3 TS : > I'm trying to send vars via POST somehow. Is this possible? > > Currently I'm doing > > header("Location: http://domain/index.php?var=3";); > > but, want to send POST or some other method that doesn't stick with the > session. I'm not sure what you mean by "stick with the session". What exactly are you trying to achieve? -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is it possible to send POST vars through a header redirect?
2009/2/4 JĂ´natas Zechim : > Try curl 1) I really wish people would look at other replies to a post before sending their own. Duplicates are rarely useful. 2) CURL cannot perform a "header redirect" as the OP is asking for, so the more useful response is to ask what they're actually trying to achieve because they're wanting to know how to do something that's not possible so the question is flawed. Rant over. -Stuart > -----Mensagem original- > De: Stuart [mailto:stut...@gmail.com] > Enviada em: quarta-feira, 4 de fevereiro de 2009 07:52 > Para: TS > Cc: php-general@lists.php.net > Assunto: Re: [PHP] Is it possible to send POST vars through a header redirect? > > 2009/2/3 TS : >> I'm trying to send vars via POST somehow. Is this possible? >> >> Currently I'm doing >> >> header("Location: http://domain/index.php?var=3";); >> >> but, want to send POST or some other method that doesn't stick with the >> session. > > I'm not sure what you mean by "stick with the session". What exactly > are you trying to achieve? > > -Stuart > > -- > http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I do the opposite of property_exists(), maybe a create_property() in PHP5?
2009/2/3 Daevid Vincent : > On Wed, 2009-02-04 at 08:58 +1100, Chris wrote: > >> >> the question is what is __set() doing, if it's throwing an exception >> >> for undefined properties then obviously it with 'blow up'. >> > >> > >> > >> > But why should __set() even be called if I'm accessing the property >> > directly? This seems stupid. >> > >> > $this->oraclecustomerid = 1122; >> > >> > should NOT be the same as >> > >> > $this->set_oraclecustomerid(1122); >> > >> > The second one I agree should call __set(), but the first one should NOT >> > be triggering __call() or __set() >> >> Yes it should. >> >> http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members >> >> __set() is run when writing data to inaccessible members. >> >> if it's a protected/private variable, it'll call __set. >> >> If it's a variable that doesn't exist, it'll call __set. >> > > > Let me rephrase that. I see now that it is designed that way, but I > think the logic is erroneous. While I'm sure this argument/discussion > is all for naught now, I believe that a straight assignment of a value > to a variable, SHOULD NOT do any behind the scenes magic __set(). It > should just do it. Otherwise, what's the point of being able to "set" a > property/variable both ways? One gives no benefit over the other and as > illustrated decreases flexibility. It appears it will work if I change > my property to public, but I don't want them exposed like that. *sigh* > > Bottom line is there should be a create_property($name, $value = null, > $type = 'protected') function/method that I can call to do what I'm > trying to do. > > I assume unset($this->foo); works. So therefore, I can check for > existence of a property, and consequently remove a property, but I > cannot create a property. In PHP class properties must be defined before being used. The __set and __get magic methods allow you to arbitrarily create properties, and IMHO is the most flexible way to do it. If it "just worked" as you want it to you would not be able to create rules around what properties can be created or what values they can hold. I use those magic methods to implement validation in my model classes. If $this->x simply created x I would have to implement it using accessor functions which IMHO is much less intuitive. When deciding whether to call __set or __get PHP looks at whether you can access the property in the current context, so if you declare a private or protected property you should be able to set its value from within the class without involving the magic methods. Hope that makes things a bit clearer. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] why does a html mail send as text ?
2009/2/4 Bulend Kolay : > I use php-5.2.6 and apache2.2.x on opensuse11 > > I have a file called mailsend.php to send a mail of html format. > the server sends the mail form of html format. But I get it as text instead > of html. > default_mimetype is set as text/html in php.ini file. > > How can I correct this ? The default_mimetype applies to the headers returned to browsers by PHP, it does not have any effect on emails you send. To send HTML email I would suggest you use phpmailer[1] because it makes the whole process quite painless. -Stuart [1] http://phpmailer.codeworxtech.com/ -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: DB Comparisons
2009/2/5 Nathan Rixham : > Robert Cummings wrote: >> >> On Thu, 2009-02-05 at 21:03 +, Nathan Rixham wrote: >>> >>> revDAVE wrote: >>>> >>>> Hi Folks, >>>> >>>> I¹m curious if there are any previous discussions / Articles / URL¹s >>>> that >>>> compare the power and scalability of MySQL (with php) with other >>>> technologies like MS sequel server oracle - coldfusion etc >>>> >>>> I imagine that most middleware like php / asp / coldfusion is relatively >>>> good & fast - (let me know if one is better ). Mostly I¹m concerned >>>> with >>>> the speed and power of the backend database as to how it functions on an >>>> enterprise scale  such as how many hits it can handle per hour  how >>>> many >>>> users before it starts to slow down etc. >>>> >>>> >>> honestly, if you're thinking enterprise scale then database is the least >>> of you're worries, you'll be needing to move away from a scripting language >>> and go for a pre compiled programming language. >> >> Isn't Yahoo using PHP? I thought Facebook too? Doesn't seem like they >> moved away from a scripting language. >> >> Cheers, >> Rob. > > only for the display tier in certain parts AFAIK, facebook had a good > success using APC cache; however the bulk of their "applications" are > certainly not php. > > ie: > > TIER 1 |-A : many many db servers >|<--( cluster / distribution point) >v >| > |-B : distributed caches (like terracotta) > |-C : entity manager / persistence manager > |-D : domain model > TIER 2 |-E : business logic > |-F : app interface / web service interface >|<--( cluster / distribution point) >v >| > |-G : web service client > TIER 3 |-H : display interface >| <--( cluster / distribution point) >v > HTTP >| > CLIENT |-I : end user client (web browser) > > that's vastly simplified with loads left out, a short time ago yahoo rolled > out 40k new apache hadoop servers - you really think the just bolted a > connector on the front ran a few php scripts then popped on some caching? >From http://blog.facebook.com/blog.php?post=2223862130... "Our Web servers use Linux and Apache and PHP. Our database servers run MySQL. We use memcached to help keep the site snappy. Some of our behind-the-scenes software is written in Python and Perl and Java, and we use gcc and Boost for the parts that aren't." Based on everything I've read there is very very little non-scripted code behind Facebook. The performance of a web-based application rarely has anything to do with the language it's written in. System architecture, caching levels and DB indexes have a far more profound effect on the performance of an app than whether it's compiled or scripted. To the OP: Which DB server you use is far less important than making sure you're using it right and optimising it as much as possible. Sure there are differences between them, and MySQL is better in certain situations than Postgres but a badly configured and optimised Postgres instance will always outperform a well configured and optimised MySQL server. "Enterprise" doesn't mean anything. if you're going to ask for platform and software performance comparisons you need to provide a lot more detail about what you're building, what skills you have available and what kind of budget you're working to. I've built websites at every level of complexity and every level of user base and I'm yet to find the one size fits all mix of software. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Preserving History
2009/2/5 tedd : > To further the Garbage Collection thread on to another level (i.e., > preserving history) please consider this: > > Okay, let's say we have a table containing all the instances of tutors > teaching courses. A record might look like this: > > Course-to-Tutor table > course_id = 123 > tutor_id = 7 > date_active = 2/4/9 > date_inactive = null > > The above record was assembled from the following recrods: > > Tutor table: > id = 7 > name = joe > > Course table: > id = 123 > title = Introduction to Moonshine > > Okay, so let's now delete the course "Introduction to Moonshine"! > > At the first opportunity to search the Course-to-Tutor table we find that > the course 123 is now absent from our database and as such we set the > date_inactive field -- it won't be considered again. > > Okay, so what does that tell us about the history? It only provides that at > one time joe taught an undefined course. Furthermore, if joe quits, then we > only have a record that says someone with an id of 7 taught a course with an > id of 123 -- that doesn't make much sense, does it? > > Now, if we reconsider the Course-to-Tutor table and instead of putting in > the tutor_id and course_id, we put in the actual name of the tutor and title > of the class, then at least we have a history that makes sense. > > However by doing that, we violate the primary principle of a relational > database by creating redundant data. > > I guess that one can say that if we never actually delete the tutor nor the > course, but instead just make them inactive as well, then we have solved the > problem -- is that the answer? This is the way I would approach it. Once you've used an ID in a database you should never reuse it so long as there are references to it in other tables. If you need to exclude it from use you need a flag to indicate that. > In any event, what problems do you foresee if I used the actual names and > titles for the Course-to-Tutor table instead of their id's? After all, the > instance records would retain a simple history of what happened regardless > of deletions AND a search for "Introduction to Moonshine" should be > essentially as fast as a search for "123" if both fields are indexed, am I > right or wrong? If you need to change any of the names, e.g. to fix a typo, it's potentially a massive update, whereas it's a change to a single row if you use IDs. Another thing to bear in mind is the size of your indexes. IDs are small, strings are not. Having said that it depends on the DB server as some are better at handling string indexes than others. Depending on exactly what your history requirements are it may be worth exploring other options to maintaining a history. One of the sites I work on maintains an audit log such that if something gets deleted that gets recorded in a semi-structured but fairly generic way so if I need to know when record x was deleted from table y and what record x contained I can craft a SQL query to get that from the audit log table, albeit fairly slowly. I also records inserts and updates to create a complete record. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] long echo statement performance question
2009/2/6 Frank Stanovcak : > > "Richard Heyes" wrote in message > news:af8726440902060918v6d2f1ee1ia3f839189874...@mail.gmail.com... >>> Wouldn't have thought so. But for readability, you may find this a >>> little easier instead: >> >> Slight correction: >> >> ?> >> blah >> > >> -- >> Richard Heyes >> >> HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari: >> http://www.rgraph.org (Updated January 31st) > > Actually that's what I'm in the middle of undoing. The first revision was > jumping in and out of PHP mode upwards of 60 times per page on the shorter > pages. I've read a couple places that that can put a huge performace hit on > things, so I was just trying to simplify the code a bit. Plus I don't have > the fast tags, http://stut.net/projects/phpspeed/?iterations=1 As you can see, the difference is so minimal that unless you're doing it hundreds of thousands of times per script it makes little difference how you do it. In short it's usually not worth optimising at this level since greater gains are certainly to be had by looking at your interaction with databases or other external resources. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variables
2009/2/7 Paul M Foster : > I'm not too clear on HTTP headers, cookies, and such. So here are > questions related to that. Let's say I generate a random number that I > want the user to enter in a form. When I generate the number, I store it > in a session variable ($_SESSION). When the user submits the form, I > check the number they enter with what I've stored in the session > variable. > > Since this session variable survives across page loads (assuming > session_start() is appropriately called), how is it stored and recalled? > > Is it automatically stored as a cookie on the user's system? > > Or is it stored on the server? > > And how does a server "get" a cookie? > > Is it a separate request made by the server to the client? > > If the value I've asked the user for is *not* stored as a cookie, then > is it passed as part of the HTTP submission or what? > > Thanks for any enlightenment on this. Session data is stored on the server and tied to a browser using a cookie. The cookie contains a random string which uniquely identifies a session on the server. The session_start() function handles all the details of setting and maintaining that cookie and managing the server-side data. Cookies are transferred between client and server with every request in the headers. If you don't have Firefox getfirefox.com. The google for the livehttpheaders addon and install that. Turn it on and browse your site. You will see the cookies in the headers of both requests and responses. Cookies are not stored on the server side, they are sent by the client with each request. No additional HTTP requests are involved when using sessions. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Records & Capture The New Record ID
2009/2/7 revDAVE : > Adding records & capture the new record ID: > > In the past, if I added a new record from a form in a phonebook file as an > example, I would use a web form to fill out the info, and then add and > invisible text item that stored a random number in one of the unused > database fields. > > Then, after I inserted the record - I would do a quick query that would > retrieve the record ID by searching for the random number Ouch that's nasty!! > Q: is there a better way to retrieve the record ID from the newly added > record? Use an auto_increment field then, assuming MySQL you can use mysql_insert_id to get the ID of the last record inserted on a given connection. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding Records & Capture The New Record ID
2009/2/7 revDAVE : > On 2/7/2009 11:41 AM, "Stuart" wrote: > >>> Then, after I inserted the record - I would do a quick query that would >>> retrieve the record ID by searching for the random number >> >> Ouch that's nasty!! >> >>> Q: is there a better way to retrieve the record ID from the newly added >>> record? >> >> Use an auto_increment field then, assuming MySQL you can use >> mysql_insert_id to get the ID of the last record inserted on a given >> connection. >> >> -Stuart > > Thanks Stuart - it works great - so much Less Nasty! > > BTW: as long as - mysql_insert_id is right after the insert statement - is > it 100% accurate - (in that no other insert from another user could get in > the middle of this)? Yes. As I stated, it returns the ID of the last record inserted on a given connection. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/8 tedd : > At 2:35 PM + 2/8/09, Richard Heyes wrote: >> >> Hi, >> >> Can anyone point out some general statistics on PHP usage compared to >> other server languages? I've tried Netcraft, but they only appear (or >> I've only found) to have statistics on the httpd server used. >> >> Thanks. >> >> -- >> Richard Heyes > > Richard: > > I went looking for that same information a few weeks ago myself. > > I wasn't able to find a lot of information, but here's a useful link: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > I wrote them and asked for "where's ASP" in that listing. You see, I wanted > to compare the number of ASP users to the number of PHP users -- I was > thinking that ASP is the closest language to be PHP's competition (I may be > wrong). They wrote back: > > "Thanks for your feedback on our TIOBE index. ASP is not a programming > language as such, that's why it is not part of the index. Please read the > FAQ at the end of the page (or search for ASP on the page) for more details. > If you want to compare PHP to ASP, here are my 2 cents. You could combine > Visual Basic and C# to get a guestimate. Then ASP is 14.8% versus PHP 8.9%." > > The only thing that brothers me about the 8.9 percent is how can that be if > there are millions of web sites that use php and that number is growing? > Additionally, this month they report a lower percentage for php than they > did last month -- it appears that something is wrong. Tedd, that's a list of programming languages, not web development languages. I have no doubt that C# + VB accounts for more development in the world than PHP. Both are used extensively in non-web development whereas PHP is not. > If you find any information of the numbers of php users out there, please > let me know. When you consider how such a thing would be measured it won't take long to realise why the number is not available. You have to bear in mind non-public use which will not be insignificant, servers where PHP is not advertised and a multitude of other reasons why any number you could come up with *will* be wrong, and therefore pretty useless. Why anyone would see value in such a number is beyond me. IMHO the community that exists around it and the number of jobs out there requiring PHP should be enough to convince anyone that it's not an insignificant player. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Appending query result sets?
2009/2/8 Skip Evans : > Is it possible to append a result query from one call to mysql_query() to > the end of another if the specified fields are identical? > > Something like that would accomplish ths? > $r1 = mysql_query('some sql'); > $r2 = mysql_query('some sql'); > > $r3 = $r1.$r2; > > I suppose they could be read into an array then output that way, but I was > hoping to more easily just append the result sets. Best place to do this is in the SQL query with a UNION. http://dev.mysql.com/doc/refman/5.0/en/union.html -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/8 tedd : > At 3:54 PM + 2/8/09, Stuart wrote: >> >> 2009/2/8 tedd : >> >> > I wasn't able to find a lot of information, but here's a useful link: >>> >> > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html >> >> Tedd, that's a list of programming languages, not web development >> languages. > > The list shows php, javascript, ruby, and perl -- are those NOT web > development languages?!? I didn't say it doesn't include web development languages, just that it's not limited to them. >> I have no doubt that C# + VB accounts for more development >> in the world than PHP. Both are used extensively in non-web >> development whereas PHP is not. >> >> > If you find any information of the numbers of php users out there, >> please >> > let me know. >> >> When you consider how such a thing would be measured it won't take >> long to realise why the number is not available. You have to bear in >> mind non-public use which will not be insignificant, servers where PHP >> is not advertised and a multitude of other reasons why any number you >> could come up with *will* be wrong, and therefore pretty useless. >> >> Why anyone would see value in such a number is beyond me. IMHO the >> community that exists around it and the number of jobs out there >> requiring PHP should be enough to convince anyone that it's not an >> insignificant player. > > -Stuart > > I guess I'm not all that bright. To me a programming language is a > programming language regardless of platform or purpose -- that was so when I > was programming FORTRAN on Phoenix I, or Applesoft on Apple ]['s, or > postscript on HI's; or ANSI C on Alphas, or FutureBasic and C/C++ on Macs, > or PHP on Apache, or Javascript on IE -- they are all the same to me. I'm > just trying to get a handle on the number of people who program in php -- > what's wrong with wanting to know that figure? There's nothing wrong with wanting to know it, there's just no reliable way to measure it so why bother asking for it? > Look, I teach at the local college and am trying to get PHP/MySQL courses to > be taught there. I have superiors who are asking "How does PHP stack up > against ASP?" which the college teaches AS THE web development language. I > really can't go back to them and say "Well, everyone just *knows* PHP is a > significant player" -- that's not proof. Ask them for proof that ASP is worth teaching over PHP? I bet they have just as much trouble coming up with solid proof that ASP as a platform is any more popular than PHP, or more valuable as a teaching language. When I was at university we were taught Java rather than C++ because, and I quote one of the professors, "we don't need to teach you proper memory management". I count myself lucky that I'd learnt C++ 12 years before I got there. I suggest you point them at the big players in the web world who use PHP... Facebook, Yahoo, etc. If that doesn't convince them of its importance in the world of web development nothing will. > Sometimes I have to wonder why anyone would question an honest question? I'm not questioning the question, I'm questioning the accuracy of any answer you could possibly come up. Describe a practical method of measuring language use that's likely to yield an accurate result then I'll eat my words, but I'm yet to come up with one. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/8 tedd : > At 8:44 PM + 2/8/09, Stuart wrote: >> >> 2009/2/8 tedd : >> >> > just trying to get a handle on the number of people who program in php >> -- >>> >>> what's wrong with wanting to know that figure? >> >> There's nothing wrong with wanting to know it, there's just no >> reliable way to measure it so why bother asking for it? > > Huh!? > > I must be getting dumber by the minute. > > If you don't know there's no reliable way to measure something, then what's > wrong with asking about it? At least now I can say "There's no reliable way > to determine that figure, so I don't know the answer." > > Sometimes trying to get a question answered on this list is a bit like > running through a gauntlet of "Why are you asking that? You should know > better!" > > Now maybe you didn't mean it that way, but IMO that appears more demeaning > of the poster than providing help. I'm surprised, because that's not typical > of you nor this list. Indeed. Not really sure what I was thinking when I wrote it and I apologise for the attitude. Asking questions should never be discouraged, but the point still stands that it's important to understand the margin of error in the answer. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php validate user password
2009/2/9 Michael Kubler : > These days SHA should really be used instead of MD5, and you should be > SALTing the password as well. > Here's a great guide : http://phpsec.org/articles/2005/password-hashing.html Good advice. I would also advise against stripping and trimming anything from passwords. By removing characters you're significantly reducing the number of possible passwords. -Stuart > Jan G.B. wrote: >> >> 2009/2/9 Andrew Williams : >> >>> >>> Can some body help out on how to validate user password from the >>> database? >>> >> >> There are several possibilities. This would be one. >> > $query = 'SELECT 1 from `usertable` where `name` = ' . >> mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE) >> . ' AND `pass` = md5("' . >> mysql_real_escape_string(STRIPPED_AND_TRIMMED_REQUEST_VAR_HERE) . >> '");'; >> ?> -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php validate user password
2009/2/9 Jan G.B. : > 2009/2/9 Stuart : >> I would also advise against stripping and trimming >> anything from passwords. By removing characters you're significantly >> reducing the number of possible passwords. > > Surely, the stripping should only be done when when magic_quotes is > enabled! (e.g. Your Server makes \' out of '). If you have this option switched on on your server you really need to do everything you can to get rid of it. It's evil and has been completely removed from PHP 6. But yes, if you're stuck with it then you need to strip them before storage, but the poster did not make that clear. > Trimming could be left out but it minimizes user errors and users > pretending to know their password. > (Like copy/paste from a passwords-file with added spaces on the end, etc..) Not sure what you mean by users pretending to know their password, but if I put a space at the start or end of my password I would expect that to add to its complexity and make it harder to guess. By stripping it you're not doing anyone any favours. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/9 tedd : >> > Now maybe you didn't mean it that way, but IMO that appears more >> demeaning >>> >>> of the poster than providing help. I'm surprised, because that's not >>> typical >>> of you nor this list. >> >> Indeed. Not really sure what I was thinking when I wrote it and I >> apologise for the attitude. > > We all have off days, no problem -- thanks for the apology. > > On my side of the world, it's amazing how ignorant people are. > > I have administrators at the college, where I teach, who think that php is > nothing more than a fad and not anything serious. In fact, I talked to their > web guy, who is a avid php/mysql developer, and he says that the > administration is asking to have php and mysql removed completely from their > server. They only want asp and oracle. In the last 6 years they have spent > over $22 million on trying get oracle to work and it still hasn't. > > That's the reason why I've been looking for php stats. I think people are like that everywhere, particularly above a certain level of management in my experience. I wish you luck in convincing them but I've found that PHP rarely wins when put up against the sales and marketing budgets available to Microsoft and Oracle. It's going to take a while for the majority of people to stop equating free with worthless or risky when the truth is that products from closed corporations carry more risk than open source software. You should tell them your QuickBasic story - that might start some mental cogs turning in their heads. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/9 Andrew Ballard : > On Mon, Feb 9, 2009 at 11:10 AM, tedd wrote: >> At 10:02 AM -0500 2/9/09, Andrew Ballard wrote: >>> >>> On Sun, Feb 8, 2009 at 3:37 PM, Paul M Foster >>> wrote: >>> >>> > Perhaps a better question then might be how many IIS servers are there >>>> >>>> out there compared to Apache. Apache servers uniformly support PHP, but >>>> I think only IIS servers support ASP (I could be wrong). >>> >>> We're running PHP under IIS where I currently work. For that matter, >>> I'm pretty sure the headers spit out that both ASP.NET and PHP are >>> supported on these machines, even though we're not currently using >>> ASP.NET. >> >> So using IIS v Apache is not a good measure for trying to determine php and >> asp numbers, right? >> >> Cheers, >> >> tedd > > Probably not. For that matter, ColdFusion under both IIS and Apache on > either Windows or Linux (though the only couple installations I've > seen have been on Windows/IIS). You could get a reasonable ballpark > from something like netcraft, but I think Stuart is right on the money > when it comes to the problems you'll have with margin of error. For > that matter, I wonder how useful some of the newer smashups I've seen > like builtwith.com really can be, if sites are configured to hide the > headers that identify the server software and/or supported languages. builtwith.com actually state on their site that "many sites report PHP usage even if it is not being used" so they know their methods are not at all accurate. In fact for two of the sites I maintain it's way off because they don't expose the use of PHP or Apache. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP OOP
2009/2/9 tedd : > Hi gang: > > At the college where I teach, they are considering teaching OOP, but they > don't want to settle on a specific language. > > My thoughts are it's difficult to teach OOP without a language -- while the > general concepts of OOP are interesting, people need to see how concepts are > applied to understand how they work -- thus I think a specific language is > required > > I lean toward C++ because I wrote in it for a few years AND C++ appears to > be the most common, widespread, and popular OOP language. > > However, while I don't know PHP OOP, I am open to considering it because of > the proliferation of web based applications. My personal opinion is that's > where all programming is headed anyway, but that's just my opinion. > > With that said, what's the differences and advantages/disadvantages between > C++ and PHP OOP? C++ is a good option, but if OOP is the focus it might be better to use Java or similar where you don't need to worry so much about memory management. If you're dealing with people who know C then C++ will work well, otherwise not. The worst thing you can do is skip over the details of C++ development because you want to focus on OOP. You'll end up with a bunch of people who *think* they can code in C++ but really haven't got a clue. Personally I'd have preferred my university to use Smalltalk, but none of the professors knew it so I had to teach myself. It's the original and IMHO still the best implementation of OOP concepts around. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/9 Daniel Brown : > On Mon, Feb 9, 2009 at 14:58, Shawn McKenzie wrote: >>> >> And HTM shows 701M, so it is now beating out ASP :-) > >Another bone of contention is the masking --- I mentioned it > briefly in my original remarks in this thread, but on further > investigation, it may actually have a substantial impact on numbers. > More sites are using mod_rewrite and similar tactics to use > extensionless URL's and SEFU's (Search Engine-Friendly URL's) than > ASP, as it seems from a random sampling of 100 websites that I put > into an array and checked with a simple, dumb script. > >Eventually, perhaps sooner than later (though I hate that phrase), > curiosity is going to lead me to build a spider and database to > collect some real samples and do some metrics. Probably later this > week, in fact I would advise you against wasting your time because there is no reliable way to tell what systems a server is actually using to serve pages. Nearly all sites I work on these days use techniques to remove extensions from URLs, and a fair few hide all details of the server software for a variety of reasons. Since you can't say with any certainty what your margin of error is, the numbers will be meaningless as a measure of language usage. Having said that it's been a while since I wrote a spider, shame I don't have time to have a go at the moment. Have fun ;-) -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP usage stats
2009/2/9 Daniel Brown : > On Mon, Feb 9, 2009 at 15:21, Stuart wrote: >> >> I would advise you against wasting your time because there is no >> reliable way to tell what systems a server is actually using to serve >> pages. Nearly all sites I work on these days use techniques to remove >> extensions from URLs, and a fair few hide all details of the server >> software for a variety of reasons. Since you can't say with any >> certainty what your margin of error is, the numbers will be >> meaningless as a measure of language usage. > >Right, but adjusting the math as appropriate should be fine. If a > site doesn't report either PHP or ASP, for example, don't include it > in the count. If we have 100 sites that we spider and 23 report > having PHP capabilities, 16 report being able to support ASP, fifty > (half) having no response, we know that 46% of the total can serve PHP > code while 32% can serve ASP, because we will only record the total > based upon responses. I'm sure there are flaws in this logic > which is why I'm thinking aloud here. ;-P You used the right word there... "can" as in not necessarily is! Your results would indicate capability rather than actual usage and even then you have no way to determine your margin of error. Having said all that I would guess that any numbers that look half-way decent would probably convince the people Tedd is looking to sway. But they still won't be anyway near accurate. >> Having said that it's been a while since I wrote a spider, shame I >> don't have time to have a go at the moment. Have fun ;-) > >It's just going to be proof-of-concept code certainly nothing > worth pushing Nielsen out the door. Indeed, but I find coding without QA requirements is a great way to relax. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generate unique login token
2009/2/10 sean greenslade : > I have a login system that I am coding. I need it to generate a unique token > on login to be stored in the browser's cookie. I currently use a script that > generates a MD5 hash of the current unix timestamp, then checks the mysql > database to see if the token already exists. It loops this generate/check > until it gets a unique token. Is there a better way to do this? I want a > token that cannot be easiy predicted (i.e. not an auto-increment value). > Thanks in advance! I've never had a clash with this on a site with 20m PVPM... $token = sha1($_SERVER['REMOTE_ADDR'].microtime(true)); -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Looking for some PHP OO programming guides
2009/2/10 Michael Kubler : > Hi, > I'm just getting into programming in an Object Oriented fashion, and am > looking for some guides, tutorials, hints, tips, etc... > > I only just found out that you remove the $ from variables when calling them > from $this-> > > e.g : > class People > { > private $person = "not set"; > function __construct() > { >*$person* = "A person"; //This doesn't work (well it creates a variable > $person that only has the scope of the current function from what I can > gather).. >$this->*person* = "A person"; //This works properly >} > function display_list() > { > echo $person; //This doesn't work > echo $this->person; //This works. > } > } > > $person= new People; > $person->display_list(); > ?> > > > Instead of painstakingly working out most of the other mistakes I'm likely > to make, I'd love to read about other peoples issues they had with learning > OO so I can skip most of the hard stuff, and only make small mistakes > (hopefully). Ok, because it's you I'm going to offer you this ebook at the very very very low limited time price of $49 and I'll throw in a free watermelon. Ahh, hell, I can't be arsed. It's in the frickin' manual: http://php.net/oop -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on caching an object.
2009/2/11 Yeti : > Hello gang, > > First of all, yes I searched the mailing list's archive. > > My problem is very simple: > I have an object that's definately called with every page request. > It's pretty much the same for every unregistered/anonymous user. > And it's not small. Alot of attributes are being set from DB queries etc. > > Now my idea was to do some sort of caching with PHP to speed things up. > So I was wondering if anybody had experiences on this ... > > Of course, I considered using serialize(), but it seemed to me as if > it could cause even more lagging since PHP requires the class to > unserialize the object correctly. Then I would end up reading the > class file, reading the searialized object and unserializing it. A 100 > simple DB queries might be done in the same time or at least not much > slower. > > Could it be that I'm looking at the wrong place? Should it be more > like caching the queries or something similar? > > Thank you very much for everyone's effort in advance. I suggest you look at memcached - it's an in-memory volatile cache that performs extremely well. APC has a similar feature but I've never used it. Also, are you guestimating the performance of DB queries against a serialised file? Do some tests and you might be surprised at how quickly PHP can unserialise data. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on caching an object.
Emailing me directly is not cheap, please don't do it again without expecting an invoice. 2009/2/11 faisal murad : > how can i unsubscribe from php list. It's really difficult. You follow the instructions shown at the end of each frickin' email!! >> To unsubscribe, visit: http://www.php.net/unsub.php Yup, that's really hard!! -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to post XML via curl?
2009/2/12 Brian Dunning : > I'm going crazy, can't quite get this encoding to work. I've tried all the > various combinations, trying to send this block $xml (which is a simple > string variable) via post along with 3 other params: > > $postArgs = http_build_query(array('method'=>'newPrintRequest', > 'login'=>$login, 'password'=>$password, 'orderxml'=>$xml)); > $ch = curl_init('http://test.server.com/rest_interface.php'); > curl_setopt($ch, CURLOPT_POST, true); > curl_setopt($ch, CURLOPT_POSTFIELDS, $postArgs); > curl_setopt($ch, CURLOPT_HEADER, 0); > curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); Drop the above line and I reckon it should work. The content you're sending is not XML, it's form fields which CURL will default to. It just happens that one of those fields is XML. > $response = curl_exec($ch); > > Is this use of http_build_query the best way to send XML? Any other curl > options I should be setting? I tried urlencoding() the $xml, I tried > htmlspecialchars(), I tried nothing at all, I tried & and & is there > a "best practice" for how a big block of xml should be posted? -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to post XML via curl?
2009/2/12 Brian Dunning : > This line is the key. WITH the line, I get a properly formatted XML response > from the server, telling me that I did not send any valid post fields. > WITHOUT the line, all I get back from the server is a '1' and their tech > reports that no valid call was received from me. In that case you're not sending them what they're asking for. Are the method, login and password fields supposed to be separate or should they be included in the xml? At the moment they're separate so when you tell the server it's in XML format you're lying because only part of it is. As a test try setting $postArgs = $xml. If I'm right it might either work or give you and authentication error. -Stuart > On Feb 11, 2009, at 4:56 PM, Stuart wrote: > >>> curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); >> >> Drop the above line and I reckon it should work. The content you're >> sending is not XML, it's form fields which CURL will default to. It >> just happens that one of those fields is XML. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to post XML via curl?
2009/2/12 Brian Dunning : > From the documentation: > > Parameters > The following POST parameters are required: > login - Assigned > password - Assigned > method - newPrintRequest, updatePrintRequest, reprintRequest > orderxml - XML according to accompanying documentation > > The error that I get says no method was provided, and if you look at my > code, it clearly is. The original code you had, minus the Content-Type header will do exactly that. Either the documentation is wrong or there's something wrong with their system. I suggest you create an HTML file containing a form with those fields that posts to the destination URL, fill it in with valid values and see what happens when you post that. Remove CURL from the equation, and if that doesn't work go back to them and show them that form and the response you get, because according to that documentation it should work. -Stuart > On Feb 11, 2009, at 5:08 PM, Stuart wrote: > >> 2009/2/12 Brian Dunning : >>> >>> This line is the key. WITH the line, I get a properly formatted XML >>> response >>> from the server, telling me that I did not send any valid post fields. >>> WITHOUT the line, all I get back from the server is a '1' and their tech >>> reports that no valid call was received from me. >> >> In that case you're not sending them what they're asking for. Are the >> method, login and password fields supposed to be separate or should >> they be included in the xml? At the moment they're separate so when >> you tell the server it's in XML format you're lying because only part >> of it is. >> >> As a test try setting $postArgs = $xml. If I'm right it might either >> work or give you and authentication error. >> >> -Stuart >> >>> On Feb 11, 2009, at 4:56 PM, Stuart wrote: >>> >>>>> curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); >>>> >>>> Drop the above line and I reckon it should work. The content you're >>>> sending is not XML, it's form fields which CURL will default to. It >>>> just happens that one of those fields is XML. >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >> >> -- >> http://stut.net/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
2009/2/16 Paul M Foster : > I'm submitting a url like this: > > http://mysite.com/index.php/alfa/bravo/charlie/delta > > The index.php calls has code to decode the url segments > (alfa/bravo/charlie/delta). It determines that the controller is alfa, > the method is bravo, and converts charlie and delta to $_GET['charlie'] > = 'delta'. It verifies that the controller and method exist, and calls > the controller and method. > > This works fine. The right controller gets called and the right method, > and the GET parameter looks like it should. The method sets some > variables and then calls a render() function to render the page, which > is in the doc root of the site. > > The page does get rendered, but without the stylesheet, and none of the > graphics show up. Why? Because, according to the logs, Apache appears to > be looking for the images and everything else in the directory > index.php/alfa/bravo/charlie/delta, which of course doesn't exist. > > No, I don't have an .htaccess file with RewriteEngine on. Apache figures > out that index.php is the file to look for in the original URL, but > can't figure out that everything else is relative to that file, not the > entire URL. > > This method is in use in at least one other MVC framework. What am I > doing wrong? You need to specify the absolute URL for all assets when using a URL scheme like this because the browser has no idea that index.php indicates the current directory so it resolves relative paths using the full URL. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache odd behavior
2009/2/16 Paul M Foster : > On Mon, Feb 16, 2009 at 07:30:57PM +0200, Thodoris wrote: > >> >>> I'm submitting a url like this: >>> >>> http://mysite.com/index.php/alfa/bravo/charlie/delta >>> >>> The index.php calls has code to decode the url segments >>> (alfa/bravo/charlie/delta). It determines that the controller is alfa, >>> the method is bravo, and converts charlie and delta to $_GET['charlie'] >>> = 'delta'. It verifies that the controller and method exist, and calls >>> the controller and method. >>> >>> This works fine. The right controller gets called and the right method, >>> and the GET parameter looks like it should. The method sets some >>> variables and then calls a render() function to render the page, which >>> is in the doc root of the site. >>> >>> The page does get rendered, but without the stylesheet, and none of the >>> graphics show up. Why? Because, according to the logs, Apache appears to >>> be looking for the images and everything else in the directory >>> index.php/alfa/bravo/charlie/delta, which of course doesn't exist. >>> >>> No, I don't have an .htaccess file with RewriteEngine on. Apache figures >>> out that index.php is the file to look for in the original URL, but >>> can't figure out that everything else is relative to that file, not the >>> entire URL. >>> >>> This method is in use in at least one other MVC framework. What am I >>> doing wrong? >>> >>> Paul >>> >>> >> >> I assume that in order for this to work you will have to use mod_rewrite >> for apache to work properly. Check the framework's installation >> instructions to see if you configured mod_rewrite correctly for this to >> work properly. > > mod_rewrite isn't involved. Apache has a "lookback" feature that "looks > back" through the URL until it finds an actual file it can execute, > which in this case is index.php. Unfortunately, it appears that Apache > believes the directory in which linked files are found is the *whole* > URL. > > mod_rewrite might resolve this, but it isn't allowed on all servers. So > it's not a reliable solution. This is your problem, you're not understanding where the paths are being resolved. Apache has absolutely no involvement in resolving relative paths in your HTML files to absolute URLs. The browser does this. All you need to do is use absolute URLs and everything will work fine. By absolute, in case you don't know, I mean starting with a / and being "from" the document root in the web server. For example, if you have a tag like arse and arse.php is in the same directory as index.php you need to change it to arse. Another example... if you have crack where crack.php is in the subdirectory somedir beneath where index.php is you need to change the tag to crack. You need to apply this to all URLs in your code, including stylesheets, images and javascript references. This should not be a difficult concept to grasp, so maybe I'm not explaining it right. If so please explain what you understand by what I'm saying and I can alter it to be more helpful. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
2009/2/16 Thodoris : > In addition to this there is an API for C that can be used to code web > applications and it is known as CGI (it is provided by many languages) CGI is a protocol not an API and has no specific connection to C. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Full versus relative URLs
2009/2/16 Paul M Foster : > On Mon, Feb 16, 2009 at 07:39:29PM +0200, Thodoris wrote: > >> >>> Here's a question related to my last post. When specifying a link in a >>> HTML file (like to the css or an image file), there are two ways of >>> doing it. One is to simply include the relative path to the file >>> (relative to the doc root), like: >>> >>> /graphics/my_portrait.gif >>> >>> Or you can include the full URL, like: >>> >>> http://example.com/graphics/my_portrait.gif >>> >>> My casual observation seems to indicate that the former will load faster >>> than the latter. But has anyone done any benchmarking on it? >>> >>> Paul >>> >>> >> >> I am not aware if absolute URLs are faster or not (in case they are >> there will be such a small difference you cannot probably notice) but >> IMHO it is a bad practice to use full URLs. >> >> Basically because renaming directories or scripts will cause great pain >> in the ass. >> >> Of course resources that are coming outside your own site are needed to >> use absolute URLs and nobody is assuming that are useless. > > Agreed. But here's the real reason, in my case. We develop the pages on > an internal server, which has the URL http://pokey/mysite.com. When we > move the pages to the live server at mysite.com, all the URLs would have > to be rewritten. Ugh. My advice would be to stop coding and sort this out as soon as possible. If your development server has a different layout to your live server you're simply asking for trouble, especially since you're using a front controller pattern (as evidenced in another thread). It's simple to fix this. Add a hosts entry for mysite.local pointing at pokey's IP. Change the server software so it has a virtual host for mysite.local pointed at the mysite.com directory in the existing web rooot. This is not difficult and will allow you to solve both of the problems you are currently asking this list about. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opinions Please, Describing PHP as Web Framework of C and C++
2009/2/16 German Geek : > I thought its an interface as in Common Gateway Interface. :-P > > You are right it isn't a specific connection to C. CGI can basically be used > with any language. > > A protocol to me is something like TCP/IP or http etc. Like a language > between a network of nodes. A protocol in computer science is defined as "rules determining the format and transmission of data". CGI is a protocol defining the format and transmission of data between two entities, most commonly an HTTP server and an executable of some sort. It has no connection to TCP/IP, HTTP or networks in general. -Stuart -- http://stut.net/ > 2009/2/17 Stuart >> >> 2009/2/16 Thodoris : >> > In addition to this there is an API for C that can be used to code web >> > applications and it is known as CGI (it is provided by many languages) >> >> CGI is a protocol not an API and has no specific connection to C. >> >> -Stuart >> >> -- >> http://stut.net/ >> >> -- >> 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] Re:
2009/2/16 Mike Roberts : > Please folks, honor my request and remove me from the list. Yes I signed up > intentionally, and yes I tried (3 times) to de-list myself but I still get > the emails. You guys seem like nice folks, so I don't want to lodge a > complaint somewhere... I just one somebody to take responsibility and delete > me from the list. What exactly have you done three times? Send an email to php-general-unsubscr...@lists.php.net then follow the instructions in the automated email you receive, usually a few minutes later. If this is what you've done already then there may be a problem with the system, but please make sure you've fully read, understood and actioned the instructions in the email you get back. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php