[PHP] Hope any body can fix this!!!
Hi.. I made the following PHP script.. And every time I try it, it shows an error message... I think there is a wrong with ($LogoutTime - $RightLoginTime'). So please try to fix the error.. What I want to do is to insert a logout time and if (LogoutTime - LoginTime = 20) for example.. then make the field LessonNumber = Its value + 1 (2 + 1 = 3 for example) This is the script :- ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = INSERT INTO accounts (Distance) ('$LogoutTime - $RightLoginTime'); $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? Waiting your replies.. Best regards..
[PHP] Re: Hope any body can fix this!!!
Radwan Aladdin wrote: ... I think there is a wrong with ($LogoutTime - $RightLoginTime'). So please try to fix the error.. ... $query4 = INSERT INTO accounts (Distance) ('$LogoutTime - $RightLoginTime'); This line should be: $query4 = INSERT INTO accounts (Distance) VALUES ('$LogoutTime - $RightLoginTime'); Hope that helps. :) -- Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] naming a directory after a user-submitted string
Here's another question, possibly easier. Possibly even bone-headed. What kind of checking/filtering/changing do I need to do on a user-submitted string before I can feel comfortable using it to name a new directory in the web root on Linux/Apache? Anybody have a quick Regular Expression they can toss at me? If so, I'd be muchly appreciative. Or is this just a Terrible Idea That Should Never Be Contemplated? A file or directory name in Unix can contain any character, except a slash. On mac OS, you also can't use a colon because that was the old mac way of delimiting directories. I imagine windows has a similar restriction on the backslash. I think it has to be less than 256 characters as well, but I may be remembering that incorrectly... Permissively, you could try: substr(preg_replace('/[\/\:\\]/', '_', $dirname), 0, 256) Though you may also want to be strict, and remove all non-word characters, i.e. letters, digits, slash and underscore: substr(preg_replace('/\W/', '_', $dirname), 0, 256) ...that will eliminate special case checks for ., .., and .*. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] CGI Error -- need some ideas
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. I am getting this error and I can't figure out what is causing the problem. If I hit refresh on the broswer, the page loads just fine. Any ideas??? Thanks, Dale NOTE: RUNNING IIS 6.0 WITH MSSQL 2000 ON NEW DELL SERVER -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cacheing data form PHP script
Hi all, I use a HTML menu that is created from multiple database queries. This is powerfull and very extendable. The problem is that the queries have to be executed on every new page or request. Moreover, the menu won't change very often for the users. So I would like to 'cache' the HTML code that is generated. If one admin add/remove/update one menu, I need to clear the cache. At the moment, I store the HTML code to display the menu in the $_SESSION['menu_cache']['menu_id'] var. And this works well! The pages are displayed faster when the menu is in the cache, which is the expected result! What is your opinion about this? Do you see any other way to 'cache' some content? Could I use the $_ENV variable (or any other) to cache the menus accross ALL visitors/users? Thank you Vincent
[PHP] Re: Cacheing data form PHP script
Vincent Dupont [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, At the moment, I store the HTML code to display the menu in the $_SESSION['menu_cache']['menu_id'] var. And this works well! The pages are displayed faster when the menu is in the cache, which is the expected result! What is your opinion about this? Do you see any other way to 'cache' some content? Could I use the $_ENV variable (or any other) to cache the menus accross ALL visitors/users? It depends if your menu is unique per user, or it is the same for all users. If it is unique for each user, than storing it i session makes sense. If not than you can store it in some file or table in the db. Beeing in one place would make it easier to invalidate the cache since you would not need to poke around all sessions. rush -- http://www.templatetamer.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PEAR] Re: Cacheing data form PHP script
On Wed, 28 Jan 2004 10:26:09 +0100 rush [EMAIL PROTECTED] wrote: Do you see any other way to 'cache' some content? Take a look at pear::cache or pear::cache_lite and pearweb. pearweb use cache_lite to cache whole pages (when possible). To cache part of a page (or whatever). pear::cache is maybe easier to cache function calls (ie the function that generates the menu). But cache_mite is damn fast and can work with function calls too. See the support page on pearweb, there is links to tutorials. It depends if your menu is unique per user, or it is the same for all users. If it is unique for each user, than storing it i session makes sense. If not than you can store it in some file or table in the db. Cache in db? sounds not that good :) Beeing in one place would make it easier to invalidate the cache since you would not need to poke around all sessions. That is how cache* work. pierre ps: Rush can you use quotes in reply? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] [posibleOT] Forcing entering te site thru index.php
The only other way I can think of doing this without sessions is to use $_SERVER['HTTP_REFERER'] to check if page request is coming from an existing page within your site or not. But I don't think this method will work 100% of times. Another approach would probably be to use single entry point controller model meaning, all pages are served by index.php. Still not sure as to how you can do this without sessions but you might want to look at frameworks like php.MVC or Fusebox that use the controller model http://www.phpmvc.net/ http://php-fusebox.sourceforge.net/ Hope this helps. -Original Message- From: Fernando M. Maresca [mailto:[EMAIL PROTECTED] Sent: Sunday, December 21, 2003 10:57 AM To: [EMAIL PROTECTED] Subject: [PHP] [posibleOT] Forcing entering te site thru index.php Hello everybody. Well, i'm trying to avoid access to the site for the middle. Say there is a initial page with a form and other pages that depends on this. Is there a way to force users access the site thru the initial form page, regardless of the url? Something like this: lynx http://mysite/forma2.php/ produce the browser to redirect to http://mysite/index.php/ Of course, the forma2.php must be served if its accesed after index.php. Thanks -- Fernando M. Maresca Cel: (54) 221 15 502 3938 Cel: 0221-15-502-3938 -- 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] Using unset with $_SESSION
On 27 January 2004 15:52, [EMAIL PROTECTED] wrote: I am trying to find a reliable method to clean out all session variables and start clean. Running PHP 4.3.1 on Win2K developing a web app to run on Linux. Session cookies are enabled, register globals is off. I access all session variables with $_SESSION. What I have found is that if I use unset($_SESSION), set a single variable, and redirect, the OLD session data is passed to the new page. However if I use session_unset() or $_SESSION = array() and set my single variable, the data is passed properly. Shouldn't unset($_SESSION) work? No. The following Caution appears in the manual (at http://www.php.net/manual/en/ref.session.php#session.examples): Caution Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, 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] Using unset with $_SESSION
On 27 January 2004 16:20, [EMAIL PROTECTED] wrote: On 27 Jan 2004 Stuart wrote: In that case, try this... foreach (array_keys($_SESSION) as $key) unset($_SESSION[$key]); Yes, I had tried that but forgot to mention it. It does work. However, I'm still mystified as to why unset($_SESSION) not only doesn't remove old data from the sesison file when the script exits, but prevents the new variable I create after that from being saved. Perhaps $_SESSION as created by PHP is special and is tied to the session storage, whereas if it is destroyed with unset and then recreated that link is lost. That would explain the behavior. Yes, that is exactly the case. You might like to take a look at session_write_close() (http://www.php.net/session-write-close) in addition to the other recommendations. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, 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
[PHP] Re: [PEAR] Re: Cacheing data form PHP script
Pierre-Alain Joye [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ps: Rush can you use quotes in reply? until this morning I was pretty certain that I can, however this last reply and OE proved me wrong :) rush -- http://www.templatetamer.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] naming a directory after a user-submitted string
Mike Joey, et al -- ...and then Mike Migurski said... % % What kind of checking/filtering/changing do I need to do on a % user-submitted string before I can feel comfortable using it to name a ... % appreciative. Or is this just a Terrible Idea That Should Never Be % Contemplated? In general, I'd say the latter, but I'm a little harsh :-) % % A file or directory name in Unix can contain any character, except a Note, however, that allowing many of these characters will cause you no end of headaches. % slash. On mac OS, you also can't use a colon because that was the old mac % way of delimiting directories. I imagine windows has a similar restriction % on the backslash. I think it has to be less than 256 characters as well, Windows has numerous restrictions, both on characters allowed anywhere and special names. The only special characters I would allow are '@.' (in case you're naming after email addresses) and the fairly common '_-' (polite word separators to help your users) which gives us a-z A-Z 0-9 @._- I don't really see a need for a comma, though that could be included as well. Anything else is likely to mess you up when trying to handle it (just try to print a text input box whose value is O'Banion said come! or such and have it show up in the browser...). I'm also the type who will kick back an error rather than trying to reformat the string, either in order to get rid of bad chars or to make something unique in the event of a collision. Thus, a simple if ( preg_match('/[EMAIL PROTECTED]/',$string) || file_exists($string) ) { puke() ; } could work nicely. HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
RE: [PHP] Tip For The Day
[snip] Its all good, it's like inline braces versus dropped braces and every other coding style debate :) There's no winner. pfft. Inline braces wins hands down ;p It's on now. Somebody set up the ring for the cage match. Last brace standing at the end wins. ;) [/snip] I think that you meant to its already been broughten!, didn't you? Did you know that you will find that bracing style has been debated since the days of FORTRAN? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] naming a directory after a user-submitted string
On 28-Jan-2004 Joey Manley wrote: Here's another question, possibly easier. Possibly even bone-headed. What kind of checking/filtering/changing do I need to do on a user-submitted string before I can feel comfortable using it to name a new directory in the web root on Linux/Apache? Anybody have a quick Regular Expression they can toss at me? If so, I'd be muchly appreciative. Or is this just a Terrible Idea That Should Never Be Contemplated? 1. Please don't hijack threads. 2. Make everything dodgy into a directory delimiter and get the last bit of the path (untested code ahead) : // cleanup $unsafe=preg_replace('[^\w]', '/', $unsafe); // get trailing dirname (explode and pop would work also) $dir = substr(strrchr($unsafe, /), 1); Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] addslashes stripslashes
Im a little confused with these functions. How I here you ask. Well I thought I understood what they were for: Escaping characters that might cause a problem when you enter your data into a database query. i.e. \ Anyway what is confusing me is, say I have a string which contains an e.g: thats mine. I would use addslashes so that the query wouldnt upset mysql when it is entered. Viewing the data entry via phpmyadmin the data is displayed as: thats mine (not: that\s mine) Meaning that when I extract the data from the database I need to use stripslashes returning the string to: thats mine. (I thought that perhaps phpmyadmin striped the slashes when displaying the data.) However recently I encrypted some data which I stored in the database. The string contained a \ which I added slashes to when entered in to the database. But as the database appears to strips the first slash off the double slash automatically. Upon retrieving the data and strip the slashes off it, my data is now corrupt as there werent double slashes it was just a single (like it was supposed to be) and that got removed by the function instead of the extra one. As I havent had any data that contains a \ in it before Ive never noticed its not made any difference before. So Does this basically mean that there is no point using stripslashes on the data you extract from the database. Or am I just being an idiot J Thanks Will I've stopped 46,346 spam messages. You can too! One month FREE spam protection at www.cloudmark.com
Re: [PHP] addslashes stripslashes
Will wrote: I'm a little confused with these functions. How I here you ask. Well I thought I understood what they were for: Escaping characters that might cause a problem when you enter your data into a database query. i.e. \ ' Anyway what is confusing me is, say I have a string which contains an ' e.g: that's mine. I would use addslashes so that the query wouldn't upset mysql when it is entered. Viewing the data entry via phpmyadmin the data is displayed as: that's mine (not: that\'s mine) Meaning that when I extract the data from the database I need to use stripslashes returning the string to: that's mine. (I thought that perhaps phpmyadmin striped the slashes when displaying the data.) However recently I encrypted some data which I stored in the database. The string contained a \ which I added slashes to when entered in to the database. But as the database appears to strips the first slash off the double slash automatically. Upon retrieving the data and strip the slashes off it, my data is now corrupt as there weren't double slashes it was just a single (like it was supposed to be) and that got removed by the function instead of the extra one. As I haven't had any data that contains a \ in it before I've never noticed it's not made any difference before. So Does this basically mean that there is no point using stripslashes on the data you extract from the database. True. that's mine is already stored in the database as that's mine (w/o the backslash), and the database returns this. If you have magic_quotes_runtime on, php will run addslashes on the database output, but it's usualy off. Remember that the backslashes are to escape characters with special meaning (such as end of a string), but are not part of the actual string. They simply say the next character should be treated literaly. Or am I just being an idiot :-) Thanks Will _ I've stopped 46,346 spam messages. You can too! One month FREE spam protection at www.cloudmark.com http://www.cloudmark.com/spamnet?v1 http://www.cloudmark.com/spamnet?v1 Cloudmark SpamNet - Join the fight against spam! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP EDITORS
Great and it's free. http://phpedit.net John Jensen wrote: Hello everyone. I am new to PhP and MySQL. I was wondering what a good (Or Free) Php Editor is? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] addslashes stripslashes
Hello Will, On 28 Jan 2004 at 12:31, Will wrote: However recently I encrypted some data which I stored in the database. The string contained a \ which I added slashes to when entered in to the database. But as the database appears to strips the first slash off the double slash automatically. Upon retrieving the data and strip the slashes off it, my data is now corrupt as there werent double slashes it was just a single (like it was supposed to be) and that got removed by the function instead of the extra one. Just adding to Marek's response in an attempt to make things clearer for you. I think what's bothering you is the fact that you don't see the backslashes added by addslashes in the strings stored in the database. Well, that's because they are *not* actually added to the strings; they simply tell the database to treat whatever character comes after them (them = the backslashes) as regular text, not as symbols with special meanings (such as quotes, which MySQL would normally sees as string delimiters, not actual quotes in a string of text). Since no backslashes have actually been added to the strings stored in the database, you don't need to (or, rather, should not) use stripslashes when retrieving the strings from the db. By the way, consider using mysql_escape_string or mysql_real_escape_string instead of addslashes; consult the PHP manual for more info on these functions. Cheers, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Googlebot
from google http://www.google.com/webmasters/facts.html Fiction: Sites are not included in Google's index if they use ASP (or some other non-html file-type.) Fact: At Google, we are able to index most types of pages and files with very few exceptions. File types we are able to index include: pdf, asp, jsp, hdml, shtml, xml, cfm, doc, xls, ppt, rtf, wks, lwp, wri. I notice php is not mentioned in this list, surely it can index php generated pages ?? Thanks, Jon jon bennett | [EMAIL PROTECTED] new media creative _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ iChat (AIM): jbendotnet On 27 Jan 2004, at 14:53, Ben Ramsey wrote: Perhaps this link will help: http://www.google.com/webmasters/ Frank Tudor wrote: That's not very helpful. I am also curious about this. Anyone have a more thought provoking answer? Frank --- Raditha Dissanayake [EMAIL PROTECTED] wrote: If you read the pages on google you will know the answer. Hartley, Matt wrote: Is Googlebot (or any other bot) able to follow links that are php? e.g. a href=Contact.phpContact Us/a a href=Product.phpimg src=Images/product.jpg width=110 height=111 border=0/a Is there a way to invite bots to your site? Thanks Matt -- 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 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- 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] Using unset with $_SESSION
Shouldn't unset($_SESSION) work? No. The following Caution appears in the manual (at http://www.php.net/manual/en/ref.session.php#session.examples): Caution Do NOT unset the whole $_SESSION with unset($_SESSION) as this will disable the registering of session variables through the $_SESSION superglobal. Thanks -- I have to say I missed that one! Thanks for noting session_write_close() as well. I did try that, but it didn't seem to offer any advantages over letting the script write the data on exit. -- Tom Rawson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Googlebot
is that it tends to avoid or downgrade URI's with parameters tacked onto the end. Does that go for internal links in your site then ??? news.php?start=10 etc ??? Could be tricky writing dyamic pages then. Thanks, Jon jon bennett | [EMAIL PROTECTED] new media creative _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ iChat (AIM): jbendotnet On 28 Jan 2004, at 01:05, Mike Migurski wrote: Is Googlebot (or any other bot) able to follow links that are php? As others have already pointed out to you, what better place to find information about google than google? That, or your server logs - googlebot is great about identifying itself. RTFM's aside, a little understanding of how HTTP request-response loop goes a long way. There's no reason why google (or any other bot) shouldn't be capable of making a GET request for a *.php resource. My understanding is that it tends to avoid or downgrade URI's with parameters tacked onto the end. - michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- 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] PHP EDITORS
Hello John, On 28 Jan 2004 at 0:10, John Jensen wrote: Hello everyone. I am new to PhP and MySQL. I was wondering what a good (Or Free) Php Editor is? If you want something nice and simple to start with, try WinSyntax (http://www.winsyntax.com). If you want a very nice and configurable editor that has loads of great plugins for other technologies (such as XML/XSLT), go straight to jEdit (http://www.jedit.org). If you want a nice IDE with lots of menus and helpers, try either PHPEdit (http://www.phpedit.org) or Maguma Studio (http://www.maguma.com/products.php?article=free). My suggestion is that you download them all, have a go at each one and keep the one you find more intuitive and feel most comfortable with. Good luck, Erik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Googlebot
Jon Bennett wrote: is that it tends to avoid or downgrade URI's with parameters tacked onto the end. Does that go for internal links in your site then ??? news.php?start=10 etc ??? Could be tricky writing dyamic pages then. Some spiders will not visit URLs with query strings, some will. Those that will generally put a limit on the number of links they will visit of that nature on a particular site to prevent it from following possibly infinite combinations. As stated in http://www.google.com/webmasters/2.html#A1... We are able to index dynamically generated pages. However, because our web crawler can easily overwhelm and crash sites serving dynamic content, we limit the amount of dynamic pages we index. Nice the way they say it's to help you not them :). As far as your tricky comment goes, dynamic content does not have to look like dynamic content. Check the archives for info on how to get rid of query strings from your site. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unix-Apache: running apache as different user
Mike Migurski [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have PHP installed on Apache and Unix with several vhosts so each vhost has its own user account on Unix. Now when accessing a webpage, Apache runs with user httpd.. but I want it to run as the user of the vhost account.. How can I do that? http://httpd.apache.org/docs/suexec.html The SuEXEC is not good for my purpose, since I want to run PHP as Apache Module (and not CGI). I'm using Apache 1.3... does the User / Group directives change the user/group in case I use Apache Module for PHP? Also, I read about the AssignUserID directive, but couldn't figure out if it affects Apache Module or only CGI module for PHP? thanks in advance -Lorderon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] amp
is there any function that will always replace a with a amp in a string? -- -- Diana Castillo Global Reservas, S.L. C/Granvia 22 dcdo 4-dcha 28013 Madrid-Spain Tel : 00-34-913604039 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] Problem with mcrypt_encrypt and mcrypt_decrypt.
Hi all, i'm trying to crypt and decrypt password with the code below but i get many warnings Warning: mcrypt_get_iv_size(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 36 Warning: mcrypt_create_iv(): Can not create an IV with size 0 or smaller in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 37 Warning: mcrypt_decrypt(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 38 and i don't understand why, any help is appreciated. Code is below. This code is in a script //Start crypt $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $key=genera();// genera() function for rand number $emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); $emailcifrata=$key.$emailcifrata; // End crypt This code is in another script that isn't the same script of previous //Start decrypt $emailcifrata=fgets($fp); $lunghezza_str=strlen($emailcifrata); $emailcifrata=substr($emailcifrata,10); $key=substr($emailcifrata,0,($lunghezza_str-10)); $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); // End decrypt Thanks in advance.
Re: [PHP] amp
Diana -- ...and then Diana Castillo said... % % is there any function that will always replace a with a amp in a % string? You are looking for a function ... A function that will replace an HTML special character ... A PHP function to do this. I shall consult the Great Programmer. Something is coming to me ... I see a function ... It's ... It's ... It's in the manual! [HINT: look for 'special character' since you clearly didn't look for 'amp', which would do about as well.] HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
RE: [PHP] amp
str_replace(, amp, $text); -Original Message- From: Diana Castillo [mailto:[EMAIL PROTECTED] Sent: January 28, 2004 9:27 AM To: [EMAIL PROTECTED] Subject: [PHP] amp is there any function that will always replace a with a amp in a string? -- -- Diana Castillo Global Reservas, S.L. C/Granvia 22 dcdo 4-dcha 28013 Madrid-Spain Tel : 00-34-913604039 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
Diana Castillo wrote: is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SV: [PHP] amp
Htmlspecialchars() should do it :) http://www.php.net/manual/en/function.htmlspecialchars.php - anders -Opprinnelig melding- Fra: Diana Castillo [mailto:[EMAIL PROTECTED] Sendt: 28. januar 2004 15:27 Til: [EMAIL PROTECTED] Emne: [PHP] amp is there any function that will always replace a with a amp in a string? -- -- Diana Castillo Global Reservas, S.L. C/Granvia 22 dcdo 4-dcha 28013 Madrid-Spain Tel : 00-34-913604039 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
Stuart wrote: Diana Castillo wrote: is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); Forgot to mention the htmlentities and htmlspecialchars functions, but they do more than you asked for. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
Stuart, et al -- ...and then Stuart said... % % Diana Castillo wrote: % is there any function that will always replace a with a amp in a % string? % % $string = str_replace('', 'nbsp;', $string); Clearly I must need more coffee, because I completely fail to see how this will satisfy her requirement. Does this somehow do something other than what it obviously appears to do? % % -- % Stuart HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
RE: [PHP] amp
[snip] is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); [/snip] Shouldn't this be $string = str_replace('', 'amp;', $string); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
David T-G wrote: Stuart, et al -- ...and then Stuart said... % % Diana Castillo wrote: % is there any function that will always replace a with a amp in a % string? % % $string = str_replace('', 'nbsp;', $string); Clearly I must need more coffee, because I completely fail to see how this will satisfy her requirement. Does this somehow do something other than what it obviously appears to do? Time for more coffee. Or maybe sleep. Or maybe a holiday. All three methinks but not necessarily in that order!! -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
David T-G wrote: Stuart, et al -- ...and then Stuart said... % % Diana Castillo wrote: % is there any function that will always replace a with a amp in a % string? % % $string = str_replace('', 'nbsp;', $string); Clearly I must need more coffee, because I completely fail to see how this will satisfy her requirement. Does this somehow do something other than what it obviously appears to do? You need more coffeebetter yet, Mt. Dew. Replacing an ampersand with a non-breaking space is the new form of code encryption and job security. ;) -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] addslashes stripslashes
On 28 January 2004 12:31, Will wrote: I'm a little confused with these functions. How I here you ask. Well I thought I understood what they were for: Escaping characters that might cause a problem when you enter your data into a database query. i.e. \ ' Anyway what is confusing me is, say I have a string which contains an ' e.g: that's mine. I would use addslashes so that the query wouldn't upset mysql when it is entered. Viewing the data entry via phpmyadmin the data is displayed as: that's mine (not: that\'s mine) Meaning that when I extract the data from the database I need to use stripslashes returning the string to: that's mine. Correct so far. Let's do a little visualisation, using your example string of that's mine: * Start with the string you want to insert: that's mine * You apply addslashes to escape problematic characters. This results in: that\'s mine * The database takes this string, translates the escape sequence to its unescaped equivalent, and inserts the result: that's mine So, by this process, you have inserted into the database exactly what you wanted -- in the process, it gets escaped in PHP, and then unescaped by the database. The bottom line here is, the slashes do *not* get inserted -- they are there simply to ensure that any potentially problematic characters get stored correctly. Now, when you retrieve this data, PHP takes a look at the setting of magic_quotes_runtime, and if it is On does an on-the-fly addslashes() on the retrieved value; so the result, when displayed will be: * with magic_quotes_runtime = On: that\'s mine * with magic_quotes_runtime = Off:that's mine So, with magic_quotes_runtime Off, you get back exactly what you put in, which is good for displaying on, say, an HTML page; with it On, you get a version that's good for using in, say, another database query, but needs stripslashes()ing before you display it. Now to the meat of your query: However recently I encrypted some data which I stored in the database. The string contained a \ which I added slashes to when entered in to the database. But as the database appears to strips the first slash off the double slash automatically. Upon retrieving the data and strip the slashes off it, my data is now corrupt as there weren't double slashes it was just a single (like it was supposed to be) and that got removed by the function instead of the extra one. Well, it's important to note here that the encryption of a string containing problematic characters may not, itself, contain them -- and, of course, vice versa! -- so the trick is to apply addslashes() (or whatever) to the values *inserted into the database*. This means that the sequence should be: * encrypt string * apply addslashes * insert into database The database will, as before, deslash the string as it is inserted, so that when you later retrieve the encrypted value and decrypt it you will properly get back what you started with. If you addslashes() and then encrypt, you've just incorporated the added slashes into the encrypted value -- and you have no protection against encrypted values which themselves contain quotes or slashes. As I haven't had any data that contains a \ in it before I've never noticed it's not made any difference before. So Does this basically mean that there is no point using stripslashes on the data you extract from the database. If you've correctly addslashes()ed it on the way in, then yes, there is no point -- since the added slashes never actually make it into the database. (Indeed, you may incorrectly remove slashes that were in the original data!) Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, 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
[PHP] __autoload() in PHP4
Good morning fella, Is there something like __autoload() of PHP5 in PHP4? After using PHP5 for a month, I just can't stand writing those never-ending includes and requires. Any ideas how to simulate an __autoload()? I am not afraid of a little overhead. For those who don't know - if PHP does not have some class defined, it looks for __autoload() function defined by user and checks for class definition after executing the function. If the class is then defined, PHP goes on parsing as nothing had ever happened, but if the class is not found by that time PHP sends an error message. -- Best regards, Pietuka Tevi gaida Persijas princis Tikssanaas vieta un aizrautiiga laika pavadiissana http://games.inbox.lv
[PHP] Help with a string replacement
Hi, I want to replace a string a:[whatever] with a href=[something][whatever]. [whatever] may be what ever substring possible... ie. I want to replace all occurences that exists being [whatever] a variable expression... Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
On Wednesday 28 January 2004 09:32 am, Stuart wrote: Diana Castillo wrote: is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); Just a heads up on using the above method. If there are more than one in the string it will produce unexpected results. For example Here is one and here is another will produce Here is one amp; and here is another amp;amp; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Fopen and streams
Hi, first time poster here. Having some trouble with a line that used to work, but doesn't now. $pg = fopen(http://$ip/mypage;, r); Gets me: Warning: fopen(http://10.1.1.233/mypage): failed to open stream: HTTP request failed! And then it spits out the data from that page anyways. What's going on here? This was working on my other box a few days ago. And I've tried it with and without the variable for the ip address/url. --Stryder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] amp
[snip] [snip] is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); [/snip] Shouldn't this be $string = str_replace('', 'amp;', $string); ? [/snip] I tried this and amazingly it worked! The robustness of php defies all logic and comprehension! When did they sneak in this new feature to read the mind of the programmer? Keep up the good work guys! -J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
Gerard Samuel wrote: On Wednesday 28 January 2004 09:32 am, Stuart wrote: Diana Castillo wrote: is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); Just a heads up on using the above method. If there are more than one in the string it will produce unexpected results. For example Here is one and here is another will produce Here is one amp; and here is another amp;amp; You could use preg_replace( '/(?!amp;)/', 'amp;', $string); But I suspect that the OP is probably looking for htmlentities and other such built in PHP functions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] amp
Gerard Samuel wrote: On Wednesday 28 January 2004 09:32 am, Stuart wrote: Diana Castillo wrote: is there any function that will always replace a with a amp in a string? $string = str_replace('', 'nbsp;', $string); Just a heads up on using the above method. If there are more than one in the string it will produce unexpected results. For example Here is one and here is another will produce Here is one amp; and here is another amp;amp; Not from where I'm sitting [PHP 4.3.3RC1 (cli) (built: Jun 21 2003 23:40:27) on FreeBSD built from ports]. Code... print str_replace('', 'amp;', 'Here is one and here is another '); ... outputs ... Here is one amp; and here is another amp; Do you need more coffee? -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Googlebot
On Wed, 2004-01-28 at 08:34, Jon Bennett wrote: is that it tends to avoid or downgrade URI's with parameters tacked onto the end. Does that go for internal links in your site then ??? news.php?start=10 etc ??? Could be tricky writing dyamic pages then. mod_rewrite is your friend here. You can rewrite stuff like /foo/ /bar/ etc... to *.php?foo=barbar=foo. Kind of a pain in the arse but if you MUST have a spider following links then... -- BrianGnuPG - KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys Key Server: pgp.mit.edu == gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC GnuPG: http://gnupg.org http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC Linux Registered User #339825 at http://counter.li.org signature.asc Description: This is a digitally signed message part
Re: [PHP] __autoload() in PHP4
From: Pietuka Krustins [EMAIL PROTECTED] Is there something like __autoload() of PHP5 in PHP4? After using PHP5 for a month, I just can't stand writing those never-ending includes and requires. Any ideas how to simulate an __autoload()? I am not afraid of a little overhead. For those who don't know - if PHP does not have some class defined, it looks for __autoload() function defined by user and checks for class definition after executing the function. If the class is then defined, PHP goes on parsing as nothing had ever happened, but if the class is not found by that time PHP sends an error message. I don't see how you could replicate it. You could probably capture the error with some custom error handling, but how would you tell it to now go back and try that line again? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Tip For The Day
Jay Blanchard wrote: I think that you meant to its already been broughten!, didn't you? Did you know that you will find that bracing style has been debated since the days of FORTRAN? Oh! Fortran 77! I remember those times! =) And I still think inline braces wins hands down!!! Cesar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help: arrays in a class
Hi all, I'm having some trouble here and I hope you can help. I'm writing a class for PHP to help track includes in a c++ source file. My class has 3 member variables: a filename file contents array of files that file includes The class definition looks like this class clsfTreeNode { //member variables var $fName; var $fData; var $includedFiles; //constructor function clsfTreeNode( $fileName ) { $this-$fName = $fileName; $this-$fData = file_get_contents($this-$fName); $this-ParseFile(); print count($this-$includedFiles); } function ParseFile(); { ...Long Drawn Out Code Omitted... } }; Here's the problem. In ParseFile I call the function: array_push($this-$includedFiles, $ifName); where $ifName is the name of an include file I found in the code. However, I get an error stating the first argument must be an array. So I tried making the constructor look like this: function clsfTreeNode( $fileName ) { $this-$fName = $fileName; $this-$fData = file_get_contents($this-$fName); $this-$includedFile = array(); $this-ParseFile(); print count($this-$includedFiles); } and that seems to work ok EXCEPT that $fData also becomes an array and it's contents erased! I've tried moving things around, etc but no matter where i make $includedFile an array $fData gets screwed up. If I don't explicitly make $includedFile an array then nothing works anyway. I'm going out of my mind trying to get this to work, and it shouldn't be so hard. I'm using php 4.3.4 on a WinXP machine. Any thoughts? THanks Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] index page not running and other woes (0t?)
Hi, I think this is a bit off topic, but i'm sure some of you guys must be running ensim so might be able to help me. We reciently took a dedicated server to work with, it came with ensim installed, its a Linux machine P4 2.6 running Apache. Problem: 1)As I go to the IP address assigned to our box, it rolls out the ensim login screen instead! it does not run the index.html page 2)when i put a phpinfo.php page there, and call that like so http://ipnumber/phpinfo.php it runs perfectly, but after that i made a folder members and tried calling that http://ipnumber/members/ it gives me a page not found... i even tried calling the index file like so: http://ipnumber/index.html and it gives me a page not found... whats wrong? and what setting do i have to change? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: arrays in a class
[EMAIL PROTECTED] wrote: snip Here's the problem. In ParseFile I call the function: array_push($this-$includedFiles, $ifName); Here you have it ending in an 's' where $ifName is the name of an include file I found in the code. However, I get an error stating the first argument must be an array. So I tried making the constructor look like this: function clsfTreeNode( $fileName ) { $this-$fName = $fileName; $this-$fData = file_get_contents($this-$fName); $this-$includedFile = array(); Here you have it without an 's' $this-ParseFile(); print count($this-$includedFiles); } and that seems to work ok EXCEPT that $fData also becomes an array and it's contents erased! I've tried moving things around, etc but no matter where i make $includedFile an array $fData gets screwed up. If I don't explicitly make $includedFile an array then nothing works anyway. I'm going out of my mind trying to get this to work, and it shouldn't be so hard. I'm using php 4.3.4 on a WinXP machine. Any thoughts? Don't know if the 's' is the problem, but it's a start. Also, you may want to declare you $includeFile(s) as an array at the start of your class. I'm just guessing here, but declaring it as such ($this-$includeFile = array()) may be emptying $this too. -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: arrays in a class
From: [EMAIL PROTECTED] class clsfTreeNode { //member variables var $fName; var $fData; var $includedFiles; //constructor function clsfTreeNode( $fileName ) { $this-$fName = $fileName; $this-$fData = file_get_contents($this-$fName); $this-ParseFile(); You have an extra $ sign in your variables names. $this-fName instead of $this-$fName Not sure if that'll solve all your problems, but it's a start. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] chunk_split();
Title: chunk_split(); Hi, I am using the chunk_split(); function to separe a long long text on differents pages. At this time, I can split the string into x sections of 2000 characters. Now I need to show only the first 2000 . when user click on page #2, its reloading and show the next 2000 characters... If he click the page 4 button, its going to the 6000th caracters and it show his next 2000.. etc... How can I split this text on many pages without loosing any characters?? Maybe the chunk_split function is not the good one... Thanks Ben
Re: [PHP] Help: arrays in a class
John W. Holmes wrote: snip You have an extra $ sign in your variables names. $this-fName instead of $this-$fName Not sure if that'll solve all your problems, but it's a start. ---John Holmes... Oh, sure. Point out what I missed in my eval. ;) -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Zend Studio ESC key issue?
First, let me apologize for this not being a specific PHP question, but I can't find the answer and I'm hoping someone else here has run into this. Maybe I'm just blind, blond or stupid today. :) In Zend Studio (Zend Development Environment) for Windows (on Windows 2000 fyi), when I hit the ESC key, it hides my Messages, Debug and Output windows. This might be nice sometimes, but I find myself hitting ESC (sometimes for no rational reason) and it's driving me nuts that it hides the three windows I WANT to see and not the File Manager window, which I really don't use that much currently. Hah Is there somewhere to customize this or is there another key that brings them back quickly? I prefer keyboard use to mouse use and would prefer not to have these windows disappear in the first place, but if it were a matter of hitting ESC to temporarily hide and hitting ESC again to bring them back, that'd be acceptable. I promise to post more directly PHP related messages later, just gotta take care of this one project first. Thanks in advance! -Trevor Gryffyn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] chunk_split();
maybe its better to use fread() and fseek() 2000 bytes should be 2000 characters in a textfile g. tinu Wed, 28 Jan 2004 11:20:32 -0500 Benjamin Trpanier [EMAIL PROTECTED]: Hi, I am using the chunk_split(); function to separe a long long text on differents pages. At this time, I can split the string into x sections of 2000 characters. Now I need to show only the first 2000 . when user click on page #2, its reloading and show the next 2000 characters... If he click the page 4 button, its going to the 6000th caracters and it show his next 2000.. etc... How can I split this text on many pages without loosing any characters?? Maybe the chunk_split function is not the good one... Thanks Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Googlebot
Googlebot visits my site occasionally and follows a lot of my PHP links with long query strings... -Mike __ Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread! __ On Jan 28, 2004, at 8:34 AM, Jon Bennett wrote: Does that go for internal links in your site then ??? news.php?start=10 etc ??? Could be tricky writing dyamic pages then. Thanks, Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Tip For The Day
On 28 January 2004 15:52, Cesar Cordovez wrote: Jay Blanchard wrote: I think that you meant to its already been broughten!, didn't you? Did you know that you will find that bracing style has been debated since the days of FORTRAN? Oh! Fortran 77! I remember those times! =) Fortran-77?? You were lucky!! When *I* were a lad, it were FORTRAN-II with its arithmetic-if, which like as not would jump up and bite you in t'backside every time you dared to use it, and we thowt oursens damn' lucky to have it an all...!! And I still think inline braces wins hands down!!! Personally, I HATE BRACES (I think I've mentioned this before). Give me PHP's alternative :-and-end-token syntax every time. insert standard rant here Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, 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] chunk_split();
Wed, 28 Jan 2004 11:41:56 -0500 Benjamin Trépanier [EMAIL PROTECTED]: On 28/01/04 11:29, Martin Luethi [EMAIL PROTECTED] wrote: maybe its better to use fread() and fseek() 2000 bytes should be 2000 characters in a textfile g. tinu Wed, 28 Jan 2004 11:20:32 -0500 Benjamin Trépanier [EMAIL PROTECTED]: Hi, I am using the chunk_split(); function to separe a long long text on differents pages. At this time, I can split the string into x sections of 2000 characters. Now I need to show only the first 2000 . when user click on page #2, itÅs reloading and show the next 2000 characters... If he click the page 4 button, itÅs going to the 6000th caracters and it show his next 2000.. etc... How can I split this text on many pages without loosing any characters?? Maybe the chunk_split function is not the good one... Thanks Ben Interesting but my text are from a mySQL DB so, I have to split a text who is content in a variable.. chunk_split($text) What Ca I do? Is there a way to told the server brings me caracters (1,2000) and after by an incrementation 2001- 4001 etc... you can use $text = chunk_split($text, 2000, MYTAG); to insert MYTAG after every 2000 chars. with $testarray = split(MYTAG, $text); you get an array with your data (each entry is 2000 chars, MYTAG is removed) MYTAG can be anything, just make sure that it never occurs inside the data from mysql. g. tinu -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Googlebot
On Wed, Jan 28, 2004 at 11:51:06 -0500, Michael Mulligan wrote: Googlebot visits my site occasionally and follows a lot of my PHP links with long query strings... same here, google has been indexing my php site for over 3 years now :) -- A Pope has a Water Cannon. It is a Water Cannon. He fires Holy-Water from it.It is a Holy-Water Cannon. He Blesses it. It is a Holy Holy-Water Cannon. He Blesses the Hell out of it. It is a Wholly Holy Holy-Water Cannon. He has it pierced.It is a Holey Wholly Holy Holy-Water Cannon. He makes it official. It is a Canon Holey Wholly Holy Holy-Water Cannon. Yes, of course it's the right cabl [le0: NO CARRIER] pgp0.pgp Description: PGP signature
[PHP] Still error messages!!
Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? And this is the mySQL structure : # phpMyAdmin MySQL-Dump # version 2.2.3 # http://phpwizard.net/phpMyAdmin/ # http://phpmyadmin.sourceforge.net/ (download page) # # Host: localhost # Generation Time: Jan 28, 2004 at 08:27 PM # Server version: 3.23.47 # PHP Version: 4.1.1 # Database : `elearning` # # # Table structure for table `accounts` # CREATE TABLE accounts ( UserName varchar(50) NOT NULL default '', Password varchar(50) NOT NULL default '', SecurityQuestion varchar(50) NOT NULL default '', SecurityAnswer varchar(50) NOT NULL default '', CourseTitle varchar(50) NOT NULL default '', CourseLanguage varchar(50) NOT NULL default '', FirstName varchar(50) NOT NULL default '', LastName varchar(50) NOT NULL default '', BirthDay varchar(50) NOT NULL default '', BirthMonth varchar(50) NOT NULL default '', BirthYear varchar(50) NOT NULL default '', Gender varchar(50) NOT NULL default '', Language varchar(50) NOT NULL default '', Country varchar(50) NOT NULL default '', StateOrCity varchar(50) NOT NULL default '', ZIPPostalCode varchar(50) NOT NULL default '', Occupation varchar(50) NOT NULL default '', Email varchar(50) NOT NULL default '', Phone varchar(50) NOT NULL default '', Mobile varchar(50) NOT NULL default '', Serial varchar(50) NOT NULL default '', Activation varchar(50) NOT NULL default '', Random varchar(101) NOT NULL default '', Adjective varchar(50) NOT NULL default '', LessonNumber varchar(50) NOT NULL default '', LoginTime varchar(200) NOT NULL default '', LogoutTime varchar(200) NOT NULL default '', Distance varchar(50) NOT NULL default '', UNIQUE KEY UserName (UserName) ) TYPE=MyISAM; # # Dumping data for table `accounts` # So where are the errors? Waiting your help please.. Regards..
RE: [PHP] Still error messages!!
[snip] So where are the errors? [/snip] Good question. You have not shown us the error message. Please show us and we can help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with mcrypt_encrypt and mcrypt_decrypt.
[EMAIL PROTECTED] wrote: Hi all, i'm trying to crypt and decrypt password with the code below but i get many warnings Warning: mcrypt_get_iv_size(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 36 Warning: mcrypt_create_iv(): Can not create an IV with size 0 or smaller in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 37 Warning: mcrypt_decrypt(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 38 and i don't understand why, any help is appreciated. Code is below. This code is in a script //Start crypt $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); should be... $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_ECB); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $key=genera();// genera() function for rand number $emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); should be... $emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_ECB,$iv); $emailcifrata=$key.$emailcifrata; // End crypt This code is in another script that isn't the same script of previous //Start decrypt $emailcifrata=fgets($fp); $lunghezza_str=strlen($emailcifrata); $emailcifrata=substr($emailcifrata,10); $key=substr($emailcifrata,0,($lunghezza_str-10)); $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); should be... $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_ECB); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); should be... $email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_ECB,$iv); // End decrypt Thanks in advance. And the reason why is the streaming mode CBC doesn't work with every cipher mcrypt provides, for a list of modes each cipher is compatible with from a shell issue this command... %/path/to/mcrypt --list Or if you don't have access to a shell on the webserver try these... http://us3.php.net/manual/en/function.mcrypt-list-algorithms.php http://us3.php.net/manual/en/function.mcrypt-list-modes.php From the help file on php.net for mcrypt http://us3.php.net/manual/en/ref.mcrypt.php Predefined Constants The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. Mcrypt can operate in four block cipher modes (CBC, OFB, CFB, and ECB). If linked against libmcrypt-2.4.x or higher the functions can also operate in the block cipher mode nOFB and in STREAM mode. Below you find a list with all supported encryption modes together with the constants that are defines for the encryption mode. For a more complete reference and discussion see Applied Cryptography by Schneier (ISBN 0-471-11709-9). * MCRYPT_MODE_ECB (electronic codebook) is suitable for random data, such as encrypting other keys. Since data there is short and random, the disadvantages of ECB have a favorable negative effect. * MCRYPT_MODE_CBC (cipher block chaining) is especially suitable for encrypting files where the security is increased over ECB significantly. * MCRYPT_MODE_CFB (cipher feedback) is the best mode for encrypting byte streams where single bytes must be encrypted. * MCRYPT_MODE_OFB (output feedback, in 8bit) is comparable to CFB, but can be used in applications where error propagation cannot be tolerated. It's insecure (because it operates in 8bit mode) so it is not recommended to use it. * MCRYPT_MODE_NOFB (output feedback, in nbit) is comparable to OFB, but more secure because it operates on the block size of the algorithm. * MCRYPT_MODE_STREAM is an extra mode to include some stream algorithms like WAKE or RC4. HTH Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] chunk_split();
chunk_split();From: Benjamin Trépanier I am using the chunk_split(); function to separe a long long text on differents pages. At this time, I can split the string into x sections of 2000 characters. Now I need to show only the first 2000 . when user click on page #2, it's reloading and show the next 2000 characters... If he click the page 4 button, it's going to the 6000th caracters and it show his next 2000.. etc... How can I split this text on many pages without loosing any characters?? Maybe the chunk_split function is not the good one... You'll have to look for the spaces. So you want no more than 2000 characters per page. If you're on page x, then start at character x*2000 and start looping backwards character by character until you find a space. Then grab the text up until that character. remember that characters location, too, as you'll need to use that as your starting point on the next page. Something like this: $start = 0; $chars = 2000; $page = array(); $x = 0; $len = strlen($long_text); while($start $len) { $spot = $start + $chars; if($spot $len) { while($long_text{$spot--} != ' ') { } } else { $spot = $len; } $page[$x]['start'] = $start; $page[$x]['chars'] = $spot - $start + 1; $x++; $start = $spot + 1; } Now you'll have your start and number of characters for each page. For example to show page zero: echo substr($long_text,$page[0]['start'],$page[0]['chars']); To show page 5 echo substr($long_text,$page[5]['start'],$page[5]['chars']); etc. Throw $page into a session variable so you only have to calculate it once. Also, if you're pulling this text from a database or file, combine it with the database and/or file functions so that you only extract/read the part of the text your after instead of the whole text each time. Hope that helps. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
From: Radwan Aladdin [EMAIL PROTECTED] So where are the errors? In your code or database, I'm sure of it. In other words, why don't you tell us what error message your getting, the line number, etc. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
Hehehehehe :) sorry I forgot that :) Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are sme other errors.. please see the whole script.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. Waiting your help.. Regards.. - Original Message - From: Jay Blanchard [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:12 PM Subject: RE: [PHP] Still error messages!! [snip] So where are the errors? [/snip] Good question. You have not shown us the error message. Please show us and we can help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the queries are what you want them to be... $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); Do the same here for query4 $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
Thank for your reply.. But I'm not trying to echo these queries.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. The error that is displayed always is : Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are some other errors.. please see the whole script.. Waiting your help.. Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:35 PM Subject: Re: [PHP] Still error messages!! At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the queries are what you want them to be... $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); Do the same here for query4 $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? -- 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] amp
On Wednesday 28 January 2004 10:23 am, Stuart wrote: Not from where I'm sitting [PHP 4.3.3RC1 (cli) (built: Jun 21 2003 23:40:27) on FreeBSD built from ports]. Code... Hey, as least we can agree with something. FreeBSD :) print str_replace('', 'amp;', 'Here is one and here is another '); ... outputs ... Here is one amp; and here is another amp; You're absolutely correct. I jumped the gun way too early. My experience with replacing with amp; is that if the content already contains entity content, for example nbsp; Running str_replace will mess them up. Do you need more coffee? Maybe some latte ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Still error messages!!
Correct Radwan, you are NOT trying to echo the queries to the screen. However, what David is trying to teach you is simply debugging techniques. By echoing the actual query that the PHP pareser is using, you can see if it is indeed what you want it to be. This way, you can debug the code yourself, instead of posting it to a list for help. That way you cut down on the number of email messages I receive and also learn something in the process. Now, echo it to the screen and see what it says :-) M Damon Hill Senior Technical Lead IFWorld, Inc. www.ifworld.com Go Hogs! People demand freedom of speech to make up for the freedom of thought which they avoid. - Soren Aabye Kierkegaard -Original Message- From: Radwan Aladdin [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:50 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still error messages!! Thank for your reply.. But I'm not trying to echo these queries.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. The error that is displayed always is : Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are some other errors.. please see the whole script.. Waiting your help.. Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:35 PM Subject: Re: [PHP] Still error messages!! At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the queries are what you want them to be... $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); Do the same here for query4 $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? -- 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] Variables not working!
Try this for a generic fix if it is the globals issue: Place this somewhere to set to TRUE or FALSE when needed $GLOBAL_FIX = TRUE; use an include on every script: if($GLOBAL_VARS_FIX) { if( phpversion() = '4.2.0' ) { extract($_POST); extract($_GET); extract($_SERVER); extract($_ENV); extract($_COOKIE); } } --- Alvaro Zuniga Information Technology Professional (337) 654 6515 www.zunitek.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
I made that.. but there is something strange!! I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 So what is wrong!!!?? Everything is inserted and updated correctly in the database.. but the distance is the same.. no changes.. no updates!! Regards.. - Original Message - From: Damon Hill [EMAIL PROTECTED] To: 'Radwan Aladdin' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:56 PM Subject: RE: [PHP] Still error messages!! Correct Radwan, you are NOT trying to echo the queries to the screen. However, what David is trying to teach you is simply debugging techniques. By echoing the actual query that the PHP pareser is using, you can see if it is indeed what you want it to be. This way, you can debug the code yourself, instead of posting it to a list for help. That way you cut down on the number of email messages I receive and also learn something in the process. Now, echo it to the screen and see what it says :-) M Damon Hill Senior Technical Lead IFWorld, Inc. www.ifworld.com Go Hogs! People demand freedom of speech to make up for the freedom of thought which they avoid. - Soren Aabye Kierkegaard -Original Message- From: Radwan Aladdin [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:50 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still error messages!! Thank for your reply.. But I'm not trying to echo these queries.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. The error that is displayed always is : Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are some other errors.. please see the whole script.. Waiting your help.. Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:35 PM Subject: Re: [PHP] Still error messages!! At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the queries are what you want them to be... $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); Do the same here for query4 $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? -- 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] (WEIRD problem) Not following directories!!! (0t)
Hi, Heres a totally weird problem, I created some folders on our server (which we are accessing only via ip as the domain has not been resolved) but I get an error when i try to access the folder(s)! eg: (I created this folder) ryan and i try to access it like this: http://208.234.29.220/ryan/ and it gives me this error: You don't have permission to access /ryan/ on this server. Which is totally weird coz I have NOTHING in that folder right now...not even a .htaccess file What could be wrong? I have looked in my httpd.conf file and on google but cant seem to find anything...any ideas? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session time-out value
Yes, I have used a .htaccess file in a Web Directory to prevent http access to its contents. Thanks again !! -Pushpinder Singh On Saturday, January 24, 2004, at 12:59 AM, Jason Wong wrote: On Saturday 24 January 2004 05:46, Pushpinder Singh wrote: I tried to keep a .htaccess file in the Dir that my application esided in and kept the session lifetime of about 8 hrs. However I checked to see after 2 hr and it had already kicked me out of the system. Please advise. Does your hosting service allow you to use .htaccess files? -- 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 -- /* You can't fall off the floor. */ -- 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] (WEIRD problem) Not following directories!!! (0t)
Hey Andrew, First, note that that is an apache problem, not PHP. Yep, thats why I put the Ot in the subject line but since you cant have PHP without a webserver and apache is the most popular on the list or the net...I was hopeing someone else had this problem and could guide me In httpd.conf add Option Indexes to the folder (root for whole site). That will produce a file list of the directory. Thanks, will try that right now. Or, put in a 'default' document (ie: index.html) that will produce the output when people browse to the directory. Will try that too. Directory browsing is normaly disabled in web servers (from experience, apache and IIS). See? didnt know that. Learned something new. HTH Sure did. Thanks. Cheers, -Ryan Andrew Hi, Heres a totally weird problem, I created some folders on our server (which we are accessing only via ip as the domain has not been resolved) but I get an error when i try to access the folder(s)! eg: (I created this folder) ryan and i try to access it like this: http://208.234.29.220/ryan/ and it gives me this error: You don't have permission to access /ryan/ on this server. Which is totally weird coz I have NOTHING in that folder right now... not even a .htaccess file What could be wrong? I have looked in my httpd.conf file and on google but cant seem to -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
I assume you are using another page with a form to enter the username and password? If so: add as the first line of your script right after the ?PHP phpinfo(); Run your application, scroll to the bottom and look at the php variables and make sure that your are asking for $_GET[Username] and $_GET[Password] are what the script sees If not: You may have to run just that page with http://whatever/whatever.php?Username=whateverPassword=whatever to see if the problem is in the form or not -Dave At 01:08 PM 1/28/2004, Radwan Aladdin wrote: I made that.. but there is something strange!! I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 So what is wrong!!!?? Everything is inserted and updated correctly in the database.. but the distance is the same.. no changes.. no updates!! Regards.. - Original Message - From: Damon Hill [EMAIL PROTECTED] To: 'Radwan Aladdin' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:56 PM Subject: RE: [PHP] Still error messages!! Correct Radwan, you are NOT trying to echo the queries to the screen. However, what David is trying to teach you is simply debugging techniques. By echoing the actual query that the PHP pareser is using, you can see if it is indeed what you want it to be. This way, you can debug the code yourself, instead of posting it to a list for help. That way you cut down on the number of email messages I receive and also learn something in the process. Now, echo it to the screen and see what it says :-) M Damon Hill Senior Technical Lead IFWorld, Inc. www.ifworld.com Go Hogs! People demand freedom of speech to make up for the freedom of thought which they avoid. - Soren Aabye Kierkegaard -Original Message- From: Radwan Aladdin [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:50 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still error messages!! Thank for your reply.. But I'm not trying to echo these queries.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. The error that is displayed always is : Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are some other errors.. please see the whole script.. Waiting your help.. Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:35 PM Subject: Re: [PHP] Still error messages!! At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the queries are what you want them to be... $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); Do the same here for query4 $result2 = mysql_query($query4) or die(Query error: . mysql_error()); if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? -- 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:
Re: [PHP] amp
From: Gerard Samuel [EMAIL PROTECTED] You're absolutely correct. I jumped the gun way too early. My experience with replacing with amp; is that if the content already contains entity content, for example nbsp; Running str_replace will mess them up. Depends how you define mess them up... If you want to display nbsp; literally on a web page, then you need to write amp;nbsp; in the source. So this may not be messing things up but rather preparing them to be shown on a web page, literally. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
I'm using the GET method.. And it is right.. it shows the correct GET method.. the problem in is in the Destance value.. it is not updating this value to the database.. or it is wrong.. every time = 0 So what is the error? Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 10:34 PM Subject: Re: [PHP] Still error messages!! I assume you are using another page with a form to enter the username and password? If so: add as the first line of your script right after the ?PHP phpinfo(); Run your application, scroll to the bottom and look at the php variables and make sure that your are asking for $_GET[Username] and $_GET[Password] are what the script sees If not: You may have to run just that page with http://whatever/whatever.php?Username=whateverPassword=whatever to see if the problem is in the form or not -Dave At 01:08 PM 1/28/2004, Radwan Aladdin wrote: I made that.. but there is something strange!! I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 So what is wrong!!!?? Everything is inserted and updated correctly in the database.. but the distance is the same.. no changes.. no updates!! Regards.. - Original Message - From: Damon Hill [EMAIL PROTECTED] To: 'Radwan Aladdin' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:56 PM Subject: RE: [PHP] Still error messages!! Correct Radwan, you are NOT trying to echo the queries to the screen. However, what David is trying to teach you is simply debugging techniques. By echoing the actual query that the PHP pareser is using, you can see if it is indeed what you want it to be. This way, you can debug the code yourself, instead of posting it to a list for help. That way you cut down on the number of email messages I receive and also learn something in the process. Now, echo it to the screen and see what it says :-) M Damon Hill Senior Technical Lead IFWorld, Inc. www.ifworld.com Go Hogs! People demand freedom of speech to make up for the freedom of thought which they avoid. - Soren Aabye Kierkegaard -Original Message- From: Radwan Aladdin [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:50 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still error messages!! Thank for your reply.. But I'm not trying to echo these queries.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. The error that is displayed always is : Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are some other errors.. please see the whole script.. Waiting your help.. Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:35 PM Subject: Re: [PHP] Still error messages!! At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the queries are what you want them to be... $result = mysql_query($query1) or die(Query error: . mysql_error()); $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; $query4 = UPDATE accounts
Re: [PHP] Still error messages!!
From: Radwan Aladdin [EMAIL PROTECTED] I made that.. but there is something strange!! It's strange you can't follow instructions... I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 If you had printed out all the queries, you'd realize that error is coming from $query4. $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); $UserName and $Password have no value. Your distance calculation doesn't make any sense, either, as you're subtracting a string from an integer... $LogoutTime = date(U); $RightLoginTime = 'LoginTime'; So you're setting distance equal to 1034566 - LoginTime (for example), which is just going to come out to $LogoutTime (since a string converted to an integer is zero in this case). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
In your script you have $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; So $Distance is a string equaling Distance and $LessonNumber = LessonNumber How are you performing math on a string? -Dave At 01:42 PM 1/28/2004, Radwan Aladdin wrote: I'm using the GET method.. And it is right.. it shows the correct GET method.. the problem in is in the Destance value.. it is not updating this value to the database.. or it is wrong.. every time = 0 So what is the error? Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 10:34 PM Subject: Re: [PHP] Still error messages!! I assume you are using another page with a form to enter the username and password? If so: add as the first line of your script right after the ?PHP phpinfo(); Run your application, scroll to the bottom and look at the php variables and make sure that your are asking for $_GET[Username] and $_GET[Password] are what the script sees If not: You may have to run just that page with http://whatever/whatever.php?Username=whateverPassword=whatever to see if the problem is in the form or not -Dave At 01:08 PM 1/28/2004, Radwan Aladdin wrote: I made that.. but there is something strange!! I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 So what is wrong!!!?? Everything is inserted and updated correctly in the database.. but the distance is the same.. no changes.. no updates!! Regards.. - Original Message - From: Damon Hill [EMAIL PROTECTED] To: 'Radwan Aladdin' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:56 PM Subject: RE: [PHP] Still error messages!! Correct Radwan, you are NOT trying to echo the queries to the screen. However, what David is trying to teach you is simply debugging techniques. By echoing the actual query that the PHP pareser is using, you can see if it is indeed what you want it to be. This way, you can debug the code yourself, instead of posting it to a list for help. That way you cut down on the number of email messages I receive and also learn something in the process. Now, echo it to the screen and see what it says :-) M Damon Hill Senior Technical Lead IFWorld, Inc. www.ifworld.com Go Hogs! People demand freedom of speech to make up for the freedom of thought which they avoid. - Soren Aabye Kierkegaard -Original Message- From: Radwan Aladdin [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:50 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Still error messages!! Thank for your reply.. But I'm not trying to echo these queries.. What I'm trying to do is : To UPDATE a value in the database (Login_Time and Logout_Time) and then caculate the distance between them and put it in (Distance) field.. then after that program the PHP file and put in it a LessonLimit value.. if the LessonLimit is the same of the Distance.. then make a value in that row (LessonNumber) = Its currently value + 1 (So for example : is LessonNumber = 2 then it must be 3...Etc..) Hope you got my meaning.. The error that is displayed always is : Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 Also when I put the right UserName and Password.. the same error!! So also there are some other errors.. please see the whole script.. Waiting your help.. Regards.. - Original Message - From: David OBrien [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 9:35 PM Subject: Re: [PHP] Still error messages!! At 12:08 PM 1/28/2004, Radwan Aladdin wrote: Hello all.. This is the PHP code : ?php include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; right here do a ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? and make sure the
Re: [PHP] Help: arrays in a class
On Wed, 28 Jan 2004 [EMAIL PROTECTED] wrote: in php you have to access a member variable (or methods) with: $this-varname (without the $) e.g.: $this-includedFile = array(); hope this helps AHA! I think that's it. The comment someone sent to me (Sorry, i'm awful with names) about $this-$includeFiles=array() maybe corrupting all of $this apparently seemed true. Thanks again all :) Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
But I mean by $RightLoginTime = 'LoginTime'; the selected field from the database (LoginTime).. First I selected the LoginTime from the database and now I'm trying to name a variable for it to use it.. So what is the correct code? Regards.. -- SASSINC Internet Solutions - Arabic Department [EMAIL PROTECTED] http://www.SASSINC.Net - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 10:46 PM Subject: Re: [PHP] Still error messages!! From: Radwan Aladdin [EMAIL PROTECTED] I made that.. but there is something strange!! It's strange you can't follow instructions... I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 If you had printed out all the queries, you'd realize that error is coming from $query4. $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); $UserName and $Password have no value. Your distance calculation doesn't make any sense, either, as you're subtracting a string from an integer... $LogoutTime = date(U); $RightLoginTime = 'LoginTime'; So you're setting distance equal to 1034566 - LoginTime (for example), which is just going to come out to $LogoutTime (since a string converted to an integer is zero in this case). ---John Holmes... -- 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] Still error messages!!
I believe I'd start here http://www.php.net/manual/en/function.mssql-fetch-row.php You get the db result from your script but you do nothing with it in your script A whole lot more reading and coding you need to accomplish. Good Luck -Dave At 01:54 PM 1/28/2004, Radwan Aladdin wrote: But I mean by $RightLoginTime = 'LoginTime'; the selected field from the database (LoginTime).. First I selected the LoginTime from the database and now I'm trying to name a variable for it to use it.. So what is the correct code? Regards.. -- SASSINC Internet Solutions - Arabic Department [EMAIL PROTECTED] http://www.SASSINC.Net - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 10:46 PM Subject: Re: [PHP] Still error messages!! From: Radwan Aladdin [EMAIL PROTECTED] I made that.. but there is something strange!! It's strange you can't follow instructions... I SELECTED field from the database.. but it is not showing what it contains!! This is what is shown on the screen : UPDATE accounts SET LogoutTime=1075313199SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='' AND Password=''UPDATE accounts SET LessonNumber=LessonNumber + 1 Query error: You have an error in your SQL syntax near '0') WHERE UserName= AND Password=)' at line 1 If you had printed out all the queries, you'd realize that error is coming from $query4. $query4 = UPDATE accounts SET (Distance=' . $LogoutTime - $RightLoginTime . ') WHERE UserName= . $UserName . AND Password= . $Password . ); $UserName and $Password have no value. Your distance calculation doesn't make any sense, either, as you're subtracting a string from an integer... $LogoutTime = date(U); $RightLoginTime = 'LoginTime'; So you're setting distance equal to 1034566 - LoginTime (for example), which is just going to come out to $LogoutTime (since a string converted to an integer is zero in this case). ---John Holmes... -- 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] sending a hex string as it is?
$var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. Thanks for your help. Khoa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending a hex string as it is?
At 02:03 PM 1/28/2004, Khoa Nguyen wrote: $var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave Thanks for your help. Khoa -- 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] Still error messages!!
From: Radwan Aladdin [EMAIL PROTECTED] But I mean by $RightLoginTime = 'LoginTime'; the selected field from the database (LoginTime).. First I selected the LoginTime from the database and now I'm trying to name a variable for it to use it.. So what is the correct code? You end up with Distance = '12345678 - LoginTime' and you want Distanct = 12345678 - LoginTime so figure it out... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending a hex string as it is?
Thanks for the info Dave, but I still can't make it work: ?php $var = 0x10; // decimal 16 echo $var; // case 1 echo strval($var); // case 2 ? In both cases, I see 3136 (ASCII encoded of string 16) on the wire :-( Any ideas? Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:08 PM To: Khoa Nguyen; [EMAIL PROTECTED] Subject: Re: [PHP] sending a hex string as it is? At 02:03 PM 1/28/2004, Khoa Nguyen wrote: $var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave Thanks for your help. Khoa -- 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] amp
On Wednesday 28 January 2004 01:35 pm, John W. Holmes wrote: Depends how you define mess them up... If you want to display nbsp; literally on a web page, then you need to write amp;nbsp; in the source. So this may not be messing things up but rather preparing them to be shown on a web page, literally. ---John Holmes... True, but the bottom line is amp;nbsp; !== nbsp; Me personally, I rather keep it in its simplest form nbsp; For example, if you run amp;nbsp; through str_replace('', 'nbsp;', $foo) again, it becomes even more messed up. amp;amp;nbsp; The point Im trying to make, is to watch out using str_replace() to convert to amp; or something else thats similar, because, one may end up with a situation where they have content like amp;amp;nbsp; on their hands. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Making Graph / Chart
--- Ralph Guzman [EMAIL PROTECTED] wrote: Take a look at jpgraph: http://www.aditus.nu/jpgraph/ Great! That's exactly what I want. Now, after I read the installation instruction for JPGraph, I notice I must have built PHP with GD support to use the functionality. The problem is that my PHP is NOT built with GD support. My question is: Can I load GD as a separate .so with dl(gb.so) instead of building PHP again? Thanks! -Original Message- From: unkno me [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 27, 2004 5:25 PM To: [EMAIL PROTECTED] Subject: [PHP] Making Graph / Chart Hi, Does anyone know what function is needed to make graphic chart like those line / pipe char? Any example? Thanks! __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
Radwan Aladdin wrote: snip So where are the errors? Waiting your help please.. Regards.. What's the error message??? -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
David OBrien wrote: I believe I'd start here http://www.php.net/manual/en/function.mssql-fetch-row.php Or here even http://www.php.net/manual/en/function.mysql-fetch-row.php ;) -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Performance of multidimensional arrays vs many variables
I'm planning to use a very large multidimensional array to store data for grouping quantities of Products. This information needs to be carried from page to page in a session. Here's a part of the array's hierarchy for an example: grouping (array) - owner = 'name' - message = 'text' - package (array) -- 1st package (array) --- box = $boxTypeID --- inspector = $employeeID --- contents (array) $productID = $quantity So, for example, if I want to access the contents of the third package: $array_of_productIDs = $grouping['package'][3]['contents']; Great for organization, but seems prone to inefficiencies. For example, I need to look though each Package for a Product ID to find how many of that Product that have been Packaged, compare that with the quantity of that Product ID in the work order, and display to the user the quantity that hasn't yet been packaged. I'm also concerned about the memory usage for such a deep array; would it take more memory than the same data broken up into many, simpler variables? I've thought of using simpler variables (e.g., $package1, $package2, $p1contents, etc.). However, since there are many pieces of structurally-similar data (the Contents of a Package could have any number of Product IDs and and Quantities), and some elements have many pieces of related data (both a Box Type and Inspector for each Package), arrays seem to be the logical choice. Am I worrying about this too much? ;-) Are arrays the best solution for this sort of problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Still error messages!!
Now I fixed the error message.. but the problem is in Distance = 0 always.. because the LoginTime is a string.. I fetch it but the same thing!! This is the new script : ?php phpinfo(); include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $result2 = mysql_query($query2) or die(Query error: . mysql_error()); $row2 = mysql_fetch_row($result2); $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; $RightLoginTime = 'LoginTime'; $Distance = 'Distance'; $LessonNumber = 'LessonNumber'; $LessonsTimeLimit = 30; ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? $query4 = UPDATE accounts SET Distance= . $LogoutTime - $RightLoginTime . - LoginTime WHERE UserName= . $UserName . AND Password= . $Password . ); $result4 = mysql_query($query4) or die(Query error: . mysql_error()); $row4 = mysql_fetch_row($result4); ? pre ? echo $query4; ? /pre ? if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? So why it is making the Distance value = 0 and it doen't update the value in the database. (Because it must update the value in the database by it) Regards.. - Original Message - From: John Nichel [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:37 PM Subject: Re: [PHP] Still error messages!! Radwan Aladdin wrote: snip So where are the errors? Waiting your help please.. Regards.. What's the error message??? -- By-Tor.com It's all about the Rush http://www.by-tor.com -- 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] working with files
hi, i have problem with writing a reading to file i want to write emails in files. like this [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] etc.. this is how I write to the file $handle = fopen($filename, a); fwrite($handle,$email\n,128); fclose($handle); ok it writes everything just fine but now i want to read the file line by line and print line by line. this is how i do it. ?php $handle = fopen ($filename, r); do { $data = fread($handle, 128); if (strlen($data) == 0) { break; } print ($databr); } while (true); fclose($handle); ? the problem i get then is everything is printed in one line. any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] working with files
replace ?php $handle = fopen ($filename, r); do { $data = fread($handle, 128); if (strlen($data) == 0) { break; } print ($databr); } while (true); fclose($handle); ? with this ?php $handle = fopen ($filename, r); do { $data = fread($handle, 128); if (strlen($data) == 0) { break; } print ($databr\n); } while (true); fclose($handle); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: working with files
Did you try file(); ? -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com Tony [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] hi, i have problem with writing a reading to file i want to write emails in files. like this [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] etc.. this is how I write to the file $handle = fopen($filename, a); fwrite($handle,$email\n,128); fclose($handle); ok it writes everything just fine but now i want to read the file line by line and print line by line. this is how i do it. ?php $handle = fopen ($filename, r); do { $data = fread($handle, 128); if (strlen($data) == 0) { break; } print ($databr); } while (true); fclose($handle); ? the problem i get then is everything is printed in one line. any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending a hex string as it is?
Did you consider following? $var=\x10; ? Or dechex();? -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com Khoa Nguyen [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] Thanks for the info Dave, but I still can't make it work: ?php $var = 0x10; // decimal 16 echo $var; // case 1 echo strval($var); // case 2 ? In both cases, I see 3136 (ASCII encoded of string 16) on the wire :-( Any ideas? Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:08 PM To: Khoa Nguyen; [EMAIL PROTECTED] Subject: Re: [PHP] sending a hex string as it is? At 02:03 PM 1/28/2004, Khoa Nguyen wrote: $var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave Thanks for your help. Khoa -- 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] Still error messages!!
At 02:45 PM 1/28/2004, Radwan Aladdin wrote: Now I fixed the error message.. but the problem is in Distance = 0 always.. because the LoginTime is a string.. I fetch it but the same thing!! This is the new script : ?php phpinfo(); include(Config.php); $link = mysql_connect($user_hostname, $user_username, $user_password); mysql_select_db($user_database, $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $LogoutTime = date(U); $query1 = UPDATE accounts SET LogoutTime=$LogoutTime; You are not executing this query anywhere in the script $query2 = SELECT LoginTime,Distance,LessonNumber FROM accounts WHERE UserName='$UserName' AND Password='$Password'; $result2 = mysql_query($query2) or die(Query error: . mysql_error()); $row2 = mysql_fetch_row($result2); Great that you used this to get the results in a row but you need to reference the row in your script $query3 = UPDATE accounts SET LessonNumber=LessonNumber + 1; Instead of $RightLoginTime = 'LoginTime'; use $RightLoginTime = $row2[LoginTime]; but you need to do a mysql_query for the $query1 and get that value frst Instead of $Distance = 'Distance'; use $Distance = $row2[Distance]; Instead of $LessonNumber = 'LessonNumber'; use $LessonNumber = $row2[LessonNumber]; The user comments on the online manual are a very good starting point for basic programming steps needed to accomplish a task If you would have taken the example on that page you would have seen the steps needed: set your query string execute the query get the resultset into a variable This is the norm for all mysql php programming just putting a $Distance='Distance' does not tell php that what you really want it do read the database and place the value of Distance into $Distance -Dave $LessonsTimeLimit = 30; ? pre ? echo $query1; echo $query2; echo $query3; ? /pre ? $query4 = UPDATE accounts SET Distance= . $LogoutTime - $RightLoginTime . - LoginTime WHERE UserName= . $UserName . AND Password= . $Password . ); $result4 = mysql_query($query4) or die(Query error: . mysql_error()); $row4 = mysql_fetch_row($result4); ? pre ? echo $query4; ? /pre ? if($Distance == $LessonsTimeLimit){ $result3 = mysql_query($query3) or die(Query error: . mysql_error()); }else{ echo Not yet!; } ? So why it is making the Distance value = 0 and it doen't update the value in the database. (Because it must update the value in the database by it) Regards.. - Original Message - From: John Nichel [EMAIL PROTECTED] To: Radwan Aladdin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 11:37 PM Subject: Re: [PHP] Still error messages!! Radwan Aladdin wrote: snip So where are the errors? Waiting your help please.. Regards.. What's the error message??? -- By-Tor.com It's all about the Rush http://www.by-tor.com -- 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] Re: working with files
I'm new to php, and i tried file() no luck $lines = file('$filename'); foreach ($lines as $line_num = $line) { print (option value=\$line\$line/option); } thanx for the help Dvdmandt [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Did you try file(); ? -- // DvDmanDT MSN: dvdmandt¤hotmail.com Mail: dvdmandt¤telia.com Tony [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] hi, i have problem with writing a reading to file i want to write emails in files. like this [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] etc.. this is how I write to the file $handle = fopen($filename, a); fwrite($handle,$email\n,128); fclose($handle); ok it writes everything just fine but now i want to read the file line by line and print line by line. this is how i do it. ?php $handle = fopen ($filename, r); do { $data = fread($handle, 128); if (strlen($data) == 0) { break; } print ($databr); } while (true); fclose($handle); ? the problem i get then is everything is printed in one line. any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sending a hex string as it is?
At 02:17 PM 1/28/2004, Khoa Nguyen wrote: Thanks for the info Dave, but I still can't make it work: ?php $var = 0x10; // decimal 16 echo $var; // case 1 echo strval($var); // case 2 $var = 0x . dechex(strval($var)); is about the only way I could get it to show 0x10 instead of 16 -Dave ? In both cases, I see 3136 (ASCII encoded of string 16) on the wire :-( Any ideas? Khoa -Original Message- From: David OBrien [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 2:08 PM To: Khoa Nguyen; [EMAIL PROTECTED] Subject: Re: [PHP] sending a hex string as it is? At 02:03 PM 1/28/2004, Khoa Nguyen wrote: $var = 0x8180; How do I send $var to the browser as it is? In other words, if sniffing on the wire, I should see 8180, not 38 31 38 30. I think http://www.php.net/manual/en/function.strval.php would work here -Dave Thanks for your help. Khoa -- 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] Re: Performance of multidimensional arrays vs many variables
Hi John If you have a large number of Users using this system, your save map for sessions will grow in space, using some resources If it's very large pieces of information, i would advise you to store this info in a database. That's doomed to be more effective. Eric John Schulz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm planning to use a very large multidimensional array to store data for grouping quantities of Products. This information needs to be carried from page to page in a session. Here's a part of the array's hierarchy for an example: grouping (array) - owner = 'name' - message = 'text' - package (array) -- 1st package (array) --- box = $boxTypeID --- inspector = $employeeID --- contents (array) $productID = $quantity So, for example, if I want to access the contents of the third package: $array_of_productIDs = $grouping['package'][3]['contents']; Great for organization, but seems prone to inefficiencies. For example, I need to look though each Package for a Product ID to find how many of that Product that have been Packaged, compare that with the quantity of that Product ID in the work order, and display to the user the quantity that hasn't yet been packaged. I'm also concerned about the memory usage for such a deep array; would it take more memory than the same data broken up into many, simpler variables? I've thought of using simpler variables (e.g., $package1, $package2, $p1contents, etc.). However, since there are many pieces of structurally-similar data (the Contents of a Package could have any number of Product IDs and and Quantities), and some elements have many pieces of related data (both a Box Type and Inspector for each Package), arrays seem to be the logical choice. Am I worrying about this too much? ;-) Are arrays the best solution for this sort of problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SOLVED:- (WEIRD problem) Not following directories!!! (0t)
Hey All, Thanks to everyone who replied, the problem was indexes were not defined as Andrew pointed out (and solved my problem). *Main* problem I think was, that I never installed apache totally from the start, I always depended on the big bangs where you just run one .exe file and it installs apache,php,mysql and etc for you. Very nice approach, but as you can see, you dont learn too much, the only reason I am mentioning this is coz I know I am not the only one who does this..and now I'm going to take some time out and screw around with my httpd.conf, php.ini etc files trying to make sense of them...and if you are like me...you might want to do the same. Cheers, -Ryan On 1/28/2004 8:10:28 PM, Andrew Séguin ([EMAIL PROTECTED]) wrote: my apologies... didn't see the ot at the end of the subject... happy that helped. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php