Re: [PHP] mysql_connect does not connect
Windows XP Firewall, or any other firewall for that matter must be off. Jason Sam Hobbs [EMAIL PROTECTED] wrote: I have: PHP Version 5.0.1 MySQL 5.0.1 Apache 2.0.48 Winows XP Pro SP2 MySQL is working fine as best as I can see; I have tried the various samples in the MySQL manual and I have executed the myTest sample provided with MySQL. They all work. However I can't get mysql_connect to work; when I try: $conn = mysql_connect(localhost, root); I get: Warning: mysql_connect() [function.mysql-connect.chm]: Can't connect to MySQL server on 'localhost' (10061) The host and user should be correct; I have not changed anything such as that after installation. The password should still be blank. However I have tried many, many other combinations but nothing that works. Is 10061 an error code? I can't find it in the PHP documentation. -- 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] mysql_connect does not connect
Also, a google on the error returns hundreds of results.. http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta= Jason Jason Davidson [EMAIL PROTECTED] wrote: Windows XP Firewall, or any other firewall for that matter must be off. Jason Sam Hobbs [EMAIL PROTECTED] wrote: I have: PHP Version 5.0.1 MySQL 5.0.1 Apache 2.0.48 Winows XP Pro SP2 MySQL is working fine as best as I can see; I have tried the various samples in the MySQL manual and I have executed the myTest sample provided with MySQL. They all work. However I can't get mysql_connect to work; when I try: $conn = mysql_connect(localhost, root); I get: Warning: mysql_connect() [function.mysql-connect.chm]: Can't connect to MySQL server on 'localhost' (10061) The host and user should be correct; I have not changed anything such as that after installation. The password should still be blank. However I have tried many, many other combinations but nothing that works. Is 10061 an error code? I can't find it in the PHP documentation. -- 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] convert degrees to heading
Hi, Alternatively, try :- $Compass = array('West', 'North Westerly', 'North', 'North Easterly', 'East', 'South Easterly', 'South', 'South Westerly'); print $Compass[round($Degrees / 45)] . \n; This can be expanded easily by adding 'North North West' etc. at the relevant points in the array and changing the 45 to 22.5. No messy horrible switches :-) TTFN, Dave php/2004-09-14.tx [EMAIL PROTECTED], php-general,[EMAIL PROTECTED] ++ | Dave Restall, IIRC Limited, PO Box 46, Skelton, Cleveland, TS12 2GT. | | Tel. 0845 10 80 151Mob. +44 (0) 7973 831245 Int. +44 (0) 1287 653003 | | email : [EMAIL PROTECTED] [EMAIL PROTECTED] Web : http://www.iirc.net | ++ | One picture is worth more than ten thousand words. | | -- Chinese proverb | ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] convert degrees to heading
Hi, Alternatively, try :- $Compass = array('West', 'North Westerly', 'North', 'North Easterly', 'East', 'South Easterly', 'South', 'South Westerly'); print $Compass[round($Degrees / 45)] . \n; This can be expanded easily by adding 'North North West' etc. at the relevant points in the array and changing the 45 to 22.5. No messy horrible switches :-) Oh and I forgot to mention, it also deals fairly well with weird degrees such as 48.7. Dave php/2004-09-14.2.tx[EMAIL PROTECTED], php-general,[EMAIL PROTECTED] ++ | Dave Restall, IIRC Limited, PO Box 46, Skelton, Cleveland, TS12 2GT. | | Tel. 0845 10 80 151Mob. +44 (0) 7973 831245 Int. +44 (0) 1287 653003 | | email : [EMAIL PROTECTED] [EMAIL PROTECTED] Web : http://www.iirc.net | ++ | Azh nazg durbatal^uk, azh nazg gimbatul, Azh nazg thrakatal^uk agh | | burzum ishi krimpatul! | | -- J. R. R. Tolkien| ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] perl regex in php and multiple escape rules
In a word: I'm looking for more detailed information about preg_replace (and other perl regex functions) than in the php manual, specifically about different escape rules interaction. In more words: PHP has it's own way of escaping strings [2] Ex \ within '' is '\' (or '\\' if at the end or before ' ) \ within is \ (or \\ if at the end or before ) So \\ can be written '\\\' or '' or \\\ or and \\\ can be written '\' or '\\' (same with ) (rule 1) Perl regex are powerfull and came with other escape rules [3] Ex regex to match... is ... \ /\\/ (newline) \n /\n/ (2 chars) \n /\\n/ (rule 2) My problem is about preg_replace function, because it's entry in the php manual [1] is not specific enough -- I mean, writing a real specification seems impossible without more details The 'pattern' argument is a string, but how does php proceed it? I guess it first uses rule1 then rule2, ie php string escape rule (for ' and \ ) then perl regex rule (via verbatim use in perlre C library?) This mean that to match \n (the 2 chars), the perl re is \\n so correct php pattern is '\\\n' or 'n' or \\\n or n. (see comment 29-Mar-2004 05:46 on [1]). Is this right? /me think using perl regex is easier in perl than in php ;-) Is it the same for the 'replacement' argument? Another comment (steven -a-t- acko dot net, 08-Feb-2004 12:45) says To make this easier, the data in a backreference with /e is run through addslashes() before being inserted in your replacement expression. Is that user right? Ok, I can try to guess answers to my questions by probing things. But that didnt tell me if my guesses are wrong, or if what I guess is exactly what php pcre functions are supposed to do (not only now with php x.y.z but in the future too). And I prefer specifications over guesses. (think about ppl using alt attribute instead of title on img html tags : they guessed wrong by not reading html spec) In other words, is there some details about escape rules in pcre php functions? I feel much better when I can use a stable, reliable and precise API. Christophe [1] preg_replace in php manual http://www.php.net/manual/en/function.preg-replace.php [2] strings in php manual http://www.php.net/manual/en/language.types.string.php [3] pcre syntax in php manual http://www.php.net/manual/en/reference.pcre.pattern.syntax.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] perl regex in php and multiple escape rules
On Tue, 14 Sep 2004 11:18:33 +0200, Christophe Chisogne [EMAIL PROTECTED] wrote: In a word: I'm looking for more detailed information about preg_replace (and other perl regex functions) than in the php manual, specifically about different escape rules interaction. In more words: PHP has it's own way of escaping strings [2] Ex \ within '' is '\' (or '\\' if at the end or before ' ) \ within is \ (or \\ if at the end or before ) So \\ can be written '\\\' or '' or \\\ or and \\\ can be written '\' or '\\' (same with ) (rule 1) Perl regex are powerfull and came with other escape rules [3] Ex regex to match... is ... \ /\\/ (newline) \n /\n/ (2 chars) \n /\\n/ (rule 2) My problem is about preg_replace function, because it's entry in the php manual [1] is not specific enough -- I mean, writing a real specification seems impossible without more details The 'pattern' argument is a string, but how does php proceed it? I guess it first uses rule1 then rule2, ie php string escape rule (for ' and \ ) then perl regex rule (via verbatim use in perlre C library?) This mean that to match \n (the 2 chars), the perl re is \\n so correct php pattern is '\\\n' or 'n' or \\\n or n. (see comment 29-Mar-2004 05:46 on [1]). Is this right? /me think using perl regex is easier in perl than in php ;-) Is it the same for the 'replacement' argument? Another comment (steven -a-t- acko dot net, 08-Feb-2004 12:45) says To make this easier, the data in a backreference with /e is run through addslashes() before being inserted in your replacement expression. Is that user right? Ok, I can try to guess answers to my questions by probing things. But that didnt tell me if my guesses are wrong, or if what I guess is exactly what php pcre functions are supposed to do (not only now with php x.y.z but in the future too). And I prefer specifications over guesses. (think about ppl using alt attribute instead of title on img html tags : they guessed wrong by not reading html spec) In other words, is there some details about escape rules in pcre php functions? I feel much better when I can use a stable, reliable and precise API. Christophe [1] preg_replace in php manual http://www.php.net/manual/en/function.preg-replace.php [2] strings in php manual http://www.php.net/manual/en/language.types.string.php [3] pcre syntax in php manual http://www.php.net/manual/en/reference.pcre.pattern.syntax.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It's all very easy, actually. You take the real regex, and convert that to a php string. for example: to match the two chars \n, in perl you'd do: /\\n/ php requires each slash to be slashed again, so you'd get $regex = '/n/'; whenever you're in doubt, put the regex into a var, print that var and if that what you get is exactly the regex you'd use in perl, you're good. And yes, I do agree with anybody who'd state that it's a bit confusing. Cuz it is! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating a date before 1970 on Fedora
On Mon, 13 Sep 2004 12:39:26 -0500, Greg Donald [EMAIL PROTECTED] wrote: On Mon, 13 Sep 2004 19:03:09 +0200, Wouter van Vliet [EMAIL PROTECTED] wrote: Howdy, I would assume this to be a common problem, but as I wrote to this list myself a couple of days ago I was only aware of it's existence on windows systems. Here's some sample code 1 ?php 2 $date = strtotime('12 feb 1950'); 3 print $date.': '.date('r', $date).\n; 4 $date = mktime(0,0,0,2,12,1950); 5 print $date.': '.date('r', $date).\n; 6 ? And this is it's output: -1: Thu, 1 Jan 1970 00:59:59 +0100 -3662: Wed, 31 Dec 1969 23:58:58 +0100 My search on google didn't help me out, the docs say that it should work and I can remember me having used such code and got it working. Please fella's, what am I missing? The bottom of the strtotime() manual page where it says: Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. A couple years ago when upgrading some web servers we found RedHat 7 had this issue, strtotime() basically didn't work and always returned -1 on 'negative' unix timestamps. I have never used Fedora but it's probably the same issue all over again. I know this isn't the answer you were hoping for, but I wanted to share my experience. so, basically my problem is confirmed to be existent - such a relieve ;) It's just that ppl I work for do want to be able to be born before 1970, cuz some are. Mashed patatoes :@ - is there really no way to deal with this? Might somebody have created a nice rpm of the kernel with t_*smth* set to 64 or 32 bits signed? I have full control over the server, so if i'd need to make any changes, that is possible. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating a date before 1970 on Fedora
Wouter van Vliet a écrit : Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) To avoid unix timestamps limits, dont reinvent the wheel. The Pear Date class [1] can probably help you. Perhaps this should go in the manual for date() [2], as it looks like a FAQ. [1] pear Date http://pear.php.net/package/Date [2] php date() http://www.php.net/manual/en/function.date.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple Problem about forms and sending info to db
I am currently coding a cms. So far I have completed the security login/password system but have now moved on to a new area of php. Uploading info to a database. This is the code as it stands now. ?php if($_GET[action] == ){echo form name=adduser method=post action=adduser.php?action=adduser table width=400 border=0 cellspacing=0 cellpadding=5 tr valign=top td width=50% align=rightFull Name:/td td width=50%input name=fullname type=text id=fullname/td /tr tr valign=top td height=50 align=rightEmail:/td tdinput name=email type=text id=email/td /tr tr valign=top td align=rightUserName:/td tdinput name=username type=text id=username/td /tr tr valign=top td align=rightPassword:/td tdinput name=password type=password id=password/td /tr tr align=center td colspan=2input type=submit name=Submit value=Submit/td /tr /table /form ;} if($_GET[action] == adduser){echo Add User Function is still Under Construction br as a result what you just did has had no effect} ? I know there is something wrong as i get an error when I goto the page. I want it to display the form, then when you click submit, goto the same page except run the command to add the information from the form to the database. Also how do I put the information in the database. Regards Logan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple Problem about forms and sending info to db
Ok I think I figured out my own problem. The speechmarks in the Form break up the speech marks in the echo statement so I originally changed the echo statements speechmark to a ' which worked but was informed that this was considered bad syntax and that maybe I should add a \ in front of all speechmarks which are not part of the echo statement. I could still do with an example of how to put the information from the form into the db though. As I have never done this before. Logan Moore [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am currently coding a cms. So far I have completed the security login/password system but have now moved on to a new area of php. Uploading info to a database. This is the code as it stands now. ?php if($_GET[action] == ){echo form name=adduser method=post action=adduser.php?action=adduser table width=400 border=0 cellspacing=0 cellpadding=5 tr valign=top td width=50% align=rightFull Name:/td td width=50%input name=fullname type=text id=fullname/td /tr tr valign=top td height=50 align=rightEmail:/td tdinput name=email type=text id=email/td /tr tr valign=top td align=rightUserName:/td tdinput name=username type=text id=username/td /tr tr valign=top td align=rightPassword:/td tdinput name=password type=password id=password/td /tr tr align=center td colspan=2input type=submit name=Submit value=Submit/td /tr /table /form ;} if($_GET[action] == adduser){echo Add User Function is still Under Construction br as a result what you just did has had no effect} ? I know there is something wrong as i get an error when I goto the page. I want it to display the form, then when you click submit, goto the same page except run the command to add the information from the form to the database. Also how do I put the information in the database. Regards Logan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: Supported OS
Thanks for ur reply. I was looking for ports for these OS. server-side OS, not client-side. But i guess Php doesnt support severs with these OS then, at least i could not find any downloads like i did for Perl. Marlen Dan Joseph [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hi, could anyone tell me if PHP supports these OS? I wasnt able to find anything on the net. LynxOS MVS OS390 QNX VMS Windows CE Xenix Thanks, FireSnake www.php.net You should be able to find builds for Windows and Linux (as far as server...). If you are wondering what browsers on which OSes will display PHP pages, all of them, PHP is server side. -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] prob parsing Url
Hi folks.. I'm using a form to send data from one page to another. one of the input fields in the form has a quotation mark Ex.: samsung 15 monitor in the next page i cant get the text after the symbol in the field. I've tried both GET and POST methods. what might b the problem /sagar
[PHP] Re: prob parsing Url
Urlencode() and urldecode() should help you out. Niklas Sagar C Nannapaneni wrote: Hi folks.. I'm using a form to send data from one page to another. one of the input fields in the form has a quotation mark Ex.: samsung 15 monitor in the next page i cant get the text after the symbol in the field. I've tried both GET and POST methods. what might b the problem /sagar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Simple Problem about forms and sending info to db
First of all, I'd use something like this: -- CODE -- ? if (!isset($_GET['action']) || trim($_GET['action']) == ) { ? form./form ? } else if ($_GET['action'] == 'adduser') { ? Foo ? } ? -- END -- But the actual error is in the echo. You're having quotation marks inside it. You need to do it my way, or write the form like ? echo form name=\myForm\.../form; ? Niklas Logan Moore wrote: I am currently coding a cms. So far I have completed the security login/password system but have now moved on to a new area of php. Uploading info to a database. This is the code as it stands now. ?php if($_GET[action] == ){echo form name=adduser method=post action=adduser.php?action=adduser table width=400 border=0 cellspacing=0 cellpadding=5 tr valign=top td width=50% align=rightFull Name:/td td width=50%input name=fullname type=text id=fullname/td /tr tr valign=top td height=50 align=rightEmail:/td tdinput name=email type=text id=email/td /tr tr valign=top td align=rightUserName:/td tdinput name=username type=text id=username/td /tr tr valign=top td align=rightPassword:/td tdinput name=password type=password id=password/td /tr tr align=center td colspan=2input type=submit name=Submit value=Submit/td /tr /table /form ;} if($_GET[action] == adduser){echo Add User Function is still Under Construction br as a result what you just did has had no effect} ? I know there is something wrong as i get an error when I goto the page. I want it to display the form, then when you click submit, goto the same page except run the command to add the information from the form to the database. Also how do I put the information in the database. Regards Logan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple Problem about forms and sending info to db
On Tuesday 14 September 2004 18:06, Logan Moore wrote: Ok I think I figured out my own problem. The speechmarks in the Form break up the speech marks in the echo statement so I originally changed the echo statements speechmark to a ' which worked but was informed that this was considered bad syntax and that maybe I should add a \ in front of all speechmarks which are not part of the echo statement. It's up to you. IMO, using single quote strings and breaking out when handling variables is more readable than using double quote strings and escaping the double quote (\). I could still do with an example of how to put the information from the form into the db though. As I have never done this before. Plenty of tutorials out there. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* There are no working trigger cables, unless they are too short -- Ralf's Laws of Observational Astronomy n2 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: Supported OS
On Tue, 14 Sep 2004 12:12:16 +0200, FireSnake [EMAIL PROTECTED] wrote: Thanks for ur reply. I was looking for ports for these OS. server-side OS, not client-side. But i guess Php doesnt support severs with these OS then, at least i could not find any downloads like i did for Perl. Marlen Dan Joseph [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hi, could anyone tell me if PHP supports these OS? I wasnt able to find anything on the net. LynxOS MVS OS390 QNX VMS Windows CE Xenix Thanks, FireSnake www.php.net You should be able to find builds for Windows and Linux (as far as server...). If you are wondering what browsers on which OSes will display PHP pages, all of them, PHP is server side. -Dan Joseph If you have some experience in compiling sourcecode into binaries, you might be able to compile for all OS's you'd want to use it on. Basically the only thing you'd need on each platform is a nice c compiler. Keep me posted! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple Problem about forms and sending info to db
On Tue, 14 Sep 2004 18:32:50 +0800, Jason Wong [EMAIL PROTECTED] wrote: On Tuesday 14 September 2004 18:06, Logan Moore wrote: Ok I think I figured out my own problem. The speechmarks in the Form break up the speech marks in the echo statement so I originally changed the echo statements speechmark to a ' which worked but was informed that this was considered bad syntax and that maybe I should add a \ in front of all speechmarks which are not part of the echo statement. It's up to you. IMO, using single quote strings and breaking out when handling variables is more readable than using double quote strings and escaping the double quote (\). I could still do with an example of how to put the information from the form into the db though. As I have never done this before. Plenty of tutorials out there. First of all, you're making some pretty harsh coding style errors. For the sake of compatibility, always make sure you're quoting non-numerical elements in an array, thus: write $_GET['action'] instead of $_GET[action]. Imagine, for example, what would happen if you've got some field named public and you're upgrading to php5? Or when, in php 5.4 (just saying smth), action suddenly becomes a keyword. You're stuck then with dead code. Good practice is also to check whether your expected array entry is actually set. I usually do smth like: isset($_GET['action']) or $_GET['action'] = 'thedefaultvalue'; or if (!isset($_GET['action'])) { $_GET['action'] = 'thedefalutvalue']; }; (both do the same, first one is just a lot shorter). As adviced before, whenever you have to check if a certain variable has a certain value, and if one of them is true, none of the others will be true (which is the case with $_GET['action'] checks, usually) - use the if ( /* conditions */ ) { } elseif ( /* other conditions */ ) { } method, rather than all seperate if's. I once changed this in somebody else's code and found the script running about 5 (!!) times faster, with about 15 conditions. For inserting into the databas, mysql_connect() and mysql_execute() are very good options. Or, if you're able to use the PEAR::DB package I'd advice you to use that. It's more fun to do it that way, and will help a lot if ever you'd want to change your database server from mysql to something else (postgres, for example). Ow, and it also helps a lot with any quoting problem you'd come up with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: prob parsing Url
On Tue, 14 Sep 2004 13:21:09 +0300, Niklas Lampén [EMAIL PROTECTED] wrote: Urlencode() and urldecode() should help you out. Niklas Sagar C Nannapaneni wrote: Hi folks.. I'm using a form to send data from one page to another. one of the input fields in the form has a quotation mark Ex.: samsung 15 monitor in the next page i cant get the text after the symbol in the field. I've tried both GET and POST methods. what might b the problem /sagar I'd go for htmlentities($str, ENT_QUOTES); to encode and decode the quotes, and other characters that are actually invalid to use in normal html code... ( Later versions of php have a reverse function, called html_entity_decode or smth) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] convert degrees to heading
On 13 September 2004 20:23, Gryffyn, Trevor wrote: Nice! I didn't know you could do that with switch. I was wondering why conditionals were left out of PHP's switch statement, but hoped someone would prove me wrong. Thanks John! Very helpful! -TG -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED] Sent: Monday, September 13, 2004 3:26 PM To: Gryffyn, Trevor; php Cc: René Fournier Subject: Re: [PHP] convert degrees to heading I have to write a little function to convert a direction from degrees to a compass -type heading. 0 = West. 90 = North. E.g.: Something like this... it'll account for 360 degrees, too. No different that a bunch of IF statements, though... ?php $dir = 378; switch($dir = $dir%360) { case 0 = $dir $dir 90: echo 'northeasterly'; break; case 90 = $dir $dir 180: echo 'southeasterly'; break; case 180 = $dir $dir 270: echo 'southwesterly'; break; case 270 = $dir $dir 360: echo 'northwesterly'; break; } That will actually give the wrong answer for $dir==0, since then the switch value will equate to (bool)FALSE, which will fail to match case 0 = $dir $dir 90 because that evaluates to (bool)TRUE in this situation. I'm guessing you'll get 'southeasterly' as that's the first FALSE value, but theoretically you could get any one of the other values since all the other conditions evaluate to FALSE! If you're using this kind of condition-matching switch statement, it's absolutely necessary to use switch(TRUE) to make it clear exactly what's going on; so the above should be: $dir %= 360; switch (TRUE) { etc } Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] perl regex in php and multiple escape rules
On 14 September 2004 10:19, Christophe Chisogne wrote: I'm looking for more detailed information about preg_replace (and other perl regex functions) than in the php manual, specifically about different escape rules interaction. [] The 'pattern' argument is a string, but how does php proceed it? I guess it first uses rule1 then rule2, ie php string escape rule (for ' and \ ) then perl regex rule (via verbatim use in perlre C library?) It's really very simple: (1) PHP processes the string, doing all PHP escape substitutions, and hands the result off to the pcre library; (2) pcre applies its escapes to the received string and then performs the match. This mean that to match \n (the 2 chars), the perl re is \\n so correct php pattern is '\\\n' or 'n' or \\\n or n. (see comment 29-Mar-2004 05:46 on [1]). Is this right? Not quite, since \n is also a valid escape sequence in PHP when used in double-quoted strings; so \\\n will be escape-processed by PHP to give the two-character sequence backslash-newline, whereas n will yield the 3-character sequence backslash-backslash-n. Of course, this is probably a moot point since pcre will then interpret the backslash-n sequence in the latter into a newline, but it's as well to be aware of it anyway. In other words, is there some details about escape rules in pcre php functions? I feel much better when I can use a stable, reliable and precise API. Well, the way I usually do it is to use the reverse order of the two rules above, so: - construct your pcre regex, including any necessary pcre escapes - then run through it inserting PHP escapes; this is a lot easier if you use single-quoted PHP strings, since the only valid PHP escape sequence in that case is \', so only backslashes preceding a ' or a \ actually require doubling. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] small query prob in Mysql
On Tue, 14 Sep 2004 05:37:30 +, Curt Zirzow [EMAIL PROTECTED] wrote: * Thus wrote Sagar C Nannapaneni: Hi everybody, I'm having a database named items, inthat one field name is itemname and the contents of that field is as follows Monitor 15 - LG Monitor 17 - Samsung Keyboard - TVS Monitor 15 - Samsung Mouse - Genius Keyboard - Microsoft The first part is the component name and the second is the Company name I need to have the distinct components in this field...like this Monitor Keyboard Mouse Any help would b greatly appreciated In order to do that properly, you would need a normalized database, a properly flattened data structure or hacked with some string manipulation. Seek more help from a SQL or mysql list. Curt -- The above comments may offend you. flame at will. Little handson: there is a way of selecting a certian part of a field, for instance everything till the first occurance of a space or dash. Probably two ways even, one with regexes the other one with substr kinda calls - all directly requestable to mysql. though I'd follow Curt's advice if i were you, take two columns, or even three - components, specifications, brand .. or smth. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem creating a date before 1970 on Fedora
On Tue, 14 Sep 2004 11:45:51 +0200, Christophe Chisogne [EMAIL PROTECTED] wrote: Wouter van Vliet a écrit : Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) To avoid unix timestamps limits, dont reinvent the wheel. The Pear Date class [1] can probably help you. Perhaps this should go in the manual for date() [2], as it looks like a FAQ. [1] pear Date http://pear.php.net/package/Date [2] php date() http://www.php.net/manual/en/function.date.php I'll have a look at it, thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] finding string in string
Hi, I've got the following little function: public function addText($pdf, $xPos, $yPos, $schriftgroese, $text){ /** * @description: Returning Text with automatic linebreak */ $heuhaufen = $text; for ($i=0; $i substr_count($heuhaufen, \n) + 1; $i++){ $posStr= stripos ($heuhaufen,\n); $text = substr ($heuhaufen, 0, $posStr); $heuhaufen = substr ($heuhaufen, $posStr, 1 ); if ($posStr ==0) $text = $heuhaufen; echo br\n\t|| $i $posStr ||| $text; } } That gives me in HTML: || 0 ||| Selbständiges Werk || 0 ||| Zweigwerk || 0 19 ||| Tochtergesellschaft || 1 0 ||| eines Konzerns oder einer Holding || 2 0 ||| eines Konzerns oder einer Holding || 0 ||| keine Angaben But if I have look at the generated code it schows CORRECTLY br || 0 ||| Selbständiges Werkbr || 0 ||| Zweigwerkbr || 0 19 ||| Tochtergesellschaftbr || 1 0 ||| eines Konzerns oder einer Holdingbr || 2 0 ||| eines Konzerns oder einer Holdingbr || 0 ||| keine Angaben The $text is preformated and checked it it's to wide for the desired place. The Output is placed at x-y Coord. for PDF Output. My Qustion is: Why for crying out loud, doesn't it cut the second time, the way it's supposed to. I just can't find the reason for this behavior. substr_count($heuhaufen, \n) is working stripos ($heuhaufen,\n); only the first time/ or the last line to be returned? Please help, I'm sitting on this for almost a day now. thx Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Reminder or answer to check if remote page is linking to you
Hi, I have been searching the archives for the past 2 hours without luck, I am looking for an older thread which was discussed on how to connect to a remote page and check if that page was linking back to blah.com, I think it was done via fopen. If you can tell me either, 1. the name of that thread or its url 2. how to do the above check I would really appreciate it. Thanks in advance, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reminder or answer to check if remote page is linking to you
From: Mag [EMAIL PROTECTED] I have been searching the archives for the past 2 hours without luck, I am looking for an older thread which was discussed on how to connect to a remote page and check if that page was linking back to blah.com, I think it was done via fopen. If you can tell me either, 1. the name of that thread or its url 2. how to do the above check I would really appreciate it. $page = file_get_contents('http://example.org/page.html'); Now use the string functions to search $page for a href back to your site. Not foolproof, but then nothing is. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_connect does not connect
Hi I connect to a MySQL 4.1 with the following String: if ($db_verbin=mysqli_connect($mysql_host,$mysql_user,$mysql_passw,$DB_n ame)) watch the i in mysqli_connect! I think I've read somewhere that you are required to use that for the 4.1 Versions, but you better look that up, I might be wrong there. Hope this helps JanBro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_connect does not connect
Hi I connect to a MySQL 4.1 with the following String: if ($db_verbin=mysqli_connect($mysql_host,$mysql_user,$mysql_passw,$DB_n ame)) watch the i in mysqli_connect! I think I've read somewhere that you are required to use that for the 4.1 Versions, but you better look that up, I might be wrong there. Hope this helps. By the way, can you connect thru PHPMyAdmin? If not you might have that old version password problem. JanBro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_connect does not connect
Hi I connect to a MySQL 4.1 with the following String: if ($db_verbin=mysqli_connect($mysql_host,$mysql_user,$mysql_passw,$DB_n ame)) watch the i in mysqli_connect! I think I've read somewhere that you are required to use that for the 4.1 Versions, but you better look that up, I might be wrong there. Hope this helps. By the way, can you connect thru PHPMyAdmin? If not you might have that old version password problem. JanBro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MSSQL, PHP and Linux
Hi, Nope, not paying for it. I think it is just a trial...he has tried for a few weeks to get the freetds library to work with redhat 9 with no luck so I think he just now wants to try fedora for the heck of it. We have no idea as to why it won't work with Red Hat 9...must me missing a small step or something but don't know...it can't be this hard. Hmm.. Kind of sounds like he doesn't know what he's doing to an extent. I'm no linux wiz, but I was able to get freedts setup on RH9 pretty easily. So no, its not that hard. Pass him the url www.linuxquestions.com, they can help. -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] convert degrees to heading
Very nice solution, Dave. I like simple, elegant and effective solutions like this. I was wracking my brain yesterday to come up with something like this, but my brain wasn't working. Hah. Good job! I think your compass directions are a bit off though.hah. West shouldn't be 0 degrees, it should be 270 normally (unless someone's using a compass system that I'm not familiar with). Here's a variation of your script that displays all 360 degrees (for validation purposes): $compass = array(N,NNE,NE,NEE,E,SEE,SE,SSE,S,SSW,SW,SWW,W ,NWW,NW,NNW); for ($degrees=0;$degrees360;$degrees++) { $compcount = round($degrees / 22.5); $compdir = $compass[$compcount]; echo $degrees degrees is roughly $compdir on the compassbr\n; } Yeah, I don't know what east of northeast is, so I just labeled it NEE :) Great thinking though. You still get the prize on this one. -TG -Original Message- From: Dave Restall - System Administrator,,, [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 4:14 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Gryffyn, Trevor Subject: Re: [PHP] convert degrees to heading Hi, Alternatively, try :- $Compass = array('West', 'North Westerly', 'North', 'North Easterly', 'East', 'South Easterly', 'South', 'South Westerly'); print $Compass[round($Degrees / 45)] . \n; This can be expanded easily by adding 'North North West' etc. at the relevant points in the array and changing the 45 to 22.5. No messy horrible switches :-) TTFN, Dave php/2004-09-14.tx [EMAIL PROTECTED], php-general,[EMAIL PROTECTED] +- ---+ | Dave Restall, IIRC Limited, PO Box 46, Skelton, Cleveland, TS12 2GT. | | Tel. 0845 10 80 151Mob. +44 (0) 7973 831245 Int. +44 (0) 1287 653003 | | email : [EMAIL PROTECTED] [EMAIL PROTECTED] Web : http://www.iirc.net | +--- -+ | One picture is worth more than ten thousand words. | | -- Chinese proverb | +--- -+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need curl
I need the latest version of curl , or at least version 7.10.5 , but the last version of php I have has libcurl 7.10.2, how can I upgrade CURL without upgrading php ? (Version 5.0 of php doesnt work) -- Diana Castillo Global Reservas, S.L. C/Granvia 22 dcdo 4-dcha 28013 Madrid-Spain Tel : 00-34-913604039 Ext 216 Fax : 00-34-915228673 email: [EMAIL PROTECTED] Web : http://www.hotelkey.com http://www.destinia.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: need curl
Hello, On 09/14/2004 11:46 AM, Diana Castillo wrote: I need the latest version of curl , or at least version 7.10.5 , but the last version of php I have has libcurl 7.10.2, how can I upgrade CURL without upgrading php ? (Version 5.0 of php doesnt work) Depending on your system, it may be possible to upgrade Curl without upgrading PHP itself. OTOH, if you tell what you would like to do with Curl, it may be possible to suggest an alternative solution that does not require upgrading curl. -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ZIP
HI! I need catch many files in my server and make a zip file. In pear i not see nothing. I think use exec for contruction a zip file. Any idea? Regards, JP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Communicate with Outlook
Ok, so I was bored.. Attached below is a PHP script that will connect to Outlook via COM and go through all the items in the Calendar, displaying the appointment name, location, FROM and TO date/times (adjusting for the weird assed MS timestamp.. Apparently # of seconds since some time in 1970), and whether it's recurring and/or all-day. I didn't snag the information about recurrence, but you can probably figure it out. Here's the MS Data Model for Outlook. Semi-helpful, although not organized very well: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000 /html/olobjApplication.asp Also, excuse the sloppy coding, just wanted to see if I could do this real quick. I have multiple mailboxes on my Outlook at work here, so I have it cycle through all mailboxes and all folders until it finds the right mailbox and correct calendar. There's probably a more direct way to do this. But this doesn't really add much overhead, so if it works, it works eh? Feel free to share any better way you might find. Code attached to the bottom -TG -Original Message- From: Shaun [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 25, 2004 11:17 AM To: [EMAIL PROTECTED] Subject: [PHP] Communicate with Outlook Hi, Is it possible for a PHP application to communicate with an Outlook calendar? I would like to create a web based application that shows staff availability... Thanks for any advice offered. ?php $comobjOutlook = new COM(outlook.application) or die(Unable to instantiate outlook); $comobjOutlook - Activate; $targetmailboxname = Mailbox - LastName, FirstName; $targetfoldername = Calendar; $objNamespace = $comobjOutlook-GetNameSpace(MAPI); $objFolders = $objNamespace-Folders(); $mailboxcount = $objFolders - Count(); $foundmailbox = FALSE; for ($i=1; $i=$mailboxcount; $i++) { $folderitem = $objFolders -Item($i); if ($folderitem - Name == $targetmailboxname) { $objMailbox = $folderitem; $foundmailbox = TRUE; } } $foundcal = FALSE; if ($foundmailbox) { $objFolders = $objMailbox-Folders(); $foldercount = $objFolders - Count(); for ($i=1; $i=$foldercount; $i++) { $folderitem = $objFolders - Item($i); if ($folderitem - Name == $targetfoldername) { $objCalendar = $folderitem; $foundcal = TRUE; } } if ($foundcal) { $objItems = $objCalendar-Items(); $itemcount = $objItems-Count(); for ($i=1; $i=$itemcount; $i++) { $apptitem = $objItems - Item($i); $apptstart = $apptitem - Start(); $apptend = $apptitem - End(); $apptallday = $apptitem - AllDayEvent(); $apptrecur = $apptitem - IsRecurring(); $apptsubject = $apptitem - Subject(); $apptlocation = $apptitem - Location(); $secondsadj = $apptstart - 14400; $startadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970)); $secondsadj = $apptend - 14400; $endadj = date(m/d/Y H:i:s, mktime(0,0,$secondsadj,1,1,1970)); if($apptallday) { $allday = All Day; } else { $allday = ; } if($apptrecur) { $recurring = Recurring; } else { $recurring = ; } echo $apptsubject @ $apptlocation\r\nFrom: $startadj To: $endadj\r\n; if ($allday OR $recurring ) echo $allday $recurring\r\n; echo \r\n\r\n; } } else { die (Did not find calendar folder); } } else { die(Did not find target mailbox: $targetmailboxname); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: image size?
-Original Message- Let me explain more fully: I call a script like this: img src=image.php?file=file_name_here.jpg The script figures out if the image named in $_GET['file'] is portrait or landscape, and creates a thumbnail of the same orientation. I would like to get the x and y values of the image out of this script somehow, so that I can specify the height and width attributes. However, calling imagecreatefromjpeg(image.php?file=file_name_here.jpg returns an error that it can't open the stream. That function needs the full path to the image. The full path can be a URL or it can be a file path. If you want it to access a URL, the URL needs to be fully formed - ie. Including the http://. -Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZIP
searching in php.net i found this... http://www.zend.com/zend/spotlight/creating-zip-files1.php On Tue, 14 Sep 2004 12:11:23 -0300 (ART), Juan Pablo Herrera [EMAIL PROTECTED] wrote: HI! I need catch many files in my server and make a zip file. In pear i not see nothing. I think use exec for contruction a zip file. Any idea? Regards, JP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -- Fernando Gutierrez Perez -- gmeileando un poco :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Convert textarea post data from plain text to html using php..how?
I stand corrected. Nl2br() is still useful when dealing with outputting data from textarea form elements... If you're outputting to a browser at least. But yes, it only inserts a br \ where there's a \n, it doesn't replace \n and doesn't do anything with \r's. -TG -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED] Sent: Monday, September 13, 2004 3:35 PM To: [EMAIL PROTECTED]; M. Sokolewicz Subject: Re: [PHP] Convert textarea post data from plain text to html using php..how? From: M. Sokolewicz [EMAIL PROTECTED] 1. nl2br($posteddata) - This converts all the \r\n's to br's so that it comes out with the same carriage returns as the person who inputed it gave it It doesn't change \r\n to br, it only changes \n to br / It doesn't change anything, actually. It just inserts the br /. ?php $str = asdf\nasdf\nasdf\nasdf; $n = nl2br($str); if(strstr($n,\n)) { echo 'Newlines present'; } else { echo 'Newlines not present'; } ? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: need curl
I have windows 2000. And the reason I need that version of CURL to work is I need to use this: curl_setopt($curl_interface, CURLOPT_ENCODING, gzip); Manuel Lemos [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, On 09/14/2004 11:46 AM, Diana Castillo wrote: I need the latest version of curl , or at least version 7.10.5 , but the last version of php I have has libcurl 7.10.2, how can I upgrade CURL without upgrading php ? (Version 5.0 of php doesnt work) Depending on your system, it may be possible to upgrade Curl without upgrading PHP itself. OTOH, if you tell what you would like to do with Curl, it may be possible to suggest an alternative solution that does not require upgrading curl. -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] replace accents
Anyone know of any function to replace letters with accents with just the regular letter, for instance replace á with a, ç with c, ñ with n ? -- Diana Castillo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace accents
On Tue, 14 Sep 2004 17:51:00 +0200, Diana Castillo [EMAIL PROTECTED] wrote: Anyone know of any function to replace letters with accents with just the regular letter, for instance replace á with a, ç with c, ñ with n ? str_replace(), eregi_replace() -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ZIP
Juan Pablo Herrera wrote: HI! I need catch many files in my server and make a zip file. In pear i not see nothing. I think use exec for contruction a zip file. Any idea? Regards, JP There are some classes (not in pear) that can create zip files w/out any special extension. google for php zip class or something like that -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace accents
Diana Castillo wrote: Anyone know of any function to replace letters with accents with just the regular letter, for instance replace á with a, ç with c, ñ with n ? $string = str_replace(array('á', 'ç', 'ñ'), array('a', 'c', 'n'), $string); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace accents
Diana Castillo wrote: Anyone know of any function to replace letters with accents with just the regular letter, for instance replace with a, with c, with n ? found this on the strtr() manual page (http://php.net/strtr): ?php function removeaccents($string){ return strtr( strtr( $string, '', 'SZszYAACNOOYaacnooyy' ), array( '' = 'TH', '' = 'th', '' = 'DH', '' = 'dh', '' = 'ss', '' = 'OE', '' = 'oe', '' = 'AE', '' = 'ae', '' = 'u' ) ); } ? --rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_connect does not connect
Janbro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi I connect to a MySQL 4.1 with the following String: if ($db_verbin=mysqli_connect($mysql_host,$mysql_user,$mysql_passw,$DB_n ame)) watch the i in mysqli_connect! I think I've read somewhere that you are required to use that for the 4.1 Versions, but you better look that up, I might be wrong there. Hope this helps JanBro Thank you. Yes I know that there are two versions of interfaces to MySQL and the newer version has the i in it. Perhaps I should use it, but I thought the older version works also. I am using mysql_connect because the tutorial I started using uses it. Obvioulsy mysql_connect is in php version 5 so it should work. So I hope no one thinks that my question has been answered. If there is something stating that mysql_connect is not supposed to be used then it would help to know where that is said. Otherwise it would help to know what to look for as possible causes, assuming that the host, user and password are correct. Also, are the warning messages documented? As I asked in my original question, is 10061 an error code? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Benchmarking a script
You will still get the benchmark of the functions, you just declare them outside of your benchmarking loop so they don't get re-declared. Pardon my syntax, I'm just going to try to demonstrate (using the getmicrotime function from the PHP manual): ?php Function dosomething ($somevar) { echo $somevar; return 1; } Function dosomethingelse ($somevar) { echo $somevar; return 1; } function getmicrotime() { list($usec, $sec) = explode( , microtime()); return ((float)$usec + (float)$sec); } # Benchmark here $time_start = getmicrotime(); For ($i=0; $i = 10; $i++) { $retval = dosomething($i); $retval2 = dosomethingelse($i); } $time_end = getmicrotime(); $time = $time_end - $time_start; # end benchmarking ? Every time you call dosomething and dosomethingelse, it executes the function, it just doesn't delare it over again. So even though your functions are declared outside of your benchmark loop, they still get executed inside the loop, therefore you get the time needed to execute 100,000 calls of both functions (in this case). The only thing you're not benchmarking here is the time to declare the functions once, which is extremely minimal. Does that clarify it a bit for you? -TG -Original Message- From: Cristian Lavaque [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 1:18 PM To: Gryffyn, Trevor Subject: Re: [PHP] Benchmarking a script Hello Trevor, I really appreciate your reply! In fact I haven't found a way to do it yet. I can't really do it the way you suggest cause part of what I want to benchmark is defining the functions. Someone suggested benching it from Apache, but I'm not sure how to do that. Thank you very much for taking the time to drop me an email. :) Regards, Cristian Gryffyn, Trevor wrote: Doesn't look like anyone responded to this (publicly at least). I wasn't sure if you were still having a problme, but something you might try is putting the function definitions outside of the loop. They'll get called once, and still be executed within the loop. Good luck! -TG __ _ This message has been checked by mks_vir mail scanner ( http://www.mks.com.pl ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_connect does not connect
Janbro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi I connect to a MySQL 4.1 with the following String: if ($db_verbin=mysqli_connect($mysql_host,$mysql_user,$mysql_passw,$DB_n ame)) watch the i in mysqli_connect! I think I've read somewhere that you are required to use that for the 4.1 Versions, but you better look that up, I might be wrong there. Hope this helps JanBro When I do try mysqli_connect, I get: Fatal error: Call to undefined function mysqli_connect() So obviously I need to do something to enable that. I will look into that later, but I am still trying to get mysql_connect to work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Windows XP Firewall, or any other firewall for that matter must be off. Jason Can someone else confirm that this is correct? For one thing, when I use MySQL directly outside of a web page, it works. The sample C program works. For another thing, I doubt very immensely that everyone using mysql_connect does not use a firewall. Even if anyone else does, I will not. It would have been quite unreasonable for the developers of PHP to develop software with that requirement, but I doubt it was. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql_connect does not connect
Sam Hobbs wrote: snip When I do try mysqli_connect, I get: Fatal error: Call to undefined function mysqli_connect() So obviously I need to do something to enable that. I will look into that later, but I am still trying to get mysql_connect to work. mysqli : http://us4.php.net/mysqli What error are you getting with mysql_connect()? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Sam Hobbs wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Windows XP Firewall, or any other firewall for that matter must be off. Jason Can someone else confirm that this is correct? It's not correct. For one thing, when I use MySQL directly outside of a web page, it works. The sample C program works. For another thing, I doubt very immensely that everyone using mysql_connect does not use a firewall. Even if anyone else does, I will not. It would have been quite unreasonable for the developers of PHP to develop software with that requirement, but I doubt it was. I don't know anything about WindowsXP or it's 'firewall', but you _may_ have to open the port for which you have MySQL running on. I haven't followed this thread, but if MySQL, and your php enabled webserver are on the same box, then your firewall doesn't come into play. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql_connect does not connect
On Tue, 14 Sep 2004 10:11:24 -0700, Sam Hobbs [EMAIL PROTECTED] wrote: Also, are the warning messages documented? As I asked in my original question, is 10061 an error code? 10061 is a generic winsock error for a timeout, it's not PHP or MySQL specific. It means that the call couldn't connect to the socket you were trying to hit within the time allowed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused overSimple PHP mySQL date question
Hi, I have checked the recent list archives and looked up various PHP functions. I know what I want should be simple but, apparently not simple enought for me. I have a mysql database that has a date field and a time field. I want users to be able to enter a date and a time in text boxes on an html form and have them end up in the database. I am having no trouble connecting to the database and running queries against the database but I cannot get the dates and times into the database. Of course I also want to search for the database for an entered date on another form. I am not having trouble with SQL statements or mysql_connect() or anything like that just taking a date as a string from a text box and getting into a DATE field in a mysql database. What obvuios thing did I miss? Note I am not using the system date or time stamp, these are entered dates. Regards, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Confused overSimple PHP mySQL date question
[snip] DATE field in a mysql database. What obvuios thing did I miss? Note I am not using the system date or time stamp, these are entered dates. [/snip] You're using a DATE field in the MySQL database. MySQL requires an ISO formatted date unless you manipulate it, such as 2004-09-14 http://dev.mysql.com/doc/mysql/en/Date_and_time_types.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused overSimple PHP mySQL date question
From: Scott Miller [EMAIL PROTECTED] I have a mysql database that has a date field and a time field. I want users to be able to enter a date and a time in text boxes on an html form and have them end up in the database. Code examples would be good here. Either way, the format for a DATE field is MMDD or '-MM-DD' and the format for a TIME field is HHMMSS or 'HH:MM:SS'. Make sure what you're trying to stick in the database is in that format. If you want to accept another format in your text fields, then you'll need to use date(), strtotime(), mktime(), explode(), etc to format it this way. You really just need one DATETIME or TIMESTAMP field, though... there's reason to keep these values in two separate fields if they are related to the same event. It'll make searching down the road easier. SELECT * FROM events WHERE datetimecolumn BETWEEN NOW() AND INTERVAL + 30 DAY; SELECT * FROM events WHERE datetimecolumn BETWEEN 20040901 AND 20040930; etc... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
John Nichel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I don't know anything about WindowsXP or it's 'firewall', but you _may_ have to open the port for which you have MySQL running on. I haven't followed this thread, but if MySQL, and your php enabled webserver are on the same box, then your firewall doesn't come into play. Yes, this is all one system, so I sure thought that a firewall is not relevant. Thank you for saying so. I don't (should not) have the Windows XP firewall turned on; I use ZoneAlarm. This is extraneous relevance, but there is a possibility that the Windows XP firewall got turned on due to Windows XP SP2 (the latest big batch of fixes and upgrades for XP). I doubt it, though; I have checked and such. However to the extent that a firewall is not relevant, this is tnot relevant. Something that might be relevant is the possibility of some other new security feature installed by the XP SP2. If so, then many others will be encountering it in the future; SP2 was released to the public sometime in the last couple of months, probably less than a month ago. Even so, I am surprised that I am the first to say anything if that is the problem. Probably if that was a problem, other systems that were working would have been broken by SP2 and people would know that SP2 is the cause. Using that logic, it is unlikely that SP2 is the problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Also, a google on the error returns hundreds of results.. http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta= Yes, I could have searched more first. And yes, that search does get an abundance of results. However I see no solutions relevant to my problem. Many of the solutions say things such as that the extension is not installed or that MySQL is not installed. Many (close to half I think) of the results are pages that have the error, so the abundance of results indicates it is a prevalent problem that is often not easily solved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mysql_connect does not connect
Andrew Kreps [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tue, 14 Sep 2004 10:11:24 -0700, Sam Hobbs [EMAIL PROTECTED] wrote: Also, are the warning messages documented? As I asked in my original question, is 10061 an error code? 10061 is a generic winsock error for a timeout, it's not PHP or MySQL specific. It means that the call couldn't connect to the socket you were trying to hit within the time allowed. Thank you; that helps. So something that might help is for the PHP message to issue a more specific message indicating the timeout problem. This is just a suggestion for the developers. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
The webpage of coarse, is not local, regardless of where its hosted, so a firewall will come into play when trying to connect. You dont have disable it, i should have been specifc i suppose, you must allow for the mysql port to be open. :) Whats for others to confirm, try it yourself and see if it works. Jason Sam Hobbs [EMAIL PROTECTED] wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Windows XP Firewall, or any other firewall for that matter must be off. Jason Can someone else confirm that this is correct? For one thing, when I use MySQL directly outside of a web page, it works. The sample C program works. For another thing, I doubt very immensely that everyone using mysql_connect does not use a firewall. Even if anyone else does, I will not. It would have been quite unreasonable for the developers of PHP to develop software with that requirement, but I doubt it was. -- 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] mysql_connect does not connect
Sam Your problem probably does stem from the extension not being installed. You say you're using (IIRC) mySQL 4.1 This requires you to use the mysqli extension, not the mysql extension As you're on windows, it's probably just a case of uncommenting the extension=php_mysqli.dll line in your php.ini, but I'm not sure as I don't have much experience configuring PHP for windows. Anyway - as far as I can tell from what you've said, that's likely to be your problem - your timeout is occurring because the mysql extension cannot connect, not because of any firewall issues. From the manual entry on MySQL (http://www.php.net/mysql): This MySQL extension doesn't support full functionality of MySQL versions greater than 4.1.0. For that, use MySQLi. If you then look at the entry for MySQLi (http://www.php.net/mysqli), you'll see this: The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above. Then this page (http://www.php.net/manual/en/install.windows.extensions.php) about installing extension on windows should get you the rest of the way. Cheers Chris Sam Hobbs wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Also, a google on the error returns hundreds of results.. http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta= Yes, I could have searched more first. And yes, that search does get an abundance of results. However I see no solutions relevant to my problem. Many of the solutions say things such as that the extension is not installed or that MySQL is not installed. Many (close to half I think) of the results are pages that have the error, so the abundance of results indicates it is a prevalent problem that is often not easily solved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Also, a google on the error returns hundreds of results.. http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta= One thing I did find in the results is that at least one person had problems using (I think) phpMyAdmin. It supposedly uses mysql_connect. I am not aware of installing phpMyAdmin in my system, so I will try installing and using it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
The firewall I am using is ZoneAlarm, the free version. I am nearly certain that it does not allow specific ports to be opened, at least not for specific addresses. So if this were a requirement, probably many others would have that specific problem. However if nothing else works, I will try to look into this further when I have time. At the moment I must spend time on something else. Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The webpage of coarse, is not local, regardless of where its hosted, so a firewall will come into play when trying to connect. You dont have disable it, i should have been specifc i suppose, you must allow for the mysql port to be open. :) Whats for others to confirm, try it yourself and see if it works. Jason Sam Hobbs [EMAIL PROTECTED] wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Windows XP Firewall, or any other firewall for that matter must be off. Jason Can someone else confirm that this is correct? For one thing, when I use MySQL directly outside of a web page, it works. The sample C program works. For another thing, I doubt very immensely that everyone using mysql_connect does not use a firewall. Even if anyone else does, I will not. It would have been quite unreasonable for the developers of PHP to develop software with that requirement, but I doubt it was. -- 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] mysql_connect does not connect
Jason Davidson wrote: The webpage of coarse, is not local, regardless of where its hosted, so a firewall will come into play when trying to connect. You dont have disable it, i should have been specifc i suppose, you must allow for the mysql port to be open. :) Whats for others to confirm, try it yourself and see if it works. Jason You understanding of how this works is a bit off Jason. If you make a call to one of my web sites from your machine via a browser, the _only_ port I need to have open to the outside is 80 (or whatever port I have my web server running on), even if I make 1000 calls to a local db, but this has nothing to do with how the web server talks to MySQL. What is meant by local here, is that the MySQL db and web server are on the same machine. A firewall comes into play when your web browser requests a page from my web server, but does not come into play when that page has to connect to a local db before sending content to you. Your remote machine never talks to my local MySQL db. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Possible i should have checked your configurations, however, to itterate my point slightly, here is some documentation, you may find it usefull regardless of how you connect to your db. http://dev.mysql.com/doc/mysql/en/Can_not_connect_to_server.html Jason Sam Hobbs [EMAIL PROTECTED] wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Also, a google on the error returns hundreds of results.. http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta= One thing I did find in the results is that at least one person had problems using (I think) phpMyAdmin. It supposedly uses mysql_connect. I am not aware of installing phpMyAdmin in my system, so I will try installing and using it. -- 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] mysql_connect does not connect
ok, well, i just posted a link for you to check out, it gives insight on how mysql connects on different platforms, this will of use to you i think, the last few bullets in the page i linked to are of some importance to your error msg which says, cant connect to localhost, and not, cant connect through socket... again, link,, http://dev.mysql.com/doc/mysql/en/Can_not_connect_to_server.html Jason Sam Hobbs [EMAIL PROTECTED] wrote: The firewall I am using is ZoneAlarm, the free version. I am nearly certain that it does not allow specific ports to be opened, at least not for specific addresses. So if this were a requirement, probably many others would have that specific problem. However if nothing else works, I will try to look into this further when I have time. At the moment I must spend time on something else. Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The webpage of coarse, is not local, regardless of where its hosted, so a firewall will come into play when trying to connect. You dont have disable it, i should have been specifc i suppose, you must allow for the mysql port to be open. :) Whats for others to confirm, try it yourself and see if it works. Jason Sam Hobbs [EMAIL PROTECTED] wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Windows XP Firewall, or any other firewall for that matter must be off. Jason Can someone else confirm that this is correct? For one thing, when I use MySQL directly outside of a web page, it works. The sample C program works. For another thing, I doubt very immensely that everyone using mysql_connect does not use a firewall. Even if anyone else does, I will not. It would have been quite unreasonable for the developers of PHP to develop software with that requirement, but I doubt it was. -- 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: how to load extensions outside the extension_dir
when I did this in a shared hosting environment, I looked at phpinfo() running on the server in question, then changed all values in my new php.ini to be the same as the one on the server. You get most of what you need changed by doing that. Plus its almost always a standard install with shared hosting services (in my experience) so its hard to really mess up. -- -- Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ -- Marten Lehmann [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, You can't, It's a security thing. this doesn't make sense. When PHP is running as CGI, everyone can put it's own php.ini in the same directory as the PHP-script. This will overwrite all settings of the main php.ini. This works as described, but I don't want to put my own php.ini for that, because changes in the master php.ini will not affect my local one, and the changes in the master file might be important. Regards Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Hey, i understand that, :) however, a firewall may restrict _any_ access to a port, and if you are connected thru TCP/IP, then that port may be restricted even if 'local'. It is still a client server relationship regardless where client and server reside. Of coarse, this may not be the issue he is having, but it is an issue i have dealt with before, as retarded as you all seem to think it is. Jason John Nichel [EMAIL PROTECTED] wrote: Jason Davidson wrote: The webpage of coarse, is not local, regardless of where its hosted, so a firewall will come into play when trying to connect. You dont have disable it, i should have been specifc i suppose, you must allow for the mysql port to be open. :) Whats for others to confirm, try it yourself and see if it works. Jason You understanding of how this works is a bit off Jason. If you make a call to one of my web sites from your machine via a browser, the _only_ port I need to have open to the outside is 80 (or whatever port I have my web server running on), even if I make 1000 calls to a local db, but this has nothing to do with how the web server talks to MySQL. What is meant by local here, is that the MySQL db and web server are on the same machine. A firewall comes into play when your web browser requests a page from my web server, but does not come into play when that page has to connect to a local db before sending content to you. Your remote machine never talks to my local MySQL db. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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] mysql_connect does not connect
And for more testimonies, sinse i fear im getting absolutely no credit for having any knowledge of mysql and php.. :P (i say that in jest of coarse) search this in google and see how many people fixed the very problem by disabling or adjusting the firewall. http://www.google.ca/search?hl=enie=UTF-8q=mysql+firewall+localhostbtnG=Searchmeta= Cheers, and good luck Jason Jason Davidson [EMAIL PROTECTED] wrote: ok, well, i just posted a link for you to check out, it gives insight on how mysql connects on different platforms, this will of use to you i think, the last few bullets in the page i linked to are of some importance to your error msg which says, cant connect to localhost, and not, cant connect through socket... again, link,, http://dev.mysql.com/doc/mysql/en/Can_not_connect_to_server.html Jason Sam Hobbs [EMAIL PROTECTED] wrote: The firewall I am using is ZoneAlarm, the free version. I am nearly certain that it does not allow specific ports to be opened, at least not for specific addresses. So if this were a requirement, probably many others would have that specific problem. However if nothing else works, I will try to look into this further when I have time. At the moment I must spend time on something else. Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] The webpage of coarse, is not local, regardless of where its hosted, so a firewall will come into play when trying to connect. You dont have disable it, i should have been specifc i suppose, you must allow for the mysql port to be open. :) Whats for others to confirm, try it yourself and see if it works. Jason Sam Hobbs [EMAIL PROTECTED] wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Windows XP Firewall, or any other firewall for that matter must be off. Jason Can someone else confirm that this is correct? For one thing, when I use MySQL directly outside of a web page, it works. The sample C program works. For another thing, I doubt very immensely that everyone using mysql_connect does not use a firewall. Even if anyone else does, I will not. It would have been quite unreasonable for the developers of PHP to develop software with that requirement, but I doubt it was. -- 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OK ... WHY does this work ?????
This is some experimental code I did to try and find a way to recycle the same query multiple times as efficient as possible. With the purpose of efficiently comparing the results of 2 queries where the resultset from both queries won't match in the size (in this sample test it coincidently does, but I've tried with a variant where it doesn't, and it works just as beautiful). Although it's nice that it actually works like intended, I'm a little baffled to exactly WHY it works (this being why the 2 dimensional array I build actually works like intended). I tried looking through the manual to find how PHP build the associate arrays when no key is specified, but came out empty. So if anyone can explain how this come to function like intended despite immediate logic dictating it shouldn't, I'd really appreciate it ... I hate when I get the code to work, but don't get why it works... This is the code (pieced together from much larger script ... that does lots more than this in between: ?php // global data pull of base configuration $config_query = SELECT setting,value FROM hf_config; $config = mysql_query($config_query) or die('Unable to get base configurationbr'.mysql_error()); while ($config_data = mysql_fetch_array($config)) { if ($config_data['setting'] == 'admin_level') { $lvl_admin = $config_data['value']; } elseif ($config_data['setting'] == 'new_member_level') { $lvl_new = $config_data['value']; } elseif ($config_data['setting'] == 'guest_level') { $lvl_guest = $config_data['value']; } } // load levels and build array $level_query = SELECT levelID,levelname,description FROM hf_levels ORDER BY `levelorder` ASC; $levels = mysql_query($level_query); while ($leveldata = mysql_fetch_array($levels)) { $arrlevels[$leveldata['levelID']] = array('levelname' = $leveldata['levelname'], 'description' = $leveldata['description']); } ? table tr td colspan=3 class=adm_titleGeneral configuration/td /trtr td class=adm_subtitleAdministrator level/td td class=adm_regular?php echo($lvl_admin.' - '.$arrlevels[$lvl_admin]['levelname']); ?/td td/td /trtr td class=adm_subtitleNew member level/td td class=adm_regular?php echo($lvl_new.' - '.$arrlevels[$lvl_new]['levelname']); ?/td /trtr td class=adm_subtitleGuest level/td td class=adm_regular?php echo($lvl_guest.' - '.$arrlevels[$lvl_guest]['levelname']); ?/td /tr /table The query results look like this: mysql SELECT setting,value FROM hf_config; +--+---+ | setting | value | +--+---+ | admin_level | 1 | | new_member_level | 50| | guest_level | 99| +--+---+ 3 rows in set (0.00 sec) mysql SELECT levelID,levelname,description FROM hf_levels ORDER BY `levelorder` ASC; +-++---+ | levelID | levelname | description | +-++---+ | 1 | Admin | System administrators | | 50 | New member | new members | | 99 | Guest | Guest users | +-++---+ 3 rows in set (0.00 sec) Output of the script looks like this: General configuration Administrator level 1 - Admin New member level 50 - New member Guest level 99 - Guest Unless I misunderstand how PHP make unspecified arrays (and I probably do since this works), when you have an array of 3 elements on the first dimenstion like I do, and then ask for $arrlevels[$lvl_guest]['levelname'], which in this case actually means it asks for $arrlevels[99]['levelname'] how come it pick the correct element, and not error out that element 99 don't exist ?? My only conclusion (based on the fact that this actually works) is that PHP makes the key the same as the value if the key isn't specified. But is this actually correct Or is there something going on that I don't know about ??? I've got another sample, that uses the same query recycling method, but with much, much more complex database queries, and it works just as perfectly well I really just wanna understand why this actually work, and how ... it can be rather confusing to stumble across a useful functionality and solution when you're still learning how to do the more complex things in PHP. -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace accents
At 17:51 14-09-2004, Diana Castillo wrote: Anyone know of any function to replace letters with accents with just the regular letter, for instance replace á with a, ç with c, ñ with n ? How about this ??? This is the one I made for this purpose function stripAccents($string) { $returnString = strtr($string, 'àáâãäçèéêëìíîïñòóôõöùúûüýÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ', 'acnosyACNOSY'); $returnString = str_replace('æ','ae',str_replace('Æ','AE',$returnString)); $returnString = str_replace('ø','o',str_replace('Ø','O',$returnString)); $returnString = str_replace('å','a',str_replace('Å','å',$returnString)); $returnString = str_replace('ß','ss',$returnString); $returnString = str_replace('#039;','',str_replace(','',$returnString)); $returnString = str_replace('quot;','',str_replace('','',$returnString)); return $returnString; } obviously there's room for improvement, but it's from a QAD script (not production) -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Of coarse, this may not be the issue he is having, but it is an issue i have dealt with before, as retarded as you all seem to think it is. I lost track of who the original poster was, but anyway... Why not disconnect from the internet, turn off all the firewalls, and then see if it works. If it doesn't then post some error messages and code for what's being tried and failing. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OK ... WHY does this work ?????
On Tue, 14 Sep 2004 22:32:54 +0200, -{ Rene Brehmer }- [EMAIL PROTECTED] wrote: Unless I misunderstand how PHP make unspecified arrays (and I probably do since this works), when you have an array of 3 elements on the first dimenstion like I do, and then ask for $arrlevels[$lvl_guest]['levelname'], which in this case actually means it asks for $arrlevels[99]['levelname'] how come it pick the correct element, and not error out that element 99 don't exist ?? My only conclusion (based on the fact that this actually works) is that PHP makes the key the same as the value if the key isn't specified. But is this actually correct Or is there something going on that I don't know about ??? Yes, that is what's happening, a simple test shows this: #!/usr/bin/php ?php $a = array(1, 2, 3); print_r($a); ? output: Array ( [0] = 1 [1] = 2 [2] = 3 ) -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_connect does not connect
Note that there is a difference between the php_mysqli and the php_mysql extensions. I have both php_mysqli.dll and php_mysql.dll in my PHP501\ext directory, but I don't have the extension=php_mysqli.dll line in my php.ini file. Is that something that should be in the php.ini (with a ; to comment it out) file for php 5.0.1? I will try adding the extension=php_mysqli.dll line in my php.ini file later when I have time. I did not try earlier since the commented version is not in the php.ini file, either commented or uncommented. Chris Dowell [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sam Your problem probably does stem from the extension not being installed. You say you're using (IIRC) mySQL 4.1 This requires you to use the mysqli extension, not the mysql extension As you're on windows, it's probably just a case of uncommenting the extension=php_mysqli.dll line in your php.ini, but I'm not sure as I don't have much experience configuring PHP for windows. Anyway - as far as I can tell from what you've said, that's likely to be your problem - your timeout is occurring because the mysql extension cannot connect, not because of any firewall issues. From the manual entry on MySQL (http://www.php.net/mysql): This MySQL extension doesn't support full functionality of MySQL versions greater than 4.1.0. For that, use MySQLi. If you then look at the entry for MySQLi (http://www.php.net/mysqli), you'll see this: The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above. Then this page (http://www.php.net/manual/en/install.windows.extensions.php) about installing extension on windows should get you the rest of the way. Cheers Chris Sam Hobbs wrote: Jason Davidson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Also, a google on the error returns hundreds of results.. http://www.google.ca/search?hl=enie=UTF-8q=Can%27t+connect+to+++MySQL+server+on+%27localhost%27+%2810061%29btnG=Searchmeta= Yes, I could have searched more first. And yes, that search does get an abundance of results. However I see no solutions relevant to my problem. Many of the solutions say things such as that the extension is not installed or that MySQL is not installed. Many (close to half I think) of the results are pages that have the error, so the abundance of results indicates it is a prevalent problem that is often not easily solved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP to execute hyperlink?
I use an application that has a web browser engine built in and every time I open the app there is some code executing a hyperlink and pulling up a HTML page to a specific place on the page. This action changes according to if it is AM or PM and the date. Example: from 00:00 to 11:59 during the same day you will see the same starting place on the page any time this app is opened. From 12:00 to 23:59 during the same day you will see something different from the AM but it will be the same for the 12 hour time period. The next day the AM section and the PM do the same thing but on a different place on the page. Each day this behavior repeats but each day the place on the page is new. The page that is called has name anchors through out the page. It is these name anchors that are being called on the page. I said all that to ask this. I want to do the same thing using PHP script. Can this be done? I know PHP is server side script. I am not sure which date/time function to use. I assume that if else statements will be needed. I don't know how to get PHP to execute the hyperlink when the page opens. Basically the PHP code would execute something like this: Get the current date and time, find the matching name anchor that reflects the current month and day and if it is AM or PM and then display the correct place on the page. I am still learning PHP so this as been a little more than I can figure out right now. Just trying to figure out how to use all the date time functions is confusing. I do know how to use date() that one was easy to figure out. I don't know if I should be using date() or getdate() If I could figure out the start and end of the script I could probably figure this out. I think the middle with the if else statements will be easy to figure out. Every time I try to figure out these date time functions I get syntax errors. I can't figure out what the PHP manual says about these functions. Any body have any ideas? Thanks, -- Jack The Rhino Gates, Registered Linux user #342662 Morning Star Communications, www.morningstarcom.net Web Hosting, Site Design, Domain Registration, VMware Workstation Software and GSX Server Software -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php/MYSQL remove duplicate records
Hi there - I have an extremely simple table that has a unique Id and an email address. what I am looking for is an example of a PHP script that will poll the MYSQL database and delete the duplicate records leaving only 1 unique (email) record. can someone point me to the right place? thanks! d -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/MYSQL remove duplicate records
you could select out all the DISTINCT email addresses, and delete the table, and repopulate it with your selected rows add a constraint to the table to make email column unique afterwards maybe. Jason Dustin Krysak [EMAIL PROTECTED] wrote: Hi there - I have an extremely simple table that has a unique Id and an email address. what I am looking for is an example of a PHP script that will poll the MYSQL database and delete the duplicate records leaving only 1 unique (email) record. can someone point me to the right place? thanks! d -- 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] something like an SID
I'd like a value to be passed back from every page, if that page was originally passed that value. The two ways that I can think of it, are: 1/ Javascript with some sort of 'onSubmit()' function which causes a minimal form to be submitted via POST or GET 2/ A hidden form value, and make every action on a page be a button, which submits a form as above. If no value was received, it would know it was a first access. NO, I don't think Sessions will do it - I will use this value IN PARALELL to Sessions. NO, I don't think Cookies will do it, since I want the value to be different for each browser instance and each 'TAB' in each browser instance. Someone tell me if I'm on the right track, and point me to a link that shows how to do: My idea 1, My idea 2, or your idea? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session time out
How do sessions 'time out'? Especially if using and SID in the query string (not a good idea, I know, but this bypasses cookie timeout and so removes it from timeout methods for this discussion) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session time out
Hi, Depending on the time out time set in the php.ini, they will expire after that many minutes of inactivity, or when the browser is closed. -Dan Joseph -Original Message- How do sessions 'time out'? Especially if using and SID in the query string (not a good idea, I know, but this bypasses cookie timeout and so removes it from timeout methods for this discussion) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] something like an SID
Dennis Gearon wrote: I'd like a value to be passed back from every page, if that page was originally passed that value. The two ways that I can think of it, are: 1/ Javascript with some sort of 'onSubmit()' function which causes a minimal form to be submitted via POST or GET 2/ A hidden form value, and make every action on a page be a button, which submits a form as above. 3. Define your SID value: $SID = isset($_REQUEST['var_name']) ? 'var_name=' . urlencode($_REQUEST['var_name']) : ''; Write every link as href=page.php??php echo $SID; ? Something similar for forms. If no value was received, it would know it was a first access. NO, I don't think Sessions will do it - I will use this value IN PARALELL to Sessions. NO, I don't think Cookies will do it, since I want the value to be different for each browser instance and each 'TAB' in each browser instance. You will fail. User can use right click to open any link in a new window and the value will stay the same. Someone tell me if I'm on the right track, and point me to a link that shows how to do: My idea 1, My idea 2, or your idea? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image question
PHP's creating an image and I'm trying to store it into MySQL. Instead of raw binary data, all I'm getting is a resource reference. To test this and keep things as simple as possible, I took and created an image with createimagefromjpeg. Here's some example code of what I'm talking about: $url = http://mysite.com/picture.jpg;; $im = imagecreatefromjpeg($url); Imagejpeg($im); // successfully displays image I'm assuming that $im contains the binary data for the picture and I'd expect to get raw binary output from: echo $im; But I don't... I get reference #22 instead. How would I go about accessing the raw data in order to store it into the database successfully? Do I need to know anything special about pulling it back out and storing it in a variable? Side note: I know that storing images in a database isn't generally optimal. I've chosen this route because performance isn't an issue and ease of tracking tens of thousands of images is important. Thanks, Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image question
On Wednesday 15 September 2004 08:05, Ed Lazor wrote: PHP's creating an image and I'm trying to store it into MySQL. Instead of raw binary data, all I'm getting is a resource reference. To test this and keep things as simple as possible, I took and created an image with createimagefromjpeg. Here's some example code of what I'm talking about: Imagejpeg($im); // successfully displays image Use the ob_*() functions to capture the output. See archives for details. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* ... the Mayo Clinic, named after its founder, Dr. Ted Clinic ... -- Dave Barry */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reminder or answer to check if remote page is linking to you
I have been searching the archives for the past 2 hours without luck, I am looking for an older thread which was discussed on how to connect to a remote page and check if that page was linking back to blah.com, I think it was done via fopen. If you can tell me either, 1. the name of that thread or its url 2. how to do the above check I would really appreciate it. $page = file_get_contents('http://example.org/page.html'); Now use the string functions to search $page for a href back to your site. Not foolproof, but then nothing is. ---John Holmes... Hello John, Thanx for replying. I figured the part that you sent me by myself, but I dont know the regex/string functions used to read the href...any ideas? Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Image question
Got it. Thanks Jason. -Original Message- Imagejpeg($im); // successfully displays image Use the ob_*() functions to capture the output. See archives for details. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Security - Semi OT
Hello All, I am in the process of wrapping up a site for a friend of mine. It has logins, searching, account information, etc. I am wondering, does anyone on the list do any security auditing on the side? Chris, maybe you? I figured the best way to tighten it up is to have an outsider check thru it. I'm basically looking for some quotes so I can present them to my friend. Let me know. -Dan Joseph
RE: [PHP] Image question
Oop... spoke too soon. I was able to store the image into the database, but now I can't pull it back out and manipulate it with the gd image functions. Instead of using the imagejpeg function, I can just echo the field and the image will display in a browser window. How do I restore the data from the database in a way that I can continue to manipulate it with the image functions, like imagejpeg($data)? Thanks, Ed -Original Message- From: Ed Lazor [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 14, 2004 5:20 PM To: 'Jason Wong'; [EMAIL PROTECTED] Subject: RE: [PHP] Image question Got it. Thanks Jason. -Original Message- Imagejpeg($im); // successfully displays image Use the ob_*() functions to capture the output. See archives for details. -- 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] Capturing an Image of a web page
Has anyone run across a tool available to PHP that can render an image of a entire webpage from a URL, so that it can be reduced to a thumbnail and stored in a database? Warren Vail
Re: [PHP] something like an SID
You make a good point, Marek. They CAN open a new window with different results. Maybe it's up to each page to keep track of where it is at, via form elements alone, instead of through session values. Hadn't thought of that, but it must be the only way. Adding and extra layer to that might end up being really confusing to programmers for my site. The values for previous forms could just be sent as hidden elements(and not kept in the session), until the whole thing is collected, then they are all qualified again. The only thing in the session would be the user's id. Marek Kilimajer wrote: Dennis Gearon wrote: I'd like a value to be passed back from every page, if that page was originally passed that value. The two ways that I can think of it, are: 1/ Javascript with some sort of 'onSubmit()' function which causes a minimal form to be submitted via POST or GET 2/ A hidden form value, and make every action on a page be a button, which submits a form as above. 3. Define your SID value: $SID = isset($_REQUEST['var_name']) ? 'var_name=' . urlencode($_REQUEST['var_name']) : ''; Write every link as href=page.php??php echo $SID; ? Something similar for forms. If no value was received, it would know it was a first access. NO, I don't think Sessions will do it - I will use this value IN PARALELL to Sessions. NO, I don't think Cookies will do it, since I want the value to be different for each browser instance and each 'TAB' in each browser instance. You will fail. User can use right click to open any link in a new window and the value will stay the same. Someone tell me if I'm on the right track, and point me to a link that shows how to do: My idea 1, My idea 2, or your idea? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Security - Semi OT
--- Dan Joseph [EMAIL PROTECTED] wrote: I am in the process of wrapping up a site for a friend of mine. It has logins, searching, account information, etc. I am wondering, does anyone on the list do any security auditing on the side? Chris, maybe you? Yes, but I might not be a good choice, because: 1. I'm pretty booked until mid to late October. 2. I value my time, so I'm not cheap. :-) Do you have any friends who know PHP? Peer reviews are always a good idea, regardless of whether your peers are security experts. There's a lot of information on PHP security readily available on the Web - I've been trying to provide as much as I can, including the PHP Security Workbook: http://shiflett.org/php-security.pdf You can get a few peers to educate themselves prior to review. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming December 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Capturing an Image of a web page
On Tue, 2004-09-14 at 17:45, Vail, Warren wrote: Has anyone run across a tool available to PHP that can render an image of a entire webpage from a URL, so that it can be reduced to a thumbnail and stored in a database? Warren Vail This would require that PHP act as a web browser..which it doesn't do. I've seen things like this before..but I believe they are using real browsers to do this.. perhaps looking into building a way to connect to the mozilla api or something... don't think PHP is going to be much help with you for this one. -Robby -- /*** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting Development / signature.asc Description: This is a digitally signed message part
Re: [PHP] Capturing an Image of a web page
Vail, Warren wrote: Has anyone run across a tool available to PHP that can render an image of a entire webpage from a URL, so that it can be reduced to a thumbnail and stored in a database? Warren Vail nothing is impossible but you will be really really hard pressed to do that. Try java instead. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Displaying a pdf inline
After reading the online documentation, it appears that I should be using the following code, however it does not appear to work. Are there some obvious errors? if ($row) { $pdf_file = $row-CLM_IMG_FILE; $msg = $pdf_file; $SRC_FILE = /tmp/ . $pdf_file; $download_size = filesize($SRC_FILE); $filename = basename($SRC_FILE); //print(Filename: . $filename . br); //print(SRC_FILE: . $SRC_FILE . br); //print(Size: . $download_size . br); header(Content-Type: application/pdf); header(Content-Disposition: inline; filename=image.pdf); //header(Content-Disposition: attachment; filename=image.pdf); header(Content-Length: $download_size); header(Connection: close); readfile($SRC_FILE); } else { $msg = Cannot find the claim; } Todd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying a pdf inline
* Thus wrote Todd Cary: After reading the online documentation, it appears that I should be using the following code, however it does not appear to work. Are there some obvious errors? ... header(Content-Type: application/pdf); header(Content-Disposition: inline; filename=image.pdf); //header(Content-Disposition: attachment; filename=image.pdf); header(Content-Length: $download_size); header(Connection: close); The problem comes down to how the client is configured to display a pdf file. IIRC, inline doesn't force the browser to display it within the browser, it all depends on the content-type, and if a plugin is suppose to load within the browser at that point. If you search the archives, your answer may be revealed :) Curt -- The above comments may offend you. flame at will. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying a pdf inline
Curt - Thank you for the quick response. The file is being sent and the PDF reader does try to open it, but it is corrupted. When I change the Disposition to header(Content-Disposition: attachment; filename=image.pdf) and save the file, it cannot be opened do to errors within the file. Yet, the file can be opened on the server. Am I missing something simple here? Todd Curt Zirzow wrote: * Thus wrote Todd Cary: After reading the online documentation, it appears that I should be using the following code, however it does not appear to work. Are there some obvious errors? ... header(Content-Type: application/pdf); header(Content-Disposition: inline; filename=image.pdf); //header(Content-Disposition: attachment; filename=image.pdf); header(Content-Length: $download_size); header(Connection: close); The problem comes down to how the client is configured to display a pdf file. IIRC, inline doesn't force the browser to display it within the browser, it all depends on the content-type, and if a plugin is suppose to load within the browser at that point. If you search the archives, your answer may be revealed :) Curt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Displaying a pdf inline
* Thus wrote Todd Cary: Curt - Thank you for the quick response. The file is being sent and the PDF reader does try to open it, but it is corrupted. When I change the Disposition to header(Content-Disposition: attachment; filename=image.pdf) and save the file, it cannot be opened do to errors within the file. Yet, the file can be opened on the server. Am I missing something simple here? One thing to do is look at the actual contents of the file. You may see a PHP_NOTICE, or PHP_WARNING there, which will make the file appear corrupt to the pdf reader. Curt -- The above comments may offend you. flame at will. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Display data's from sql file
Hello, I have written a small code for retrieving the contents from the mysql database and display from the user. While display in the browser it is displaying some other contents from the previous row and appending with the original contents. If i give the same query in the mysql prompt that time it is showing the original content. While viewing through the browser this error is coming. Is there any where i am wrong ? Regards, Uma -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php - no results - display other message
Hi there... I have a simple search page (mysql database), and I can get it to display the results no issues, but i was wondering how I could display a message stating there were no results, instead of just having the field blank. I am familiar with IF and ELSE statements, but I am not sure how to test the no result option from the results of a SQL query thanks! d -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Capturing an Image of a web page
On Tue, 14 Sep 2004 17:45:07 -0700, Vail, Warren [EMAIL PROTECTED] wrote: Has anyone run across a tool available to PHP that can render an image of a entire webpage from a URL, so that it can be reduced to a thumbnail and stored in a database? Warren Vail I suppose you could write a complete website rendering engine in php... but the usual method is to just run the browser on the comp, open the page, and take a SS. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php - no results - display other message
Dustin Krysak wrote: Hi there... I have a simple search page (mysql database), and I can get it to display the results no issues, but i was wondering how I could display a message stating there were no results, instead of just having the field blank. I am familiar with IF and ELSE statements, but I am not sure how to test the no result option from the results of a SQL query Count the results from the search, maybe with http://us2.php.net/manual/en/function.mysql-num-rows.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nevermind ... Re: OK ... WHY does this work ?????
OK, obviously I wasn't awake last night ... figured out what I was actually doing here ... specifying the index for the 2nd array instead of the value in the first ... *sigh* *blushes* ... how do you say tanketorsk in English ??? anyway, sorry for wasting bandwidth, I'll go hide in the corner now :P At 06:46 15-09-2004, -{ Rene Brehmer }- wrote: This is some experimental code I did to try and find a way to recycle the same query multiple times as efficient as possible. With the purpose of efficiently comparing the results of 2 queries where the resultset from both queries won't match in the size (in this sample test it coincidently does, but I've tried with a variant where it doesn't, and it works just as beautiful). Although it's nice that it actually works like intended, I'm a little baffled to exactly WHY it works (this being why the 2 dimensional array I build actually works like intended). I tried looking through the manual to find how PHP build the associate arrays when no key is specified, but came out empty. So if anyone can explain how this come to function like intended despite immediate logic dictating it shouldn't, I'd really appreciate it ... I hate when I get the code to work, but don't get why it works... This is the code (pieced together from much larger script ... that does lots more than this in between: ?php // global data pull of base configuration $config_query = SELECT setting,value FROM hf_config; $config = mysql_query($config_query) or die('Unable to get base configurationbr'.mysql_error()); while ($config_data = mysql_fetch_array($config)) { if ($config_data['setting'] == 'admin_level') { $lvl_admin = $config_data['value']; } elseif ($config_data['setting'] == 'new_member_level') { $lvl_new = $config_data['value']; } elseif ($config_data['setting'] == 'guest_level') { $lvl_guest = $config_data['value']; } } // load levels and build array $level_query = SELECT levelID,levelname,description FROM hf_levels ORDER BY `levelorder` ASC; $levels = mysql_query($level_query); while ($leveldata = mysql_fetch_array($levels)) { $arrlevels[$leveldata['levelID']] = array('levelname' = $leveldata['levelname'], 'description' = $leveldata['description']); } ? table tr td colspan=3 class=adm_titleGeneral configuration/td /trtr td class=adm_subtitleAdministrator level/td td class=adm_regular?php echo($lvl_admin.' - '.$arrlevels[$lvl_admin]['levelname']); ?/td td/td /trtr td class=adm_subtitleNew member level/td td class=adm_regular?php echo($lvl_new.' - '.$arrlevels[$lvl_new]['levelname']); ?/td /trtr td class=adm_subtitleGuest level/td td class=adm_regular?php echo($lvl_guest.' - '.$arrlevels[$lvl_guest]['levelname']); ?/td /tr /table The query results look like this: mysql SELECT setting,value FROM hf_config; +--+---+ | setting | value | +--+---+ | admin_level | 1 | | new_member_level | 50| | guest_level | 99| +--+---+ 3 rows in set (0.00 sec) mysql SELECT levelID,levelname,description FROM hf_levels ORDER BY `levelorder` ASC; +-++---+ | levelID | levelname | description | +-++---+ | 1 | Admin | System administrators | | 50 | New member | new members | | 99 | Guest | Guest users | +-++---+ 3 rows in set (0.00 sec) Output of the script looks like this: General configuration Administrator level 1 - Admin New member level 50 - New member Guest level 99 - Guest Unless I misunderstand how PHP make unspecified arrays (and I probably do since this works), when you have an array of 3 elements on the first dimenstion like I do, and then ask for $arrlevels[$lvl_guest]['levelname'], which in this case actually means it asks for $arrlevels[99]['levelname'] how come it pick the correct element, and not error out that element 99 don't exist ?? My only conclusion (based on the fact that this actually works) is that PHP makes the key the same as the value if the key isn't specified. But is this actually correct Or is there something going on that I don't know about ??? I've got another sample, that uses the same query recycling method, but with much, much more complex database queries, and it works just as perfectly well I really just wanna understand why this actually work, and how ... it can be rather confusing to stumble across a useful functionality and solution when you're still learning how to do the more complex things in PHP. -- Rene Brehmer aka Metalbunny If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? http://metalbunny.net/ References, tools, and other useful stuff... Check
Re: [PHP] Display data's from sql file
T UmaShankari wrote: Hello, I have written a small code for retrieving the contents from the mysql database and display from the user. While display in the browser it is displaying some other contents from the previous row and appending with the original contents. If i give the same query in the mysql prompt that time it is showing the original content. While viewing through the browser this error is coming. Is there any where i am wrong ? it's pretty hard to tell with out knowing what your code looks like. Please post the most relevent section of the code. Regards, Uma -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 128 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Nevermind ... Re: OK ... WHY does this work ?????
* Thus wrote -{ Rene Brehmer }-: OK, obviously I wasn't awake last night ... figured out what I was actually doing here ... specifying the index for the 2nd array instead of the value in the first ... *sigh* *blushes* ... how do you say tanketorsk in English ??? scheißen or geschissen!! :) Curt -- The above comments may offend you. flame at will. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php