[PHP] Re: Help with a regular expression for 0,1 or 2 decimal places
hi, i'm not a regex guru myself, but the following regex should work - tabke a look at my regex test setup ... ?php $test = array( 1, 1., 1.2, 1.23, 1.234, 1234, 1234., 1234.5, 1234.56, 1234.567 ); // if there's a dot, we want at least one number after it. $regex = '/^\d+(.\d{1,2})?$/'; // test all or numbers ... foreach ($test as $number) { if (preg_match($regex, $number)) { echo ok ; } else { echo no ; } echo $number . br /\n; } ? i don't think there's a difference between \d and [0-9], but again, i am no expert ... regards, phillip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] cleanly written shop-system (php5, object-oriented)?
hi, i want to create a shop server application. the shop client interface will be in flash (communication with php over xml, soap or amfphp), the administration interface will be html. most likely it will probably be a long-running application that will be extended in several steps, so we need a solid foundation. we also need to get started quickly (who doesn't), otherwise i would consider starting from scratch. i have already looked around quite a lot for a nicely adaptable shop/ecommerce implementation, but haven't been very successful so far. everything i found was conceived in php4 times, where OO wasn't as wide-spread in the php community as it is today. some of the packages are poorly documented (both in-code and separate documentation), have an inconsistent coding style, are dead, are copies of oscommerce with a worse interface, ... feature-wise the best i found was xtcommerce (oscommerce fork) admin interface wise: zencart (oscommerce fork) code-wise: randshop non of them use php5's features, though, none are written object-oriented. i have no info on the performance of these shops, although that shouldn't be a prob as long as it's not desastrous (to some extend, you can always scale hardware-wise). so i am looking for a cleanly layered application where i could swap out the presentation layer. and all important shop data (products, product categories, cart, etc.) should be represented as objects, so i could extend them to implement required customizations. it would be a big plus if the admin interface was well thought-out. we need quite some features like multiple languages, multiple categories, discounts on certain products, payment provider integration, customer newsletters, possibly administration of several slightly different shops in one installation, etc. is there such an application or am i stuck with oscommerce and its forks? i don't need it to be feature complete, as long as there is a way to adapt the code without hacking the whole thing (and loosing the possibility of upgrading). as long as the code was open, i would be happy to pay a certain amount for the application. anyone? phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Php, Rails and ajax
hi, rails is written in the ruby programming language. which has nothing to do with php. ruby and php are different programming languages, that are used on the server-side of the web. normally you decide on one of them! ajax in contrast is a way of updating the web browser content without reloading the currently displayed page; to acheive that, both a client side and a server-side language are involved. the client side will be written in javascript (using the xmlhttprequest object), on the server-side you are free to use any language you want, php, ruby, java, python, perl, asp, ... if you want to use php and ajax, maybe check out phpontrax or cakephp. they are clones of ruby on rails. phil --- Jacob Friis Saxberg schrieb: Hello again. Is it possible to use Php, Rails and ajax via some open source system? How do you do it? The most important for me is to use Php and ajax. Thanks, Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Php, Rails and ajax
hi, rails is written in the ruby programming language. which has nothing to do with php. ruby and php are different programming languages that are used on the server-side of the web. normally you decide on one of them! ajax in contrast is a way of updating the web browser content without reloading the currently displayed page; to acheive that, both a client side and a server-side language are involved. the client side will be written in javascript (using the xmlhttprequest object), on the server-side you are free to use any language you want, php, ruby, java, python, perl, asp, ... if you want to use php and ajax, maybe check out phpontrax or cakephp. they are clones of ruby on rails. phil --- Jacob Friis Saxberg schrieb: Hello again. Is it possible to use Php, Rails and ajax via some open source system? How do you do it? The most important for me is to use Php and ajax. Thanks, Jacob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: cleanly written shop-system (php5, object-oriented)?
hello james, 1) i have been working with php5 for almost a year now, and the biggest project i have yet worked on (a complex intranet banking application) is running perfectly on it; no problems. on the contrary, since the zend engine has been rewritten to properly handle objects (as references not copies), a huge source of confusion/errors/odd behaviour has been removed. we have not had one stability or scaling problem with php5. (what i *would* worry about is having to develop oo-software in php4.) 2) Worst thing you can do is design a website in entirely flash - depends on the kind of site. you certainly wouldn't do a news site 100% flash, but for certain *application* is can make perfect sense. what we will do is build a product configuratorin flash, not the whole site. regards, phillip --- running perfectly clean James Benson schrieb: PHP5 has yet to see the maturity and stability PHP4 offers which is why most applications use it. Worst thing you can do is design a website in entirely flash :) Phillip Oertel wrote: hi, i want to create a shop server application. the shop client interface will be in flash (communication with php over xml, soap or amfphp), the administration interface will be html. most likely it will probably be a long-running application that will be extended in several steps, so we need a solid foundation. we also need to get started quickly (who doesn't), otherwise i would consider starting from scratch. i have already looked around quite a lot for a nicely adaptable shop/ecommerce implementation, but haven't been very successful so far. everything i found was conceived in php4 times, where OO wasn't as wide-spread in the php community as it is today. some of the packages are poorly documented (both in-code and separate documentation), have an inconsistent coding style, are dead, are copies of oscommerce with a worse interface, ... feature-wise the best i found was xtcommerce (oscommerce fork) admin interface wise: zencart (oscommerce fork) code-wise: randshop non of them use php5's features, though, none are written object-oriented. i have no info on the performance of these shops, although that shouldn't be a prob as long as it's not desastrous (to some extend, you can always scale hardware-wise). so i am looking for a cleanly layered application where i could swap out the presentation layer. and all important shop data (products, product categories, cart, etc.) should be represented as objects, so i could extend them to implement required customizations. it would be a big plus if the admin interface was well thought-out. we need quite some features like multiple languages, multiple categories, discounts on certain products, payment provider integration, customer newsletters, possibly administration of several slightly different shops in one installation, etc. is there such an application or am i stuck with oscommerce and its forks? i don't need it to be feature complete, as long as there is a way to adapt the code without hacking the whole thing (and loosing the possibility of upgrading). as long as the code was open, i would be happy to pay a certain amount for the application. anyone? phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Why this doesn't work ?
hi mario, first of all, make sure that your query works from the mysql console or phpmyadmin or some other tool (copy-paste the query from the code and replace $loging with something reasonable). then try the following: $query = SELECT COUNT (login) FROM formacao WHERE login = '$login'; // check to see if the $login variable has been filled in - // maybe $login is empty? echo $query; $result = mysql_query($query); if (!$result) { // mysql will tell you what's wrong echo mysql_error(); } mysql_fetch_row($result); and btw. mysql_fetch_row() doesn't require a connection resource, it will default to the last opened when none is given. so you only need to give the 2nd parameter if you have more than one mysql-db connection open. regards, phillip --- Mário Gamito schrieb: Hi, Why this doesn't work ? --- $query = SELECT COUNT (login) FROM WHERE login = '$login'; $result = mysql_query($query); mysql_fetch_row($result); --- It gives me Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /var/www/html/registar_action.php on line 22 Any help would be apreciated. Warm Regards, Mário Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why this doesn't work ?
ah! remove the whitespace between the COUNT and () : COUNT(login) instead of COUNT () ... Hi, Make this line instead $result = mysql_query($query) or die(mysql_error() . with the query $query; and you'll likely see the error. Here it goes: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(login) FROM formacao WHERE login = 'a'' at line 1 Regards, Mário Gamito -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: CURL and multiple sites at once
curl_setopt($ch, CURLOPT_URL, http://foobarcom/page1html;); curl_setopt($ch, CURLOPT_FILE, $fh1); curl_exec($ch); //exec1 curl_setopt($ch, CURLOPT_URL, http://foobarcom/page2html;); curl_setopt($ch, CURLOPT_FILE, $fh2); curl_exec($ch); //exec2 curl_setopt($ch, CURLOPT_URL, http://foobarcom/page3html;); curl_setopt($ch, CURLOPT_FILE, $fh3); every time you set CURLOPT_URL and CURLOPT_FILE you overwrite the last value that's why only the last page will be fetched write a function that fetches ONE page and call that in a loop for every page you want to fetch something like this function fetchAndSavePage($url) { // put your fopen curl code here // convert the $url into a useful filename $pagesToFetch = array (page1,page2,page3); foreach ($pagesToFetch as $url) { fetchAndSavePage($url); } good luck, phil -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
[PHP] Re: Can I use PHP to check server software????
Hei wrote: Can I use PHP to check server software??? you can use curl, see the func below needs the php-curl libary enabled phil titleshowHeader - lese HTTP Header Antwort des entfernten Servers/title form action=?php echo $PHP_SELF ? input type=text name=url value=?php echo $url ? style=width:300px; input type=submit name=submit value=showHeader /form pre ?php include_once(getHttpHeaderphp); if ($url == || ereg(^[ ]{1,}$,$url)) // string leer oder aus nur einem oder mehreren leerzeichen // url ungesetzt oder nur leerzeichen { echo p waiting for url/p; exit; } else { echo pb$url/bbr /returned the following header:/p; echo getHttpHeader($url); } ? /pre - ?php function getHttpHeader($url) { ob_start(); // send all output to a buffer instead of being displayed $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); #curl_setopt($ch, CURLOPT_USERPWD, $user:$password); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); #curl_setopt($ch, CURLOPT_CUSTOMREQUEST, HEAD / HTTP/10); curl_exec($ch); curl_close ($ch); $header = ob_get_contents(); // put all buffered output into $header ob_end_clean(); return $header; } ? -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
[PHP] Re: errorr log
Erwien Samantha Y wrote: does you webserver (apache?) and/or php have the rights needed to write to the /tmp directory? if not you have to chmod the permissions for the /tmp dir an maybe better idea would be to make directory /tmp/php directory and chown that to wwwrun but you should double-check the consequences of that by youself since i'm not a *nix expert phil -- PHP General Mailing List (http://wwwphpnet/) To unsubscribe, visit: http://wwwphpnet/unsubphp
[PHP] Re: PHP software tool
Yoep wrote: I use this one too... its just 20$ or so though, and is a very great and convient editor. I do all my PHP coding in it. ACK. phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Paging through MySQL results in PHP
hi nelson, i'm not sure if i get you right, but you could store the 'base' of your generated SQL query in a session variable, that way you don't have to drag the $kw array along. // before any html output (sends http headers) session_start(); // build query from keywords -- results in string $s_base_query session_register(s_base_query); then, for every new page you build your full query like this: $query = $s_base_query . LIMIT $firstitem,$items; hope this helps, phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Help Please
line 29: mysql_query('$SQL') will send the following query to your db: $SQL i know of no db that understands that ;-) everything in single quotes is NOT parsed by php. here, use double quotes, or better, none at all. hope it works now, phil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Help Please (clarification)
Phillip Oertel wrote: line 29: mysql_query('$SQL') will send the following query to your db: $SQL -- it sends exactly this string instead of the content of your variable $SQL, which contains the real query. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: $PHP_SELF not working -please help
Alawi wrote: use $PHPSELF not $PHP_SELF in windows BAD IDEA. what happens if one day you (or even worse: someone else) wants to run your scripts on a different server? one of the nicest things about PHP that you can run it on many different any OS's. phil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: $PHP_SELF not working -please help
Now for some strange reasons it tries to access my web direcorty that does not contain any file, and i get the 404 page not found error. check the source code of the html page. most likely you will see: FORM ... ACTION=. if not, it will still give you a hint about what's going wrong. are you constructing that form within a function? then you have to pull the $PHP_SELF variable into the local context. put 'global $PHP_SELF;' at the top of the form-outputting function. phil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: http message
see my message Re: URL checking. i just posted a few curl functions that do exactly what you want to. phil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: replacing Carriage Return
Phantom wrote: I solicit information from a text field and save the data in mysql to be pulled out later and displayed as text on a webpage. However, Carrage Returns in the text field do not appear in the webpage text. they're not supposed to show up in HTML ! you need to replace the \n that come from the textarea with the HTML Tag br to have line breaks in your HTML. nl2br() will do that for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: array in sessions
Gregor Jaksa wrote: Hello, is it possible to register array in session .. something like that: session_register(ex_array[field1]); session_register(ex_array[field2]); session_register(ex_array) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: i get a warning after upgrading to 4.1.0 (repost)
John Lim wrote: This is a known bug with persistent database connections. Switching to non-persistent connections or ISAPI avoids this problem. thanks ! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: pictures width and height
Tommy Straetemans wrote: Is there a way to check the height and width from a picture that I upload? yes, easy. but you need gdlib installed. ?php phpinfo(); ? will tell you. from the documentation: The GetImageSize() function will determine the size of any GIF, JPG, PNG, SWF, PSD or BMP image file and return [in an array] the dimensions along with the file type and a height/width text string to be used inside a normal HTML IMG tag. please also consult the php documentation for other (image) functions, it's excellent. phil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: URL checking
Trx wrote: Hi, I'm very much a newbie! I'm trying to set up a site which will automatically test links in a large link directory and show date and time of last check and whether or not a link to the external URL was dead or alive at the time. the curl library will let you do this. query the link, and then evaluate the server's response. but first of all check if you have curl enabled. ?php phpinfo(); ? then check out the example, two functions i happened to write a few days ago, no kidding. ;-) make sure you are prepared for that the remote server doesn't respond at all. phil. ?php echo getHttpStatusCode(http://www.phillipoertel.com/index.html;); function getHttpHeader($url) { ob_start(); // send all output to a buffer instead of being displayed $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); // you could probably achieve the same with the following line. # curl_setopt($ch, CURLOPT_CUSTOMREQUEST, HEAD / HTTP/1.0); curl_exec($ch); curl_close ($ch); // put all buffered output into $header $header = ob_get_contents(); ob_end_clean(); return $header; } function getHttpStatusCode($url) { $header = getHttpHeader($url); // grab only first line of the header list($status) = explode(\n,$header); $code = explode( ,$status); return $code[1]; } ? HTTP Status Codes: * 100 Continue 101 Switching Protocols 200 OK 201 Created 202 Accepted 203 Non-Authoritative Information 204 No Content 205 Reset Content 206 Partial Content 300 Multiple Choices 301 Moved Permanently 302 Moved Temporarily / Found 303 See Other 304 Not Modified 305 Use Proxy 400 Bad Request 401 Unauthorized 402 Payment Required 403 Forbidden 404 Not Found 405 Method Not Allowed 406 Not Acceptable 407 Proxy Authentication Required 408 Request Time-Out 409 Conflict 410 Gone 411 Length Required 412 Precondition Failed 413 Request Entity Too Large 414 Request-URL Too Large 415 Unsupported Media Type 500 Server Error 501 Not Implemented 502 Bad Gateway 503 Out of Resources 504 Gateway Time-Out 505 HTTP Version not supported -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: Problem with Code
Phillip B. Bruce wrote: 1. Is there any documentation that explains the differences between the versions of PHP? php4 : much more fun ! go use it ! the documentation will tell you on each function page in which php version the fuction was first available. 2. Does it matter when writing php code that you specifiy the file name in the following manner? test.php3 test.php4 or whatever. since you have PHP v3, .php4 and .php will not be parsed at all (you will see your code plaintext in the browser). the webserver can be set up to still have .php3 handled by PHP v3 and .php4 by PHP v4. in any case, i think you should ask your ISP to upgrade to PHP v4 ... 3.0.9 when was that ? I have the following error: Fatal error: Call to unsupported or undefined function include_once() in include_fns.php3 on line 7 from http://www.php.net/manual/en/function.include-once.php : include_once() was added in PHP 4.0.1pl2 phil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] i get a warning after upgrading to 4.1.0 (repost)
does anyone know what Warning: Unknown persistent list entry type in module shutdown (11) in Unknown means? what do i have to do to solve the problem php seems to have? environment: Win2k, IIS5.0, MySQL just upgraded from PHP 4.0.6 to 4.1.0 now i get the warning msg. any help would be appreciated. kind regards, phil! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: last entry in mysql
Yoed Anis wrote: hey guys, quick question I'm having trouble finding an answer too. In a mysql database, how can I select that last row entry. This might be done mins after i put that entry there and i tried to use: $lastid=mysql_insert_id(); to get the last id but to no avail. Thanks Yoed RT*M mysql_insert_id() returns 0 if the previous query does not generate an AUTO_INCREMENT value. If you need to save the value for later, be sure to call mysql_insert_id() immediately after the query that generates the value. could that be your problem ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] i get a warning after upgrading to 4.1.0
does anyone know what Warning: Unknown persistent list entry type in module shutdown (11) in Unknown means? what do i have to do to solve the problem php seems to have? environment: Win2k, IIS5.0, MySQL just upgraded from PHP 4.0.6 to 4.1.0 now i get the warning msg. any help would be appreciated. kind regards, phil! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: using eval
why would you want you quote the variable? eval (\$str = $str;); should work. at least no more parse error. phil. [EMAIL PROTECTED] wrote: I keep getting this error when I use eval what am I missing Parse error: parse error in c:\httpd\doc\install.php(6) : eval()'d code on line 1 $path=/home/sites/home; $fp3=fopen (location.inc,w)or die(unable to open file (location.inc)); $str='include($path/inc/dataconf.inc);'; eval (\$str = \$str\;); fwrite($fp3,$str \n); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]