Re: [PHP] Timing a MySQL response
Richard Davey wrote: Just a quick question - but does anyone know how to get the ms value back from MySQL that tells you how long it took to run your query? That value is not returned at all. Go with the wrapper... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] This Group....
gordon stewart wrote: Can someone point me in the right direction to some tutorials ( *EXAMPLES* ) to do the following functions (or point mer to an appropriate forum - see above).. http://us2.php.net/manual/en/ :- Open a file insert into an array/variable. (im trying to figure that one out now - get file-open errors).. file() ( close / flock etc... - not sure if flocking is on PHP ?) flock() :- turn a variable (split it) into an array.. explode() :- Loop through an array - display a line IF it matches another variable etc.. in_array() I think those 3 things are good starting points - I think I'll learn fast - But just need pointers to the usage / PHP commands - That I know I can do in Perl.. http://us2.php.net/file http://us2.php.net/flock http://us2.php.net/explode http://us2.php.net/in_array etc... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Convert Date Format?
Jeff Oien wrote: How do I convert this 9/8/2001 (which is Month/Day/Year) to this 20010908 (YearMonthDay - with leading zeros) echo date('Ymd',strtotime('9/8/2001')); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DB connection problem
From: Khalid Judeh [EMAIL PROTECTED] i have a problem connecting to mysql db, i use the following code to connect to the db: $DBConn = mysql_connect(localhost, myusername,mypassword) or die(Could not connect to database, . mysql_error()); mysql_select_db(db1, $DBConn); and i get the following error: Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in c:\inetpub\wwwroot\php\db_test.php on line 33 Could not connect to database, Client does not support authentication protocol requested by server; consider upgrading MySQL client Have you considered upgrading the MySQL client? :) It sounds like MySQL was upgraded on the server, but PHP was not recompiled to support the version. For example, I do not think that MySQL clients v3 will work with MySQL 4.1 and above. Check with the MySQL site to be sure. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused about logic
From: Aaron Wolski [EMAIL PROTECTED] I have input for where users can enter order numbers in which to search the database to find results matching their entry. To enter multiple order numbers they can comma separate like: 1,34,21,34,54 What I need to do is take those numbers and make a query that would like like: (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54')) Why do you need to put quotes around integers?? $var = '1,34,21,34,54'; //replace comma with quote,comma,quote and add quotes to beginning and end $in_clause = ' . str_replace(',',',',$var) . '; $query = WHERE (cart_id IN ($in_clause) OR id IN ($in_clause)); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problems...
From: Eric Gorr [EMAIL PROTECTED] When I visit test1.php with the url: http://domainpath/test1.php?name=billpwd=henry I see the output: user = 'bill' ID= 41699d4461e8fe3a71243bb3cb1c2298' You were remembered and are now being redirected to the home page. If this fails for some reason (and if you are seeing this, it probably has), please click here: To Home Page However, upon redirection to test2.php, I see: '' 31e2cab461dc525ea9a8c22e5d997db5 The session ID appears to have changed. Any idea why? 'window.location=\http://www.ericgorr.net/advciv/test2.php\;', 5000 If I go to test1.php at the above URL, I'm redirected to test2.php and my name is remembered. If it's not working for you, then the session cookie must not be getting set correctly or your browser is not accepting cookies. You can try passing the session id in the URL. 'window.location=\http://www.ericgorr.net/advciv/test2.php?; . session_name() . '=' . session_id() . \', 5000 or 'window.location=\http://www.ericgorr.net/advciv/test2.php?; . SID . \', 5000 ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Guru's advice needed ........[Security: SQL injection]
From: Marek Kilimajer [EMAIL PROTECTED] Matt Chatterley wrote: In addition to protecting against SQL Injection, has anyone here experimented with detecting and recording attempts at injection? I've been pondering checking strings which come directly from user input for sql keywords (and possibly using regexps to check for potential SQL Syntax fragments), but before I begin, I thought asking would benefit me, if someone with more experience has already tried this... This might be an interesting social study :-) It's been mentioned here before, but a good idea is to log any kind of validation errors that you get from user data. That should catch general mistakes and attempts at cross site scripting / SQL injection, depending upon your validation. The real usefulness comes from using those logs to identify areas that are difficult for your regular users to complete. If you're constantly ending up with validation errors in a date field, then it must not be clear what formats you accept or maybe you need to accept more formats. Same thing with text in a number field, and vice-versa. Use the validation logs to determine how effective your site/forms/etc are. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What does it take to give a good technical presentation?
Since I'm fresh back from php|cruise, I thought I'd comment and ask for comments on what it takes to give a good technical presentation. I'm planning on writing about this topic in my next php|architect column, so be aware that anything said here may appear in it. This is in no way a jab at any of the php|cruise presenters. Most of them did a good job and I had issues with some of them, but hell, they were doing it and I wasn't. Good info was put out either way. These are presented in random order, as they come to me and may overlap. Please add your own comments and stories. General presentation comments are fine, but try to focus on the problems or tips that help out with technical / programming type presentations. 1) Rehearse: This is a must. You have to run through your presentation a couple times and preferably in front of other people so they can provide feedback. Some people are really good at impromptu speaking and can wing it, but it still doesn't hurt to run through it just to see how long it takes. If you're given an hour for a presentation, don't rehearse a 1.5 hour presentation! When you run over it delays everything after you, too. If you're the one planning a conference, you can't necessarily plan for extra time between sessions / presentations, either. If you think you may run over on time, let the planner know. Maybe you can go last so you don't mess anyone else up? 2) Dry Run: As important as rehearsing before hand is doing a dry run of the presentation in the actual place where you'll be giving the presentation and preferably with the actual equipment you'll be using. What looks good on your CRT monitor doesn't always look good from a projector (or whatever display system they have). Do you have all of the cables you need to show your presentation? Do the colors show up (especially yellows and oranges). Can you read the fonts from the front and back of the room? Do you need a microphone? 3) Typing Code: Don't type code during your presentation. I'd bet money that everyone watching you already knows how to type. If it's a PHP conference, I'd bet they know how to type PHP, too. We don't need you to show us how. When you begin a presentation by opening up a text editor and typing ?php $fp = fopen('somefile.txt'); ... ? , I'm walking out. Either work the code (or snippets of it) into your slides, or open up a text editor and show an already completed file. If you need to make or illustrate changes to the code, either put that on subsequent slides or load sequential files where the code is already completed. 4) Text Editors: If you're going to use one, make sure you can adjust the text size. Again, what looks good and easy to read on your monitor may not during the actual presentation. Also take note of how long your lines and entire scripts are. Scrolling left and right or many pages down can be a pain during the middle of a presentation. Try to have as much code open as you can and learn / make shortcuts to get back and forth between it and your presentation that way your audience is not waiting on you. 5) Have a Buddy: This kind of goes along with all of the above suggestions; try to have a buddy that can help you rehearse and give your presentation. If you rehearse well enough, you can have your buddy flipping slides and scrolling at the right times without you having to say next slide or anything else. If you _really_ have to type, like filling out a form for example (as a demo), then have your buddy doing that while you're explaining things or make changes while you explain why he's doing so and what the results will be (for example). Hell, you can even make your buddy the bad guy that keeps you on track and on time and cuts off questions when necessary. 6) Questions: Speaking of questions, try to pause between each slide and at least look up to see if anyone has any questions. Too man people get their nose caught in the computer or looking at their slides that they miss people who want to ask a question. If you want to hold all questions until the end, make sure you say so, but understand that this will be hard for the audience to do. Also, realize that a large amount of questions may push you over your time. Don't be afraid to cut questions off when your time is up or when you really need to get to your next slide. If it's important, they'll find you or ask when there is more time. IMO, the audience likes to have face-to-face time with presenters when they have questions, anyhow, so try to make yourself available. 7) Time: Time is your enemy. This is why you rehearse and try to stay on schedule, even with questions. If you realize that you have more info to present than planned, keep in touch with whom ever is planning the conference / meeting / etc and request more time. You may or may not get it. Maybe you can be moved to last so that if you run over, you're not affecting presenters after you. 8) Graphics and Transitions: This one will probably raise some arguments, but
Re: [PHP] What does it take to give a good technical presentation?
From: Chris Shiflett [EMAIL PROTECTED] 3) Typing Code: Don't type code during your presentation. Why not? From my experience, people appreciate live demonstrations of the techniques you're discussing. Yeah, live demos are great, but I don't want to sit there and watch you type all of your PHP code. Have it already typed and just load it, explain it, and run it. Any time spent typing on the computer is going to be dead time to the audience, too, and draw your attention away from them. 8) Graphics and Transitions: This one will probably raise some arguments, but I don't see much a need for pretty graphics and transitions. Count me as arguing. :-) Pictures are good. Better are pictures that illustrate whatever it is you are discussing. If you have slide after slide of bulleted lists, you're talk is going to be boring. I hate boring talks. Maybe this is where my experience in doing briefings to military personnel vs. doing presentations to civilians would hurt me. :) If I'm boring and people fall asleep, I can make them do push-ups or jumping-jacks in the back of the room. heh... I think a better resource than these few emails is Conference Presentation Judo, a talk given by Mark Jason Dominus: http://perl.plover.com/yak/presentation/samples/slide001.html Awesome link w/great info. He agrees with you on the pictures, even if they are pointless he says. :) Although I would like to hear from other presenters and attendees on what they think with specific regards to PHP/programming presentations. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Blank Page instead of Errors
Jonathan Duncan wrote: I am getting blank pages (or partial blank pages if my HTML comes before the PHP) instead of errors. I know there are errors on the page because I have specifically put parse errors in my code to see if the server would give me errors, but instead all I get are blank pages. I have checked the PHP.INI file and I see this: error_reporting = E_ALL ~E_NOTICE display_errors = On Are you sure that's the right php.ini? Take a look at a phpinfo() page to see the actual settings your script is using. Also, do a quick View Source of the page to make sure the error isn't being hidden in an HTML element. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple question
webmaster wrote: how is the best way to keep from getting the submit button from comming through with the variables Don't name it? Just remember that users can send _any_ variable they want through a form... blindly looping through and accepting $_POST as a whole is probably a bad idea. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to keep a timestamp from updating?
From: Brian Dunning [EMAIL PROTECTED] I have a timestamp field that updates itself with NOW() every time I update the record. I don't want that to happen - I want it to remain as the original creation timestamp. How do I prevent this from happening? Set it equal to itself or use a DATETIME field. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg_replace help
From: Richard Davey [EMAIL PROTECTED] I'm sure this is blindingly simple, but could anyone tell me how to get an ereg_replace() to return a string where all characters OTHER than alpha-numerics have been stripped out? $output = ereg_replace('[^a-zA-Z0-9]','',$string); The ^ is NOT (when the first character in a bracketed character set). So anything NOT alphanumeric is replaced. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to edit a datetime field?
From: Brian Dunning [EMAIL PROTECTED] I'm trying to set a datetime field to 24 hours in the future... NOW()+6000, which worked on a timestamp field, only gives 12 seconds in the future. Algebra suggested I try NOW()+720 which is invalid. field = NOW() + INTERVAL 1 DAY or field = NOW() + INTERVAL 24 HOUR ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get form name after submission
From: Jonathan Villa [EMAIL PROTECTED] Is there a way to get the name of the form once it's submitted like $_POST['form1'] or something. No. You'd have to use javascript to set a variable upon submission and then find that variable. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace or regex
From: Adam Williams [EMAIL PROTECTED] Hi, I was wondering if I can get some help with either a str_replace or a regex. I have some data and it always begins with $$ but it can end with any letter of the alphabet. so sometimes its $$a and sometimes its $$b and sometimes $$c all the way to $$z. $$a all the way to $$z needs to be changed to a / So is there a way to do this? I was thinking of a str_replace but since the letter always changes I'm not so sure. Any help? $output = preg_replace('/\$\$[a-z]/','/',$string); If you wanted to use str_replace, then: $array = array('$$a','$$b','$$c','$$d'...); $output = str_replace($array,'/',$string); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing recordsets - only first row returned
From: Alex Hogan [EMAIL PROTECTED] I am parsing data returned from a field that looks like this; 6-8-3-5-10-9-6__7-5-9--etc... Wow... you're totally missing the point of a database when you store data like this. The code below parses out the data they way I want it but only returns the first row. I need to compare all rows and return an average from each of the parsed out numbers. Where have I made a mistake? $i = 0; $total = array(); while($row = mssql_fetch_array($result)){ So how many times does the while() loop execute? How many rows is your query actually returning? What does the output actually look like and what should it look like. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retain form values...
From: Jonathan Villa [EMAIL PROTECTED] I want to be able to submit the page to another page vs PHP_SELF. On that page I want to be able to validate the form, and if it fails, return the user to the previous page. Now that's easy, but the catch is that I want to retain/repopulate their field values. I was thinking of forcing a history.back if possible, but would rather use some server side code. I tried researching what can be done with sending headers, but I don't want to use a GET method. I want to use POST. Easiest way is to set an error and throw everything into the session. if(error) { $_SESSION['is_error'] = TRUE; $_SESSION['post'] = $_POST; } Then on your form page, check for $_SESSION['is_error'], and if it's true... $_POST = $_SESSION['post']; and use $_POST to repopulate your form (or just pull the values directly from $_SESSION). ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retain form values...
Shane McBride wrote: Actually all form validation is done before the form action takes place, so that way we do not loose input. I think you're missing the point. Client side validation is extremely easy to bypass. If that's all you're relying on, you're in trouble. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make sure a redirect works
Benjamin wrote: Henry Grech-Cini wrote: 1) Do not redirect if the page is visited as the result of a POST Why is that? I do it all the time and it seems to work fine. I have read through all the emails for this thread and didn't find anything mentioned. Am I doing something wrong? No, you're doing it right. If you don't do a redirect and someone tried to come _back_ to a page that was POSTed to, they'll have to refresh it to see it again (rePOST the data). This is why the middle-man technique is so popular. You POST to a PHP page that handles processing and then redirects to a page to show the user. This way there's no need to refresh when/if the user comes back to it. Keep in mind I'm jumping into the middle of this thead as I just resubscribed. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fmod with PHP 4.2.0 ?
From: BEOI 7308 [EMAIL PROTECTED] My ISP's PHP is 4.2.0, and the fmod function was not available before 4.2.0 My question : is there a replacement to fmod, or what can i do to do a fmod without it ? Read second comment here: http://us2.php.net/fmod ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
Will wrote: Hello All, I am having a problem. When I log into a forum it says Page Cannot Be Displayed I looked at my logs and did not find anything. I did a search everywhere and found nothing. As did your web server, apparently. :) So what page are you trying to load? It obviously doesn't exist. Your login script is probably trying to redirect you to a page that doesn't exist. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sql expression
Marc Greenstock wrote: I have a table with all the star signs, in the table are the fields 'Name','From','To'. Both the 'From' and 'To' are an integer of the relevant dates eg in the 'Gemini' row I have: Gemini, 521, 621 (521 means May 21st, 621 means June 21st). I hope I'm explaining my self ok. You should use a regular date column for your from and to dates. Now in the users table I have date of birth stored in the Date format eg; 1979-06-20. Here is my current stab at this. SELECT * FROM users WHERE MONTH(user_data.User_DOB) = 5 AND DAYOFMONTH(user_data.User_DOB) = 21 AND MONTH(user_data.User_DOB) = 6 AND DAYOFMONTH(user_data.User_DOB) = 21 and then you can do something like this: WHERE DAYOFYEAR(user_data.User_DOB) BETWEEN DAYOFYEAR(startable.from) AND DAYOFYEAR(startable.to) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email - format
Sheni R. Meledath wrote: Can any body provide me with a regular expression (as per the latest standards) to check the validity of an email address. This is covered over and over and over, 100s of times (literally) in the manual. Look through the comments in either of the regular expression chapters. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Delayed mail()... ?
From: Ben Ramsey [EMAIL PROTECTED] Finally, your system must be Linux (or other unix-type system) for this to work correctly. If it's Windows, you can use the task scheduler, but I don't think it'll execute the PHP script. Sure it will. Just put the program to run as something like this: c:\php\php.exe -q c:\path\to\script.php Or use the php-cli version. Not a big deal to do on Windows vs. Linux. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Delayed mail()... ?
From: [EMAIL PROTECTED] Basically, prospective teachers/students, can sign up for more info etc. Currently, that info is captured, and the site admin people are E-mailed... all good so far.. What they've asked for, is that when they reply to the enquiry, they are reminded to chase up the enqiry a few days later... Now I could give them a message on screen, if they happen to be in the admin area, but what i'd like to do , is simply mail the admin users, after say, 3 days. regardless if they even visit the admin area at all... How are they replying to the inquiry? If they're just using outlook and sending off a reply email, then there's no way for you to capture that reply and then do something else three days later. If they're sending a reply through your webpage, then just save the time of the reply in a database and run a cron script that looks for three day old replies and sends an email reminder. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undelivery mails
From: Juan Cortabitarte [EMAIL PROTECTED] I need to send a newsletter and I need to know all mail addresses of the undelivery mails to update the database. Any suggestion? Do I need to parse the maillog? If you're using the basic mail() function in PHP, you're not going to get any data back regarding deliveries. Some of the available SMTP classes may incorporate that, though. You'll more than likely (since you want to automate this, I imagine) have to write a PHP script that logs into a mailbox and parses the messages looking for bounces, failed delivery, etc. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending reply, the continuing
From: Lucas Gonze [EMAIL PROTECTED] On Friday, Feb 20, 2004, at 13:52 America/New_York, Pablo Gosse wrote: If by terminate the connection you mean stop sending back information to the browser, then perhaps you should look into output control functions: http://ca3.php.net/manual/en/ref.outcontrol.php Well, the best match there is ob_end_flush, as far as I can tell. Unfortunately that keeps the connection alive while the cache is being recalculated, so that even though the browser has everything it's going to get almost immediately, the throbber keeps going for quite a while, thereby freaking out my users. :( Maybe register_shutdown_function()? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending reply, the continuing
From: Lucas Gonze [EMAIL PROTECTED] Nice bit of PHP obscurantia, John. That's what I'm known for! :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heavy parsing of text, storing both versions
Justin French wrote: Hi all, I'm building a CMS that does heavy parsing of a HTML shorthand plain text to XHTML strict, in a similar way to Textile http://www.textism.com/tools/textile/. 1. Parse the text on demand into HTML -- the parsing script is to heavy/slow for this. 2. Store both the plain (shorthand HTML) text and parsed XHTML versions of each field -- the problem with this being that i'm storing double the data in the database... 3. write a reverse set of functions which converts the XHTML back to the shorthand on demand for editing -- this seems great, but I don't like the idea of maintaining two functions for such a beast. Well, you pretty much listed all of the options. Personally, I'd probably go with #2 because hard drive space is cheap. But... if the process is really that intensive and you're really that concerned about space, then I'd do #3. It doesn't seem like it'd be that hard to maintain as you're just reversing everything and how often do you expect it to change? Sorry I can't offer a better option. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] heavy parsing of text, storing both versions
joel boonstra wrote: On Fri, Feb 20, 2004 at 10:35:11AM +1100, Justin French wrote: 1. Parse the text on demand into HTML -- the parsing script is to heavy/slow for this. 2. Store both the plain (shorthand HTML) text and parsed XHTML versions of each field -- the problem with this being that i'm storing double the data in the database... combine this with versioning of each 'page', and I'm going to be storing a LOT of data in the DB. snip 3. write a reverse set of functions which converts the XHTML back to the shorthand on demand for editing -- this seems great, but I don't like the idea of maintaining two functions for such a beast. Has anyone got any further ideas? 4. Store the plain (shorthand HTML) text and when users 'save' changes, generate a static page containing the transformed XHTML version. You will have the processing overhead once (when data is changed), and everytime else visitors get static files. Isn't that just an alternate version of #2? You're still duplicating the data and taking up storage space. Again, I wouldn't really be worried about this, but that's the issue presented in #2. Sure, static files would probably be faster, but that doesn't answer the issue of when/how to do the conversion. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting age from yyyy-mm-dd
From: Ryan A [EMAIL PROTECTED] Theres a date_of_birth field there that has the values in this format -MM-DD, the client wants me to print out the age of the person from that...looking in the manual (http://se.php.net/manual/en/function.date.php) I think I will need to use mktimebut how?? Assuming you mean a database field, you can do this in your query to get the age: SELECT YEAR(CURRENT_DATE) -YEAR(dob) - (IF(DAYOFYEAR(dob)DAYOFYEAR(CURRENT_DATE),1,0)) AS age FROM table ... Where dob is the date of birth column. You could do the same thing in PHP by using strtotime() on the -MM-DD formatted date to get a Unix timestamp. Then either subtract that from the current timestamp and do the division to figure out years, or use something like the above query. date('Y',$current) - date('Y',$dob), then subtract one if the birthday day of year hasn't arrived yet. I'm sure there are a host of other ways, too. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Custom Error Handler
From: Stuart [EMAIL PROTECTED] I have a custom error handler class that's working well. My problem is that I can't find a way to find out whether a particular error has been suppressed using the @ prefix. Is there a way to do this with a custom handler? Next time start here http://us2.php.net/manual/en/function.set-error-handler.php and read everything. You'll notice this if you do: - It is important to remember that the standard PHP error handler is completely bypassed. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator. - ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include (byname.php?lang=fr);
From: John Taylor-Johnston [EMAIL PROTECTED] I want to create a language option, so the resulting html is in French or English, depending. But passing variables like this doesn't work: ?php include (../_phpcode/byname.php?lang=fr); ? echo $lang; // 'fr' Warning: main(): Failed opening '../_phpcode/byname.php?lang=fr' for inclusion (include_path='.:/usr/local/share/pear') in /home/users/q/qx04t9mu/www/.../parnoms.htm on line 125 It will work if I use a URL. ?php include (http://foo.com/_phpcode/byname.php?lang=fr;); ? echo $lang; // 'fr' Ideas on how to pass a variable? include() code runs in the same scope as where you call include(). So you can do this. $lang = 'fr'; include('../_phpcode/byname.php'); and $lang will be available within the include file. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] boolean type function ?
From: Mike Mapsnac [EMAIL PROTECTED] I search on php.net. How to declare php function as type boolean? I tried the following declaration; function booolean check_ip_remote() boolean check_ip_remote() But both declaration are wrong. I got the error messages Unless this is something new (and undocumented) with PHP5, you do not declare return types in PHP. You can return(TRUE); or return(FALSE); to actually return a boolean value, though. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why doesn't PHP see my MySQL upgrade?
From: Donpro [EMAIL PROTECTED] 1. I upgraded to PHP 4.3.4 2. I upgraded to MySQL 4.0.17 3. Restarted Apache; I even rebooted! When I run phpinfo() in my web browser, it shows: Client API version: 3.23.58 What's going on ??? That's usual, as far as I can tell. That just means PHP is using the 3.23 version of the client to connect to the server. The server is still running 4.0.17, though. There shouldn't be any issues with this. I don't think you need new client versions until you get to MySQL 4.1 and higher. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Split()
From: John Taylor-Johnston [EMAIL PROTECTED] I can do this, but want to understand how to while it: Or should I? $tempslices = explode(\r\n, $pizza); foreach ($tempslices as $singleslice) { echo a href=\http://www.foo.org$singleslice\;$singleslice/a ; } Still learning :) There's no real reason to use while() over foreach(). Why do you think you need to use while()? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with '' character
From: Chris Bruce [EMAIL PROTECTED] I am having trouble with a string becoming truncated at an '' character. I am passing the variable via a link (http://...campaign=MBI%20List%20-%20Steel%20%20Concrete) and then when I try to grab the incoming value of campaign into a SELECT query, it becomes SELECT sum(sends) from campaigns where name='MBI List - Steel ' I have tried to urlencode the variable, and also use htmlentities, etc. to no avail. Show how you tried to use urlencode() and put the value in the URL, because that's the correct solution. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class rules
From: Alex Hogan [EMAIL PROTECTED] What are the rules of thumb for classes and included files? Can I not include a file in a class function? If I put the include() outside the class structure everything works fine, but when I put it inside the class it freaks. Am I doing something wrong? Class myclass{ Include('myfile'); -- doesn't work Funciton myfunc($var1, $var2){ Include('myfile'); -- doesn't work } } It depends what's in the include file. You can do that, but the end result has to be a valid class. Using an include is basically like cutting and pasting the file at the point you have include(). So, if you're doing it this way, myfile must be variable declarations or methods, since you're already inside the class. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] diskusage
Chakravarthy Cuddapah wrote: In php I want to know space used (du) by user on a remote system. Can anyone pls tell me how this can be done. Just call du through exec(). -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phps and iis
Marek Kilimajer wrote: Anders Gjermshus wrote: Is it possible to get IIS 6 to show php sources. ( phps files ) Is it possible to set a custom 404 handler in IIS? Than you can set it to a php page, in the php page parse the request URI and highlight_file(). Good catch; never thought of that. It is possible to have a custom 404, although REQUEST_URI isn't created. You end up with a $_SERVER['QUERY_STRING'] value of 404;http://coconut/nosuchfile.php;, though, which you could parse for the original file name. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] phps and iis
Anders Gjermshus wrote: Is it possible to get IIS 6 to show php sources. ( phps files ) No. I've never seen any way to do this with IIS. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] HELP: Nested include(...)'s take relative paths not intuitively
From: Ford, Mike [LSS] [EMAIL PROTECTED] Mind you, there are exceptions: exit(), for example, is a language construct but requires the parens (at least, that's what the fine manual appears to say, and I've not tested it without!). Only if you want to pass an exit value, i.e. exit(101); otherwise just plain 'ole exit; works fine. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[4]: [PHP] HELP: Nested include(...)'s take relative paths not int uitively
From: Richard Davey [EMAIL PROTECTED] Personally I use a file called common.inc which is basically my global include file - it has nothing but variables I need set (no functions, etc - they are held elsewhere) and files I need to include. It sits at the root of my project and is included on every page. It's the only file that needs to be included. I hope you are also denying access to .inc files otherwise we could view your file as plain text. Same goes for INI files used with parse_ini_file() that are stored in the webroot. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[6]: [PHP] HELP: Nested include(...)'s take relative paths not int uitively
From: Richard Davey [EMAIL PROTECTED] JWH I hope you are also denying access to .inc files otherwise we could view JWH your file as plain text. Please.. try ;) I used to call the file common.php until we had a rather large debate about the correct naming convention for PHP include files on the PHP Community list where various people convinced me that .inc is the correct standard for include files. Heh.. I was just giving a heads up, not threatening. I personally don't care for .inc files that are in the web root. The ways to deny access to them vary across web servers and platforms, so it makes distributing your code a hassle. I know the issues with giving it a .php extension, also, but at least those issues I can control and fix and are not related to the OS or webserver. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] uploaded files are corrupted
From: Donpro [EMAIL PROTECTED] I have a script that allows the user to browse his/her local hard drive for a file and email it as an attachment. Text files come through OK but any binary type file, e.g., JPEG or PDF arrive broken. JPEG will show as a red X in my browser and Adobe will complain about the PDF. I don't know why??? How are you viewing the attachments? It's hard to tell where the issue is with that description. Look at the source code of a regular email with attachments and then compare it to the source code of the email and attachments you create with PHP. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql functions
From: Angelo Zanetti [EMAIL PROTECTED] I have a query which returns only 1 row, which of the following would be the best to get the value from the resultset: mysql_result() mysql_fetch_field() mysql_fetch_row() the resultset only returns 1 column, so basically its only 1 field i get from the resultset. mysql_result($result,0) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP: Nested include(...)'s take relative paths not intuitively
From: Samuel Ventura [EMAIL PROTECTED] I have 3 files in nested subdirectories (1) /test.php (2) /subdir1/test.php (3) /subdir1/subdir2/test.php if I call (3) it loops forever in (2) trying to including itself. Is this a bug or a feature? A feature? You make a request for (3). The thing to remember/realize is that now all require(), include(), etc. calls now happen relative to the path of (3). So, when you include (2), which tries to include ../test.php, it is trying to include itself again because the include() happens relative to the path of (3). include()'s are almost like a cut and paste. If you took the code from (2) and pasted it into (3) in place of the include(), that's the end result. This is why I do not use relative paths. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP: Nested include(...)'s take relative paths not intuitively
From: Alex Hogan [EMAIL PROTECTED] Are you saying that it's better not to use relative paths on include(...)'s, require(...)'s and their (x)_once(...) cousins? That seems awkward to me. Why would I want to hard code a path, even if I was including additional functionality from another file? Use whatever you're comfortable with because they both work. I'm just saying that I stay away from relative includes, myself. It's easy to just create a variable (or extract the data from $_SERVER) to find out the absolute path and just use that as a variable. Then you can do this: include($_CONF['path'] . '/test.php'); for example. I make similar $_CONF variables for the html root of the site $_CONF['html'] = 'http://www.bigredspark.com'; so that even the links in my html are full URLs instead of relative links. To each his own. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP: Nested include(...)'s take relative paths not intuitively
Richard Davey wrote: include $dir/file.php vs. include($dir/file.php) Both work just fine. The manual includes examples of both methods. So which do most people consider the right way ? If you use echo, then you should use include(). If you use print, then you should use include . Unless you use echo(), then you should use include and if you use print , then you should use include(). Unless you don't want to. :) Like someone else said: Personal preference. There's no right or wrong. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can PHP redirects be detected?
From: Lowell Allen [EMAIL PROTECTED] A recent thread on the WebDesign-L raised the question of whether search engines can detect (and penalize sites for) PHP redirects of the form: header(Location: http://www.whatever.com/;); I don't see how that could be the case, since the redirect occurs on the server before any HTML is output to the browser. Someone else says: No, that's not the case. What you quoted below is correct. No, the header() redirect immediately tells the /client/ to make a second GET request at a different location and the client (search bot) must actively make that 2nd request to the Location: URL (what happens if you request amazon.com) Note this is different from simply sniffing the UA string from a single request and serving altered content. What say you, PHP list? Would it be better (in terms of search engine detection) to use include() to serve different or altered content? As for whether a redirect is penalized or not, I doubt it. It'd be in the best interest of the search engine to follow the link just like it's going to follow any link on a page and index the content. Now, whether the indexed content will show up at domain.com in the search engine or domain.com/redirected/url/page.php, I don't know. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] SMTP authentication
From: Marco A. Ortiz [EMAIL PROTECTED] I want to ask you, how I must setup my PHP.INI file, to send e-mail from my Web Site if my SMTP server requires authentication. Otherwise, I want to know if exits some kind of public SMTP sever that I could use. If your SMTP server requires authentication, then you'll have to make use of a PHP class that handles this for you. I'm sure Manuel will post a specific link ;) but try searching the phpclasses.org site in the mean time. I know there are several there that implement this. The basic mail() function that uses the php.ini configuration settings cannot do authentication. Also, what's this got to do with databases??? (you posted to the php-db@ list!) This should be on php-general@ ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question About Date Function in PHP/MySQL
Freedomware wrote: When I view my data in phpMyAdmin, all I see in that column is NULL. When I preview it in a webpage, nothing displays at all. If I change it to NOT NULL, I see -00-00 in every cell. Here's a row of text from the CSV file I imported into my MySQL table: Alberta,Edmonton,1905-09-01,11,NWT,AB,CAN As you can see, the date is listed as 1905-09-01. Well, that's the right format for a MySQL date; -MM-DD, so I don't know why it wouldn't load from your CSV file. Can you show the command that you use to import the file? If the fields are NULL (or -00-00) in the database, then MySQL is not accepting your data (for the date field at least). -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question About Date Function in PHP/MySQL
Freedomware wrote: EMS lists the following: Short Date: M/d/ Long Date: , dd, Day followed by month, followed by another day, then year??? That format means something like Friday, May 5, 2004 I thought it was supposed to be year first, followed by month and day, as in the example from CSV table - 1905-09-01. Should I change Long Date so that it reads -MM-DD, or something like that? Yeah, I'd try switching possibly both the long and short dates to -MM-DD and see if it's imported correctly. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: .html or.php extension
Paul Furman wrote: If you start with one index.php then use that to include additional files, it should accept any file, even with no extension. At least it works that way for me. Just be careful with that. Remember that the files can be requested on their own, also. If you have database.inc that you include to connect ot your database and someone requests it by itself, they'll see your PHP code as plain text. Either store your includes outside of the web root, deny access to them, or give them a .php extension. Even if you give it a .php extension to hide the code, remember the file can be requested on it's own and run out of context, still. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined Index Errors
From: Cameron B. Prince [EMAIL PROTECTED] I'm creating some strings from array elements obviously. The issue is, the array elements don't always exist depending on which function you are running. And when they don't, the server log is full of undefined index errors. Is there a way I can avoid these errors without adding a if(isset(...)) around each one? Adjust your error_reporting() level so these notices don't show up. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginner question about while loops
- Original Message - From: Paul Furman [EMAIL PROTECTED] Totally ignorant need for clarification... Should I set up a counter for loops $integer++ or if I'm going through something, the while function knows to just go through those and fills in array numbers accordingly? [snip] while ($file = readdir($dh)){ if (strstr ($file, '.jpg')){ $pictures[] = $file; } With this syntax, you do not need to keep an $integer variable for the array key. When you use $array[] = something, it just assigns that value to the next available numeric key. while ($file = readdir($dh)){ if (strstr ($file, '.jpg')){ $pictures[$int++] = $file; } Would also be correct, if you wanted to keep the count yourself. You could also use array_push(). Just make sure $pictures is defined as an array before you try to push a value onto it (even using the method you have now), otherwise you'll get a warning. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginner question about while loops
From: Paul Furman [EMAIL PROTECTED] So when assigning values to an array inside a loop, it knows to advance to the next but then if I want to print those out at the same time, it's complaining while ($file = readdir($fh)){ if (strstr ($file, '.jpg')){ $pictures[] = $file; #print $pictures[]; #Fatal error: Cannot use [] for reading } var_dump ($pictures[]); #Fatal error: Cannot use [] for reading } Can't do that, like it says. You just assigned $file to $print.. so just display the value of $file. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Surpressing a 'foreach' Error Message
craig wrote: craig mailto:[EMAIL PROTECTED] on Friday, February 06, 2004 2:24 PM said: if (is_array($project)) foreach ($project as $project_id = $value) { $fields[] = $project_id; $values[] = $value; } } you're missing a curly brace after the if (). my bad, that's what you get when you don't actually run the code. Thank god for compilers ;) You'll still get the notice message with is_array(), though. Use isset(). if(isset($project)) or if(isset($project) is_array($project)) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5: __call() implementation
From: Vivian Steller [EMAIL PROTECTED] i want this function simply call the method of another class with SomeClass::$method(...) but i'm getting into trouble (bit heavy programming!:) passing the arguments (stored as Array in $params) to the SomeClass::$method([arguments]) method... further, i think i'm getting problems with objects passed through the __call() method?! Not saying that I can help you at all, but some short, example code is probably in order here. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP5: __call() implementation EXAMPLE
From: Vivian Steller [EMAIL PROTECTED] Vivian Steller wrote: Hello, as you know there is a new callback function __call($method, $params) in php5. the __call() method of an object is called, if the method named $method is not declared in this class. i want this function simply call the method of another class with SomeClass::$method(...) but i'm getting into trouble (bit heavy programming!:) passing the arguments (stored as Array in $params) to the SomeClass::$method([arguments]) method... further, i think i'm getting problems with objects passed through the __call() method?! any suggestions? thanks vivi ok, here is an example: hope you'll understand what i want... pre ?php class MyClass { function __call($method, $params) { // $params = Array(mixed var, mixed var, ...); print(request for . $method . ()\n); // how to get objects in this string?! // do i have to implement switch($type) { case object: ... } here?! $parameterstring = \ . $params[0] . \; eval(OtherClass:: . $method . ( . $parameterstring . );); Can't you just say: OtherClass::$method($params); here? } } class OtherClass { function OtherMethod($obj = false) { if(is_object($obj)) { // this method receives an object to show the difficulties with object passed through call... if(method_exists($obj, printSomething)) { $obj-printSomething(); } } else { print(Error: no object passed! ' . $obj . '\n); } } } class Whatever { function printSomething() { print(passing object through __call() is fine\n); } } $someObj = new Whatever(); // $someObj-printSomething(); $MyObj = new MyClass(); // this works perfectly $MyObj-OtherMethod(passing a string); // this is my problem... $MyObj-OtherMethod($someObj); ? /pre ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to search for a date
From: Brian Dunning [EMAIL PROTECTED] Subject: [PHP] How to search for a date A date? Well, you could try Friendster or orkut to find date, or... oh wait... Sorry this is such a basic question - but I couldn't find it online. I have a date field in MySQL: -00-00. I'm trying to insert or search for the current date, and I can't find the way to state that in the SQL. This is wrong, can someone please tell me what's correct? INSERT INTO mytable (dateField) VALUE (CURRENT_DATE); SELECT * FROM mytable WHERE dateField = CURRENT_DATE; Sucks how missing one letter will jack things up. INSERT INTO mytable (dateField) VALUES (CURRENT_DATE); Missing the S in values. That'll cause you first query to fail which will cause your second query to fail since there's no matching row. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to search for a date
From: John McKerrell [EMAIL PROTECTED] INSERT INTO mytable (dateField) VALUES (CURRENT_DATE); For MySQL you're still going to need NOW() instead of CURRENT_DATE though surely? No. He has a DATE column, so why use NOW() which includes time informatin. Quote: CURRENT_DATE and CURRENT_DATE() are synonyms for CURDATE(). Take your pick. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multilingual website
From: Shaunak Kashyap [EMAIL PROTECTED] My inclination would be to just use the DB, have linked tables with languages and pieces of text in various languages. A single query could get a full language preference setting for a site, and a little array munging could turn it into a usable set of key/value pairs, where the key is the context of the text, and the value if the text itself. (Been thinking about this alot, since I'm being asked to develop a hybrid flash/html site that needs to be in Spanish and English) Yes, I would also recommend the DB approach. The tables in your DB that contain language-sensitive information would probably have a languageId field which you could use to limit your result set to a specific language. Databases are good, but you don't want to be pulling all the text for all of your pages out of the database every time. I'd combine a database administration / storage solution that let's you store different translations of text in combination with static pages or templates that are written from the data in the database. Depending on what your site is about, how it's organized, etc, the static pages could be written as plain HTML, text, PHP include files, or even PHP variables. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] starting a session
From: Angelo Zanetti [EMAIL PROTECTED] is there ever a certain situation where you would have something at the top of your page before session_start();? If so why would it be before session_start();? Sure, there could be. It just wouldn't be able to output anything unless you were using output buffering. You may want to include library files, connect to database, etc, before you start the session. Depends upon the programmer. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing multiple Mysql tables to find duplicates
From: Chris Bruce Is there a php function that escapes single quotes in Mysql queries? addslashes() mysql_escape_string() mysql_real_escape_string() ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expressions
From: Jochem Maas [EMAIL PROTECTED] alternatively (actually this looks like the easier way to do it!) use preg_replace(), with the 'e' modifier tagged onto the end of the replacement expression: the 'e' modifier causes the expression to be evaluated as PHP. http://nl2.php.net/manual/en/function.preg-replace.php http://nl2.php.net/manual/en/pcre.pattern.modifiers.php something like: $pattern = '/\[link=quot;([[:graph:]]+)quot;]/'; $replacement = /check_this_out('\1')/e; $output = preg_replace($pattern, $replacement, $output); Good idea, except the e modifier goes in the pattern, not the replacement. And you don't need delimiters in the replacement. $pattern = '/\[link=quot;([[:graph:]]+)quot;]/e'; $replacement = check_this_out('\1'); $output = preg_replace($pattern, $replacement, $output); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Printer Friendly pages
From: Alex Hogan [EMAIL PROTECTED] I have a printer friendly page and I want to get rid of the referring url at the bottom of the page. How can I do this? I can't seem to find any reference to this in the archives. This is controlled by the browser; there's no way for PHP to change it. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New lines
From: John Nichel [EMAIL PROTECTED] If all the OP wants to do is echo out the file, then why not just use the file() function. Then each line is loaded up into an array element, and you've saved yourself a bit of cpu. And your example above doesn't address the OP's claim that it is not handling new lines. file_get_contents() would be the fastest. And once the OP learns the difference between TEXT and HTML, he'll realize he just needs to use the nl2br() function. :) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] My PHP file is not parsed
From: Reem M. [EMAIL PROTECTED] I have installed Apache 2.0.43 (win32) on my XP machine, together with PHP 4.2.3. I have configured the server to recognise PHP, local directories etc. Apache starts - no errors, and will accept PHP documents from my browser. But when I run my PHP pages, php is not parsed. I've put syntax errors purposely but it does not post any syntax errors. This is means that the php part is not parsed. What could be the problem in the configuration? Thx a lot Or it could just mean display_errors is OFF in your php.ini. Turn it on. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about dates
Renan G. Galang wrote: I just need a confirmation, when the getdate() function is invoked inside a PHP script, the date returned will be the server hosting the pages' date and not the client requesting the page, right? or am i wrong in my assumption? Thanks guys. Yes, you are not wrong in your assumption. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] formated text after Submit in MySQL/PHP
Matt Hedges wrote: Can someone help me with the following? Preferably someone other than the wise ass below? Of course... thanks matt Burhan Khalid [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Matt Hedges wrote: Hello, I have a page where users can enter in information about themselves... I want it to maintain its format instead of all running together, that is, when they enter a space the space is maintained via MySQL and displayed in their webpage (instead of having to ask them to type P) is this possible? thanks, Matt Yes. See http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-an swers.html You could try this mirror in case the other didn't work. http://www.bigredspark.com/questions-with-yes-or-no-answers.html -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 3 variables not passing to function!!!????
Ryan A wrote: I am getting everything except the 3 variables($admin,$site,$lic), heres my function: *** include_once('PRO-Config.php'); echo $admin; // This was a test to see if I am getting the value from the include..I am. function sendEmail() { [snip] Admin: $admin Site: $site Lic no: $lic variable scope, variable scope, variable scope. $admin does not exist inside the function unless you pass it or make it global. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] diff between script_filename, path_translated
From: John Schulz [EMAIL PROTECTED] After reading the manual entry on $_SERVER predefined variables, I'm unclear on the difference between 'SCRIPT_FILENAME' and 'PATH_TRANSLATED'. Results from a test script, run from a few different locations on my webserver, were always the same for these two variables. I'm especially confused by the Filesystem- (not document root-) based path comment for 'PATH_TRANSLATED'. Not sure what to say on this one other than, yeah, they're the same. :) On a pseudo-related topic: what should you use to find the absolute path from root to your application directory when you need to include a file? For example, I'm writing an application that has a function library in 'app/lib/'. From any file in the application, at any directory level, I want to be able to include specific files from the library. What's the best way to find '/absolute/path/from/root/' from '/absolute/path/from/root/app/*/any_file.php'? Since the path you get from 'DOCUMENT_ROOT' isn't necessarily where the executed file is (e.g., user directories), should that be avoided for this type of task? Not sure if this will help either, but this is what I use to determine where I'm at in scripts I write. //System path to program $this-CONF['path'] = dirname($_SERVER['PATH_TRANSLATED']); //Determine protocol of web pages if(isset($_SERVER['HTTPS']) strcasecmp($_SERVER['HTTPS'],'ON') == 0) { $this-CONF['protocol'] = 'https://'; } else { $this-CONF['protocol'] = 'http://'; } //HTML address of this program $dir_name = dirname($_SERVER['SCRIPT_NAME']); if($dir_name == '\\') { $dir_name = ''; } $this-CONF['html'] = $this-CONF['protocol'] . $_SERVER['SERVER_NAME'] . $dir_name; //Determine web address of current page $this-CONF['current_page'] = $this-CONF['protocol'] . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; Then, if all of my methods, I use $this-CONF['path'] to include files relative to the file system and $this-CONF['html'] to include files relative to the HTML root. //Include a library file include($this-CONF['path'] . '/includes/db.inc'); //Path to image img src=?=$this-CONF['html']?/images/picture.gif Hope that helps. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: parsing variables inside a variable?
From: Justin Patrin [EMAIL PROTECTED] What you need to understand is that the string parsing for variables only happens when the string is actually in your script. When you dynamically create a string (or get it from a DB) it's just a string of characters in memory and is *not* parsed. To do something like this, you would have to use one of a few things. The first would be to use some kind of search and replace to replace those variables with what you really want. $text = str_replace('$name', $name, $text); That's fairly simple and could even be done for multiple variables. foreach(array('name', 'price') as $varName) { //yes, the $$ is correct $text = str_replace('$'.$varName, $$varName, $text); } You could also use a regular expression if you *really* wanted to, but what's above is easier. For a regular expression example of how to do this: ?php $str = 'this is $name a $test'; $name = 'John'; $test = 'foobar'; $evaled_str = preg_replace('/\$([a-z0-9_]+)/ie','\$\1',$str); echo $evaled_str; ? Where $str is what's retrieved from the database with the variables in it. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] textimage
From: Maciek Hofstede [EMAIL PROTECTED] I have one problem, i can't use 'text mode' exp: echo blah; end 'image function'? exp: imagepng($rys); Any idea? I've had my coffee now and I'm still confused. What are you trying to do? I'm going to try more coffee. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Transferring an initiated Session to a Browser !!
From: Admin - CpanelPlus [EMAIL PROTECTED] I Need to access certain data in a Page protected by user login. I have written a script with socket functions which connect to port 80 and automates what any browser does. That's Ok .. Now I have the Data What I wanted in a variable. But I am also in need of a Mechanism where I can transfer an Initiated session to the User's Browser ... ( Not Just OutPutting the above variable .. But actually Transferring the Session to the User's Browser ) You want your PHP script to connect to a password protected page, retrieve information, and then pass the sucessful authentication back to the browser? So you basically want your PHP script to log in for the user, on another site, and send the resulting session, from the other site, back to the browser? If I'm understanding you correctly, I don't think you're going to be able to do this. You can't set a session cookie on behalf of the other site. You could take a look at cURL, but I don't think it'll do this. If I'm confused, please correct me. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing multiple Mysql tables to find duplicates
From: Chris Bruce [EMAIL PROTECTED] I am trying to write a function that would compare one table to a number of other tables in Mysql and remove any duplicates found. This is for tables of email addresses where I want to remove any dups found. Example: Master list - compare to list1, list2, list3, and so on and remove matches found from list1, list2, list3 etc. *not* from Master list. Does anyone know of any such beast before I set out to reinvent it? DELETE FROM list1 USING master_list, list1 WHERE list1.email = master_list.email Repeat for other tables. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparing multiple Mysql tables to find duplicates
From: Chris Bruce [EMAIL PROTECTED] Mysql 3.23.54. My first thought was to load the output from the tables into an array and they use a foreach and in_array to create a list of dups, but I wanted to see if there was an easier way. Ah, in that case, my other query won't work. :) This should: ?php $query = SELECT list1.email FROM master_list, list1 WHERE master_list.email = list1.email; $result = mysql_query($query) or die(mysql_error()); while($r = mysql_fetch_assoc($result)) { $email_list .= '{$row['email']}',; } $email_list = substr($email_list,0,-1); //remove last comma $query = DELETE FROM list1 WHERE email IN ($email_list); $result = mysql_query($query) or die(mysql_error()); ? Repeat for other tables. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do you guys do this?
From: Ryan A [EMAIL PROTECTED] I am having all the pics upload to one common directory (member_pics) so what do you suggest I name the pictures? uniqid() and md5() would come in handy here. Another question related to this, I am restricting the uploaded files to be jpg,png and gif for security..anything else you suggest for security's sake? Maybe .jpeg, also. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exectution Time?
From: Mike Mapsnac [EMAIL PROTECTED] Is there a way to find out the execution time of php program? If you start a task at 10:00 and finish at 10:15, how long did it take? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] vars in echoed file_get_contents string
Shawn McKenzie wrote: I'm having a brain fart here: ---file.php $myvar = Hello!; $stuff = file_get_contents(file.html); echo $stuff; ---file.html b$myvar/b Any ideas why when $stuff is echoed I get $myvar and not Hello? It's because you're echoing the contents of a variable, not evaluating it. Wasn't this already covered today, only pulling the string from a database? Either way, in your case you can simply say: include('file.html'); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] random?
From: Chris [EMAIL PROTECTED] $sql = SELECT * FROM agentdb WHERE ((OfficeID 214) and (agentdb.agent_id 1115421) and (agentdb.agent_id 100) and agentdb.agent_id 333)) ORDER BY RAND() LIMIT 1; It does however seem to favor one agent more than the others. Does anyone have any suggestions as to why this is occuring, please? I'd ask on a MySQL list/forum. This isn't going to be a PHP issue. Maybe MySQL's RAND() function isn't very random. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show Results one at a time ?
From: Dave Carrera [EMAIL PROTECTED] Wherever I put sleep(1), notice the comments, in the func all it dose is wait 10 seconds then shows the full output and not each result 1 at a time to the screen. Are you running this over the web or on the command line? Even though your script is staggering the output, your web server or something else may be caching it and sending it all at once. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding news items by Month
From: Michael Hill [EMAIL PROTECTED] I have a bunch of news items in a database. All of them have a date associated with them. I am trying to make a function that queries the db and tells me which months have newsitems in them(if any at all), and how many each of the months have. You should mention what database you're using when you ask questions like this. Try: SELECT MONTH(date_column), COUNT(*) FROM table GROUP BY MONTH(date_column); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PH error: Parse error: parse error, unexpected $end
From: Denham Eva [EMAIL PROTECTED] Parse error: parse error, unexpected $end Please can someone help! You need an editor that does source code highlighting. If you had that, you would not have encountered this error because you'd have noticed the unterminated string here $query = insert into work values('.$category.','.$description.','.$requestor.'); Whenever you see that error, or get a parse error on the very last line of the PHP script, it usually means you missed a quote or brace somewhere. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error fread() after switching Register Globals Off
From: Daniel Perez Clavero [EMAIL PROTECTED] Warning: fread(): supplied argument is not a valid stream resource in c:\program files\apache group\apache\htdocs\dpc\modulos\mod_ins_doc.php on line 13 I´ve got a form that calls a module to insert data. IT WAS WORKING before I switched the Register Globals to Off value. I made the proper chages to recieve variables, but i cannot make it work. Here is the code of the insert module. Since register_globals is OFF, you need to use $_FILES. The uploaded data is present in $_FILES, not $_POST. http://us2.php.net/manual/en/features.file-upload.php ? $dbhost=localhost; $dbusuario=user; $dbpassword=password; $db=database; $conexion = mysql_connect($dbhost,$dbusuario,$dbpassword); mysql_select_db($db,$conexion); $farchivo=$_POST['farchivo']; $farchivo = $_FILES['farchivo']['tmp_name']; for example... $binary = addslashes (fread(fopen($farchivo, rb), filesize($farchivo))); $nombre=$_POST['fnombre']; $descripcion=$_POST['fdescripcion']; $insert_data = INSERT INTO documentos (id, nombre, descripcion, fichero, nomfichero, tamfichero, tipofichero) VALUES ('', '$nombre','$descripcion','$binary', '$farchivo_name', '$farchivo_size', '$farchivo_type'); mysql_query($insert_data,$conexion) or die(Couldn't insert data.); header(Location: ../index.php?sec=doc0); ? The code of the form is correct. This is the name of the input fields. INPUT TYPE=\text\ NAME=\fnombre\ SIZE=\20\ CLASS=\identificationfield\; TEXTAREA name=\fdescripcion\ cols=\40\ rows=\3\ CLASS=\identificationfield\/textarea; INPUT type=\file\ name=\farchivo\ size=\30\ CLASS=\identificationfield\; ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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] 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
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] 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!!
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!!
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] Size of session?
From: motorpsychkill [EMAIL PROTECTED] I'm not sure if this has been covered (I searched the archives) but does anyone know if there is a size limit on what a session can store? What is this dependant on? I think you already got your answer. I'd just like to say that if you have to ask this question, odds are you're using sessions in a bad way... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] drop down list not populating
Montagna, Dan wrote: I've got the code for a drop down list and the drop down box displays--but with no info in it. The underlying table is populated so I could use some advice on what might be wrong from here SELECT ? include(includes/db.php); MYSQL_CONNECT(HOST,USER,PASS) OR DIE(Unable to connect to database); @mysql_select_db(DB) or die( Unable to select database); $query=(select * from community order by community); $result=mysql_query($query) or die (Unable to Make the Query: . mysql_error() ); while($row=mysql_fetch_array($result)){ Try a print_r($row) here to see what's being retrieved from the result set. echo OPTION VALUE=.$row['community']./OPTION; } ? /SELECT Any ideas? If you view the HTML source of the page, do you see a bunch of empty option elements? If so, then $row['community'] isn't valid. Maybe it's a case issue and you should be using $row['Community']? Can't tell because you're using SELECT *, though... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making Graph / Chart
unkno me wrote: Does anyone know what function is needed to make graphic chart like those line / pipe char? Any example? The easy, simple way is to just have PHP control the width of an image and stretch it. So if you had a 1x1 blue pixel image, you could stretch it 100 pixels for 100% and 50 pixels for 50%, etc... If you want more than that, Google for JPGraph. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL query
Jason Giangrande wrote: UPDATE link SET hits = hits+1 WHERE website_link = '$link' $link is the website link that was clicked on. The query works fine. The problem is if $link is a website that does not exist in the database mysql_query(); still returns true even though nothing was updated. Why is this, and anyone have any suggestions on the easiest way to check to see if $link exists in the database before updating it? There's nothing technically wrong with the query, it simply doesn't match a link so nothing is updated. That doesn't mean the query fails. Anyhow, use mysql_affected_rows() to see if any rows were affected by your query. If it's zero, then the link probably doesn't exist. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional code execution
From: Craig Jackson [EMAIL PROTECTED] This would require something like the equivalent of eval in javascript. Does PHP have that capability? Yes. Oddly enough it's called eval(). Imagine that... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [SOLVED] Beginner Q How to load externally defined function
Paul Furman wrote: You can also define your include dir in php.ini or if running as an apache mod in an .htaccess file. I had luck with the include approach: include 'c:/_Paul/web/phplib/utilities/dirfile.php'; echo scandir(); I guess it'd be more wise to put in my php.ini to save a lot of trouble. As for your php.ini, you put a path for include files that PHP will look in by default. So if you put 'c:/_Paul/web/phplib/utilities' as an include path, you'll be able to just use include 'dirfile.php'; instead of giving the complete path. Whether this is useful or not depends on you. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php