[PHP] Not sure how to loop this...(Newbie)
I have this code: $end_date = time(); $year = 2002; $month = 4; $monthi = $month + 1; $time = SecondsInMonth($month, $year); $time_i = SecondsInMonth($monthi, $year); $query = "SELECT * FROM news WHERE date $time_i AND date $time ORDER BY id"; $result = mysql_query($query); $num_results = mysql_num_rows($result); echo 'trtdh3'; echo date('F', mktime(12, 0, 0, ++$month)); echo '/h3/td'; echo 'td'; for ($i=0; $i $num_results; $i++) { $row = mysql_fetch_array($result); echo 'a href="news_temp.php?id='; echo $row['id']; echo '": '; echo $row['title']; if(!$row['date'] == 0){ echo ' - '; echo date("d-M-y", $row['date']); } echo ' :/abr'; } echo '/td/tr'; if($month == 12){ $year++; $month = 0; } And I am not sure how to loop it. It Currently prints like this: May : A Carbon Based Built Environment? - 21-May-02 : I am not sure how to get the newest records to display at the top. Rather than the bottom. There is no looping yet as I am not sure how to do it. Can I reverse to results array or something? Every month is in a new set of cells. Thanks, JJ Harrison[EMAIL PROTECTED]www.tececo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Problem
Thanks for the reply. Actually, I am using both mssql_free_query and mssql_close along with mssql_pconnect. It still happens however. I can post the code if you are unsure. Does it have a history of threading issues as it only seems to happen when several requests are sent all at once or at least in very fast succession. Justin At 06:56 PM 5/31/2002 -0700, you wrote: Hiya, were you using the appropriate free_query close functions to free up the memory more importantly the socket used to talk to the sql server? You might want to try using the _pconnect function if it's available instead of the usual _connect statement. I'd guess that PHP ran out of sockets to make outbound connections with. Also, I believe that MSSQL is setup to only have around 1000 max connections open unless you alter the value in the config. HTH, Dw Sqlcoders.com Dynamic data driven web solutions - Original Message - From: Justin Felker [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: May 31 2002 08:46 AM Subject: [PHP] MS SQL Problem Last night, I ran into a problem when using the MS SQL support in PHP under Apache/PHP module/MS SQL 2000. Everything worked well enough. I was able to connect to the server, query data, and a number of other things. However, I found that if I ran my test page (it connects to, queries and displays 20 rows of data, then disconnects) over and over very quickly (hold CTRL+R down basically) PHP would eventually (after about 6 seconds) fail to connect to the MS SQL server. In fact, the web server would have to be completely restarted before it could connect again. Has anyone run into this? I mean, if there is no solution to this and is the cause of basically shaky MS SQL support, then the SQL server would be made useless for sites with even a modest amount of traffic (several requests per second). Is this a known problem? If so, could anyone help me out? Thanks! Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Speed comparison of PHP vs. PERL (not conclusive)
Previously, Manuel Lemos wrote: Your measures do not distinguish between the compile time and execute time. I don't know about Perl, but since PHP 4, Zend engine first compiles PHP code into opcodes and only then it executes the code. Perl is compiled internally prior to execution. -- The process for understanding customers primarily involves sitting around with other marketing people and talking about what you would to if you were dumb enough to be a customer. -Scott Adams, The Dilbert Principle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing Files (Unix, Apache, PHP 4.0.X) [Newbie Alert]
John Holmes [EMAIL PROTECTED] wrote in message 001701c20901$eecbb4e0$b402a8c0@mango">news:001701c20901$eecbb4e0$b402a8c0@mango... Does the file already exist? It's not enough to change the directory permissions, you also have to change it on the file if it exists, and all of the folders above it, so that apache can get to the file. In order for PHP to open or create this file, the user that apache runs as must have permission to the folder and file. Thanks for this answer. It did not already exist, so I tried creating it, setting permissions manually and then that part worked. However, other issues popped right up, as follows: 1. I'm trying to 'include' PHP files in my scripts that contain handy functions I have prepared, like this: include 'subdir/include_file.php'; When I set the permissions on this file to read only for everybody, the include failed - I had expected only read permission to be necessary to include the file - I had to give it execute permission! Why? 2. What are the minimum permissions necessary on files to do the following with them: a) 'include' them in other PHP files [PHP] (r?) b) open them for reading only [PLAIN TEXT] (r?) c) open a new file for writing only (no prior file) [PLAIN TEXT] (w?) d) open a file for writing only when it already exists [PLAIN TEXT] (w?) e) 'unlink' a file [PLAIN TEXT] (w?) f) 'rename' a file [PLAIN TEXT] (w?) 3. What are the dangers of giving files permissions such as this (does it make my site insecure by giving too much permission, is what I'm asking)? 4. I have heard that you can impersonate different user levels when doing such operations so that you give the file different ownership - can you, should I, how do I, and what dangers are there? Bear in mind this script will be executed from the Web page as available to all and sundry. What I'm trying to do is: a) Read a text file and display contents as Web page b) Get information from the user c) Read another text file, building a new temp file as I go, and modifying the data relevant to the user input d) Deleting the old file and renaming the new to replace it Sorry for all the questions, trying to get a grip on it. I'm used to C(++) and local programs, so I don't get this problem {:v) -- _ _ o oJason Teagle [EMAIL PROTECTED] v -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Not sure how to loop this...(Newbie)
[EMAIL PROTECTED] wrote in message 010001c20934$a71ab550$0200a8c0@JohnH">news:010001c20934$a71ab550$0200a8c0@JohnH... I am not sure how to get the newest records to display at the top. Rather than the bottom. There is no looping yet as I am not sure how to do it. Can I reverse to results array or something? Every month is in a new set of cells. You should be able to reverse the order the recordsets are returned by adding DESC after ORDER BY id. You say you don't know how to loop it, but you already have a loop ( for ($i=0; $i $num_results; $i++) ) - which part do you feel also needs looping? -- _ _ o oJason Teagle [EMAIL PROTECTED] v -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variables - Using The Contents Of A Varibale Name Built Dynamically
I have found an alternate way of achieving what I want, but I'm wondering if there was an easier way. I have a PHP file that builds a Web page that includes forms. The forms are built dynamically based on the contents of a file, and thus there may be one or two or more forms on the page at any time. This means that I have controls named $btnChoice1 (first form), $btnChoice2 (second form), etc. (radio buttons). All of these forms are of a similar format, and so lead to the same PHP page in their action - a parameter is passed in the URL to identify which form it came from. When the form passes to its action file, another PHP file, there are two ways to get form data: $_POST[control_name] or $control_name. The problem is, the control name I need has to be built dynamically based on which form it came from. So I need this: $btnName = btnChoice . $form_number ; But now I have the tricky bit - $_POST[$btnName] doesn't work because it requires nested substitution of variables, and similarly I can't echo $btnName because that will of course use btnChoice2 instead of the _contents_ of the control named btnChoice2. Is it possible to 'dereference' (whatever the term is) the variable name twice? I tried $$btnName in the stupid hope that it would first interpret that to $btnChoice2 and then interpret that to the contents of the control, but of course it failed. I ended up using foreach on $_POST to pull out control names and their contents, and comparing the control name to my built-up name - but I was wondering if there's a more elegant way of doing what I wanted? Promise my next question to the group will be short {:v) -- _ _ o oJason Teagle [EMAIL PROTECTED] v -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Affiliate PHP program project - Please help
Hi PPL, I'm doing an affiliate program for a small company in PHP, but am stuck a bit in the logic or thinking process I have a table with IdNo,clicks,month,year the affiliates will get a link like this http://mysite.com/affiliates/aff.php?IdNo=775 every time I get a click from 775 in the table I am updating the table with something like clicks=clicks+1 where month=6 and year=2002 and IdNo=775 My question is how do I get the current month/year from php or do I have to query the database before every update to get month() and month(day)? will I have to use something like (for month) $mon=date(m); (for year ) $yer=date(Y); plus the main reason I am writing is to ask you gurus if I have the right idea to make this work or is it done in some other way? Maybe you have done a similar program and and can give me some valuble info/insight or wise words? ;-) OT- do you have any idea on how to contral the cursor in a form with 10 textfields? is it possible without javascript? Thanks in advance for ANY help on this, Have a great day, -Ryan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Decisions and Issues
I just want to thank everyone for their responses. I do realize this was not exactly a question that could be answered as such but I still wanted to hear some people that have had personal experiences dealing with similar issues. FYI, I have read many websites that attempt to answer this question in one way or another, but I feel that the details I can get from places such as this mailing list are much better. Anyways, to focus on one question I had asked, can anyone provide with websites that run using LAMP (large, higly trafficed websites)? http://www.sourceforge.net comes to mind, but I don't know really what's going on in the background. Specific examples would be helpful to my case. Any ideas? Justin At 12:46 PM 5/31/2002 -0500, you wrote: On Fri, 31 May 2002, Justin Felker wrote: I have spent the last hour pouring over this list's archive. (Not a flame, but I keep seeing this recently. The word is poring.) hehe, thanks. I, along with several other people am starting a business which will depend heavily on its web presence. Unfortunately, I am in the all too common position of having to make technical decisions that will have repercussions on the future well-being of said business, with little to no budget. It is crucial that the solution I pick, handle what we hope will become a very large load in the not-to-distant future (whether this happens or not is a question for another day, heh). To this end, I am very interested in using the LAMP (Linux+Apache+MySQL+PHP) approach. I have experience with all of these technologies, but I am definitely not in a position to vouch for their worthiness for use in a large scale application running beneath a heavy load. To quantify LAMP's ability, is it appropriate for say, sites that generate on the order of 5 million unique hits per day? If not, where would you draw the line? At 500,000? Or 1 million? If so, how much higher could it go possibly? 10 million? 20? . . . So, what say you? Given all that I have said, is LAMP appropriate? Will PHP and maybe even more importantly, MySQL be able to scale well? I have no doubt that MySQL is fast, but just how scaleable is it? Will it die beneath the kind of loads I have described? It's really difficult to answer this question without knowing a lot more about your application. But as a casual guess, if you reach that sort of traffic level, I'd say your stumbling block is going to by MySQL. At some point - granted, that point can be far away if you design your database and queries well - it will buckle under load. I'm too busy actually working, unfortunately, to pay attention to the bleeding edge developments in MySQL. But as it stands, there's no serious support for clustering, which means that when you are pushing more transactions than can be handled by the most expensive single machine you can afford, you've hit a brick wall. And as you know, there is a point after which multiple lesser-powered machines are a whole lot cheaper than a single mighty one. If your database transactions are mostly read-only, and you can segregate the infrequent write transactions to a separate server, you can do jury-rigged replication of the main data store and scale indefinitely. Otherwise, you'll probably have to plan with an eye to a migration path toward Oracle, DB2, or whatever. This doesn't mean you can't start out with MySQL, but it does mean you should develop with a database abstraction layer and shouldn't depend on features that are fast in MySQL but poorly supported by other databases (or emulated in the abstraction layer). As for Linux, Apache, and PHP, there's no limit to the transaction volume you can handle with even rudimentary load-balancing tactics, so that's nothing to worry about. miguel -- 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] Hi all Help :D
I have sorted the problem, thanks for all the support Adam Voigt [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Try reversing the filelocations in your ftp_put, like if you have remotelocation and mylocation, switch them to say mylocation then remotelocation. Just a thought. Adam Voigt [EMAIL PROTECTED] On Thu, 2002-05-30 at 22:26, Anthony wrote: Hi all, this is my first post on the php news groups, and im sure it wont be my last so I will first introduce my self, because im sure there are some regualar posters ;) My name is Anthony.. Im 14 years old and live in england, anything else you want to know ask :) Im working on a FTP uploader in php, but not for my own site, I want to offer it was a service to so over people can upload to there sites using my FTP script... but when you put the destonation (once they have connected) to / it trys to upload to a path in my site.. can any one explain why this is and how to correct it, It would be aprechiated a lot, thanks -- 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 Digest 1 Jun 2002 10:39:18 -0000 Issue 1379
php-general Digest 1 Jun 2002 10:39:18 - Issue 1379 Topics (messages 100184 through 100215): Re: Speed comparison of PHP vs. PERL (not conclusive) 100184 by: Ilia A. 100186 by: Manuel Lemos 100206 by: Jason Wong 100209 by: Dan Lowe Finding what headers and content were already been sent 100185 by: Noor Dawod 100187 by: Rasmus Lerdorf 100188 by: Noor Dawod 100190 by: Rasmus Lerdorf 100191 by: Noor Dawod 100192 by: Rasmus Lerdorf seesion_register() with arrays 100189 by: Douglas - IG 100195 by: John Holmes cache control and cookies... 100193 by: Gerard Samuel Re: diplaying the path 100194 by: Philip Olson Re: Writing Files (Unix, Apache, PHP 4.0.X) [Newbie Alert] 100196 by: John Holmes 100210 by: Jason Teagle Re: Form content type missing, how to fetch variables? 100197 by: Simon Troup 100198 by: John Holmes 100199 by: Simon Troup Apache, html, php and global variables 100200 by: Peter Goggin 100201 by: Stuart Dallas 100204 by: Peter Goggin 100205 by: John Holmes Folio Infobase Parser/Converter 100202 by: Richard Lynch Re: Parsing file's 100203 by: Scott Not sure how to loop this...(Newbie) 100207 by: webmaster.tececo.com 100211 by: Jason Teagle Re: MS SQL Problem 100208 by: Justin Felker Variables - Using The Contents Of A Varibale Name Built Dynamically 100212 by: Jason Teagle Affiliate PHP program project - Please help 100213 by: r Re: PHP Decisions and Issues 100214 by: Justin Felker Re: Hi all Help :D 100215 by: Anthony Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- I agree that in most cases it makes more sence at seing the webpages per second benchmark rather then a timing of some artibtrary benchmarks that for example seeing how long it take to pick prime numbers. Since in the end it matters how quickly you can get the data to the user, in case of perl programs there would be the overhead of spawning a cgi program, (unless mod_perl is used) which would negate much of the speed improvment gained by Perl. All that said, loops are very very common in PHP, and are used with virtually in any script that uses a database wether it be SQL or flatfile to loop through the result set. Since this appears to be a known performance issue, perphaps it is something the PHP Development team could consider improving for PHP 5.0 Ilia On May 31, 2002 06:00 pm, Rasmus Lerdorf wrote: Sure, you could put it that way. When benchmarking something you really should benchmark stuff that you actually care about. Benchmark PHP spewing out a web page after making a couple of SQL queries, for example. That's typical usage, so that is what you should benchmark. Very few PHP scripts are going to loop a couple of hundred thousand times to do something. -Rasmus On Fri, 31 May 2002, Ilia A. wrote: Does this mean that running a comparison benchmarks between PHP and any other language would in many cases show PHP to be slower simply because it's looping code is slow? Unless, timing is done on a speed of PHP being able to spew out webpages via the webserver with a webserver benchmark tool such as apachebench? Wouldn't that cause any benchmarks trying to guage the speed of PHP virtually meaningless because of the 'loop' overhead, which is clearly great enough to make PHP way slower in comparison to Perl for example? Ilia On May 31, 2002 05:38 pm, Rasmus Lerdorf wrote: Not very surprising. Perl's looping code has always ben faster than PHP's. Highly iterative loops is really not what PHP is geared for. You are not going to write a Mandelbrot algorithm in PHP. You write it in C and drop in a super-quick extension into PHP and call mandelbrot(). -Rasmus On Fri, 31 May 2002, Daniel Grace wrote: This all started in a little debate between me and a friend of mine who I think is as much a PERL zealot as I am a PHP zealot (I was briefly pondering the idea of a Win32 API extension for PHP), and the results were rather surprising -- to me, at least.. It all started when I asked him what PERL had that PHP didn't in terms of language (not taking community, modules, etc. into an account). We both believed that the two would be very similiar in speed -- he thought PERL would be a little faster but not enough to be noticeable. For the first test, I went with a program that computed prime numbers between 2 and 1, using no form of caching or anything like that. I gave him the PHP source with the task of
[PHP] Re: Variables - Using The Contents Of A Varibale Name Built Dynamically
You could give the button the same name in each form - only the fields in between the form/form tags is actually submitted, then put a hidden field in the form that uniquely identifies the data being submitted. Just a thought... it is what I usually do... Mikey Jason Teagle [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have found an alternate way of achieving what I want, but I'm wondering if there was an easier way. I have a PHP file that builds a Web page that includes forms. The forms are built dynamically based on the contents of a file, and thus there may be one or two or more forms on the page at any time. This means that I have controls named $btnChoice1 (first form), $btnChoice2 (second form), etc. (radio buttons). All of these forms are of a similar format, and so lead to the same PHP page in their action - a parameter is passed in the URL to identify which form it came from. When the form passes to its action file, another PHP file, there are two ways to get form data: $_POST[control_name] or $control_name. The problem is, the control name I need has to be built dynamically based on which form it came from. So I need this: $btnName = btnChoice . $form_number ; But now I have the tricky bit - $_POST[$btnName] doesn't work because it requires nested substitution of variables, and similarly I can't echo $btnName because that will of course use btnChoice2 instead of the _contents_ of the control named btnChoice2. Is it possible to 'dereference' (whatever the term is) the variable name twice? I tried $$btnName in the stupid hope that it would first interpret that to $btnChoice2 and then interpret that to the contents of the control, but of course it failed. I ended up using foreach on $_POST to pull out control names and their contents, and comparing the control name to my built-up name - but I was wondering if there's a more elegant way of doing what I wanted? Promise my next question to the group will be short {:v) -- _ _ o oJason Teagle [EMAIL PROTECTED] v -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] problems with installing freetype2
Hi there, I have problems to find out if the installation of freetype 2 has been successfull. It seems that only freetype 1 is running, since I can not use some commands. something went wrong, but there have been no complains during installation. Thanx for any help, andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Affiliate PHP program project - Please help
UPDATE table SET click = click + 1 WHERE month = MONTH(NOW()) AND year = YEAR(NOW()) AND id = 775 Don't need to use PHP at all... ---John Holmes... -Original Message- From: r [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 6:13 PM To: [EMAIL PROTECTED] Subject: [PHP] Affiliate PHP program project - Please help Hi PPL, I'm doing an affiliate program for a small company in PHP, but am stuck a bit in the logic or thinking process I have a table with IdNo,clicks,month,year the affiliates will get a link like this http://mysite.com/affiliates/aff.php?IdNo=775 every time I get a click from 775 in the table I am updating the table with something like clicks=clicks+1 where month=6 and year=2002 and IdNo=775 My question is how do I get the current month/year from php or do I have to query the database before every update to get month() and month(day)? will I have to use something like (for month) $mon=date(m); (for year ) $yer=date(Y); plus the main reason I am writing is to ask you gurus if I have the right idea to make this work or is it done in some other way? Maybe you have done a similar program and and can give me some valuble info/insight or wise words? ;-) OT- do you have any idea on how to contral the cursor in a form with 10 textfields? is it possible without javascript? Thanks in advance for ANY help on this, Have a great day, -Ryan. -- 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] Apache, html, php and global variables
I am not clear what you mean by this. I have set session_start() on in the php script that logs onto the database initially. i then call a test php script from a button on the menu frame. This is the output it gives: Test php variables Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: Cannot send session cache limiter - headers already sent (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in c:\usr\www\my-domain\maintenance.php on line 5 Test of global variables DBA USER: DBA Password; Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 The script is: HTML BODY Test php variablesBR ?php session_start(); printf (Test of global variablesBR); printf (DBA USER: ,$_SESSION_VARS[dbauser],BR); printf (BR); printf (DBA Password; ,$_SESSION_VARS[dbapassword],BR); ? /BODY /HTML Is there a problem with how I am using sessiot_start, or is there a php config problem? Regards Peter Goggin - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Peter Goggin' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 2:04 PM Subject: RE: [PHP] Apache, html, php and global variables You still have to connect to a database every time a script is run, whether it's loaded in a frame or run by itself. If you start a session and save the username and password in it, then you can use that login and password on every other page that you call session_start() on. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:12 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables I am not certain how this helps me, since it appears the data is only carried to pages called directly from where it is set. The page where the user logs onto the database does not link to other pages. This is done from the top frame of the form. The top frame of the inital page contains the menu, one option of which is to log onto the data base to start a session. The user will then select another page from the top form. This new page is displayed in the bottom frame of the intial page, and there may be futher links within this page on the bottom fram.Generally however main navigation is from the top frame which remains in place through out. What I wabt to do is to have the login information available at all times once the user is logged in, nomattar how the current page is called. Is this possible? If so how is this done? - Original Message - From: Stuart Dallas [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 11:56 AM Subject: Re: [PHP] Apache, html, php and global variables On Saturday, June 1, 2002 at 2:42:40 AM, you wrote: Is there any way of caryying the login information from one web page to the next in global variables so that the username and password entered in the login screen is available to all other web pages in the site or do I have to ask the user to re-enter this information at every screen? Sessions: http://www.php.net/session -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Apache, html, php and global variables
Sessions use cookies, which use headers, which have to be sent before any output. html is output. So, put session_start() before that. ? Session_start(); ... ? html body ... Where are you putting dbauser and dbapassword into the session? Your sessions still aren't going to work because the session.save_path isn't set correctly in your PHP.ini. Set it to a directory on your computer that the web server has access to write to. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 9:54 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables I am not clear what you mean by this. I have set session_start() on in the php script that logs onto the database initially. i then call a test php script from a button on the menu frame. This is the output it gives: Test php variables Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: Cannot send session cache limiter - headers already sent (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in c:\usr\www\my-domain\maintenance.php on line 5 Test of global variables DBA USER: DBA Password; Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 The script is: HTML BODY Test php variablesBR ?php session_start(); printf (Test of global variablesBR); printf (DBA USER: ,$_SESSION_VARS[dbauser],BR); printf (BR); printf (DBA Password; ,$_SESSION_VARS[dbapassword],BR); ? /BODY /HTML Is there a problem with how I am using sessiot_start, or is there a php config problem? Regards Peter Goggin - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Peter Goggin' [EMAIL PROTECTED]; php- [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 2:04 PM Subject: RE: [PHP] Apache, html, php and global variables You still have to connect to a database every time a script is run, whether it's loaded in a frame or run by itself. If you start a session and save the username and password in it, then you can use that login and password on every other page that you call session_start() on. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:12 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables I am not certain how this helps me, since it appears the data is only carried to pages called directly from where it is set. The page where the user logs onto the database does not link to other pages. This is done from the top frame of the form. The top frame of the inital page contains the menu, one option of which is to log onto the data base to start a session. The user will then select another page from the top form. This new page is displayed in the bottom frame of the intial page, and there may be futher links within this page on the bottom fram.Generally however main navigation is from the top frame which remains in place through out. What I wabt to do is to have the login information available at all times once the user is logged in, nomattar how the current page is called. Is this possible? If so how is this done? - Original Message - From: Stuart Dallas [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 11:56 AM Subject: Re: [PHP] Apache, html, php and global variables On Saturday, June 1, 2002 at 2:42:40 AM, you wrote: Is there any way of caryying the login information from one web page to the next in global variables so that the username and password entered in the login screen is available to all other web pages in the site or do I have to ask the user to re-enter this information at every screen? Sessions: http://www.php.net/session -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL Problem
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi there, I remember reading of a config setting in php.ini which lowered the time PHP waits before clearing up/closing the socket out. If it's a linux system you might want to try running netstat to see the open net connections. If you see lots of open connections when you reload the page a few times to your sql server then you know you need to shorten the appropiate timeouts. If you dont see lots of open connections then it's something unrelated to the actual virtual circuits opened. HTH, Dw. - - Original Message - From: Justin Felker [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: May 31 2002 11:21 PM Subject: Re: [PHP] MS SQL Problem Thanks for the reply. Actually, I am using both mssql_free_query and mssql_close along with mssql_pconnect. It still happens however. I can post the code if you are unsure. Does it have a history of threading issues as it only seems to happen when several requests are sent all at once or at least in very fast succession. Justin At 06:56 PM 5/31/2002 -0700, you wrote: Hiya, were you using the appropriate free_query close functions to free up the memory more importantly the socket used to talk to the sql server? You might want to try using the _pconnect function if it's available instead of the usual _connect statement. I'd guess that PHP ran out of sockets to make outbound connections with. Also, I believe that MSSQL is setup to only have around 1000 max connections open unless you alter the value in the config. HTH, Dw Sqlcoders.com Dynamic data driven web solutions - Original Message - From: Justin Felker [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: May 31 2002 08:46 AM Subject: [PHP] MS SQL Problem Last night, I ran into a problem when using the MS SQL support in PHP under Apache/PHP module/MS SQL 2000. Everything worked well enough. I was able to connect to the server, query data, and a number of other things. However, I found that if I ran my test page (it connects to, queries and displays 20 rows of data, then disconnects) over and over very quickly (hold CTRL+R down basically) PHP would eventually (after about 6 seconds) fail to connect to the MS SQL server. In fact, the web server would have to be completely restarted before it could connect again. Has anyone run into this? I mean, if there is no solution to this and is the cause of basically shaky MS SQL support, then the SQL server would be made useless for sites with even a modest amount of traffic (several requests per second). Is this a known problem? If so, could anyone help me out? Thanks! Justin -- 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 -BEGIN PGP SIGNATURE- Version: PGP Personal Privacy 6.5.8 iQA/AwUBPPljiNf2pW/GxlpVEQLy9wCg3tHovxdcVNthQvHyGY0brheJOqsAn28o yFtm2vp4juq7zFZcQy8G9Qfp =2jJv -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A small question - Mysql_insert_id
Hi, I am inserting a row into a table with this structure id (auto increment) name (varchar) hits (int) I am using insert into mytable values(NULL,'Ryan',90); Then according to the manual I have to use (to quote) printf (Last inserted record has id %d\n, mysql_insert_id()); will this return the row number or the id fields value..? If it returns the row number how do I get the ID number? The id started at 1500. Cheers, -Ryan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A small question - Mysql_insert_id
r I am inserting a row into a table with this structure r id (auto increment) ... Assuming you mean ID int not null primary key auto_increment (or something like that). r Then according to the manual I have to use (to quote) r printf (Last inserted record has id %d\n, mysql_insert_id()); r will this return the row number or the id fields value..? FYI, you could: a) try it and see b) see what the manual has to say: http://www.php.net/manual/en/function.mysql-insert-id.php The answer is Gets the id generated from the previous INSERT operation. - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A small question - Mysql_insert_id
Hey Julie, Thanks for replying, Actually the ID field is not null,primary and auto_increment. Thanks for the URL but in my message I did quote the line from that same url (http://www.php.net/manual/en/function.mysql-insert-id.php) I just need to get the ID of the just inserted record. Any ideas? Cheers, -Ryan. r I am inserting a row into a table with this structure r id (auto increment) ... Assuming you mean ID int not null primary key auto_increment (or something like that). r Then according to the manual I have to use (to quote) r printf (Last inserted record has id %d\n, mysql_insert_id()); r will this return the row number or the id fields value..? FYI, you could: a) try it and see b) see what the manual has to say: http://www.php.net/manual/en/function.mysql-insert-id.php The answer is Gets the id generated from the previous INSERT operation. - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A small question - Mysql_insert_id
On Sunday, June 2, 2002 at 4:07:31 AM, you wrote: will this return the row number or the id fields value..? If it returns the row number how do I get the ID number? The id started at 1500. From the manual page for mysql_insert_id()... mysql_insert_id() returns the ID generated for an AUTO_INCREMENT column by the previous INSERT query In other words, it returns the id fields value. Don't take this the wrong way, but you clearly didn't look this up in the manual. This list is to help with real problems, not manual lookups. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] A small question - Mysql_insert_id
r Actually the ID field is not null,primary and auto_increment. Well, it has to be of a TYPE as well... r Thanks for the URL but in my message I did quote the line from that same url r (http://www.php.net/manual/en/function.mysql-insert-id.php) r I just need to get the ID of the just inserted record. I'm just going to assume you're f*cking with all of us and leave it at that. - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML to ARRAY
Here is a piece of code, that is close to doing what I want it to. The end result I would like to have is an array that is simple to work with. If the XML tag was issue-nameRED HAT/issue-name, I would like something like the following: $Tags['issue-name']. So I could print it out. Something like, print $Tags['issue-name']br\n; I was able to get a numerical representation of the array like, $Tags[5] and the value of that tag was RED HAT, but then I would have to know what the position of the data I am looking for in the array. I would prefer to know the tag name and the array and get to the data that way. I know there is a way to do this, but I just can't figure it out. There is a lot of information on Parsing the XML file but not getting into a useful array, or at least that I have found easily to understand. if(!isset($Sym)) { $Sym = 'IKN'; } $URI = 'http://quotes.nasdaq.com/quote.dll?page=xmlmode=stocksymbol='; $simple = implode( '', file($URI$Sym)); $p = xml_parser_create(); xml_parse_into_struct($p,$simple,$vals,$index); xml_parser_free($p); file://echo Index array\n; file://print_r($index); file://echo \nVals array\n; file://print_r($vals); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Julie- A small question - Mysql_insert_id
Hey Julie, Sorry, am not f*cking with you or anybody, just new to databases in PHP, I'm from a java servlet background and we dont have this kind of function there. I'm sorry if I offended you or made you think that I was pulling your leg, its just that after 7 hours of programming the manual looks mighty confusing even if the explanation is simplecomputers look confusing now;-) Am a newbie in PHP and a pure virgin in database programming using PHP, hope you understand. Sorry again and have a great day, -Ryan r Actually the ID field is not null,primary and auto_increment. Well, it has to be of a TYPE as well... r Thanks for the URL but in my message I did quote the line from that same url r (http://www.php.net/manual/en/function.mysql-insert-id.php) r I just need to get the ID of the just inserted record. I'm just going to assume you're f*cking with all of us and leave it at that. - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] value passing from html form to php variable.
I am not sure if this is the right place to ask this naive question. I got a simple form addform.html and add.php look like the following. But everytime I got empty value from firstname and lastname. It seems like the input value in the html page was not passed on to the php variable $firstname in add.php. Anyone give me a hand on this naive question? Great thanks. Wei addform.html html body form action=add.php method=post First Name : input type=text name=firstname size=40 length=40 value=BR Surname : input type=text name=surname size=40 length=40 value=BR input type=submit name=submit value=Submit input type=reset name=reset value=Clear It /form /body /html add.php html body ?php $db = pg_connect(dbname=friends); $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), '$firstname', '$surname'); $result = pg_exec($db, $query); if (!$result) { printf (ERROR); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf (These values were inserted into the database - %s %s, $firstname, $surname); pg_close(); ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] value passing from html form to php variable.
On Saturday, June 1, 2002 at 4:51:20 PM, you wrote: I got a simple form addform.html and add.php look like the following. But everytime I got empty value from firstname and lastname. It seems like the input value in the html page was not passed on to the php variable $firstname in add.php. Anyone give me a hand on this naive question? You probably have register_globals turned Off in your php.ini file. If you do then you can either turn it on or use the recommended method of accessing POSTed variable: $_POST['firstname']. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reg exp problems
Hi, I've never used a reg exp, but I was trying to do something simple, and I just can't seem to do it :) I have a varible $fdata which contains the contents of a webpage, and I want to strip out the base tag. I try: $fdata = preg_replace(base.*,,$fdata); But its stripping out everything between the first base and the last on that line, instead of the of the at the end of the base tag Hope that makes sense :) TIA Andrew
Re: [PHP] value passing from html form to php variable.
Do you mind telling me where this php.ini is? And I tried the second attempt like this: $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); which returns error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5 Oy Sat, 1 Jun 2002 16:57:00 +0100 [EMAIL PROTECTED] (Stuart Dallas) wrote: On Saturday, June 1, 2002 at 4:51:20 PM, you wrote: I got a simple form addform.html and add.php look like the following. But everytime I got empty value from firstname and lastname. It seems like the input value in the html page was not passed on to the php variable $firstname in add.php. Anyone give me a hand on this naive question? You probably have register_globals turned Off in your php.ini file. If you do then you can either turn it on or use the recommended method of accessing POSTed variable: $_POST['firstname']. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] value passing from html form to php variable.
Some thoughts: a) Why is $firstname empty? It's empty because the PHP directive register_globals = off. So, PHP will not create $firstname automatically. This is most likely the cause. b) How do I access $firstname with register_globals = off then? Many ways. Regardless of register_globals setting, the information is available in many ways, like: // Worked since PHP 3 print $HTTP_POST_VARS['firstname']; // Worked since PHP 4.1.0 print $_POST['firstname']; Or, you can create $firstname (or something similar) with either extract() or import_request_variables(). Like: import_request_variables('gpc', 'r_'); print $r_firstname; extract($_POST); print $firstname; c) What is register_globals? A controversial PHP directive. As of PHP 4.2.0, this directive defaults to off. Before this, it was on. So, many books, articles, tutorials, etc. rely on it on, which makes life interesting in the PHP world today. http://www.php.net/manual/en/security.registerglobals.php There are many predefined variables, such as $_GET, too. http://www.php.net/manual/en/language.variables.predefined.php Regards, Philip Olson On Sat, 1 Jun 2002, Wei Wang wrote: I am not sure if this is the right place to ask this naive question. I got a simple form addform.html and add.php look like the following. But everytime I got empty value from firstname and lastname. It seems like the input value in the html page was not passed on to the php variable $firstname in add.php. Anyone give me a hand on this naive question? Great thanks. Wei addform.html html body form action=add.php method=post First Name : input type=text name=firstname size=40 length=40 value=BR Surname : input type=text name=surname size=40 length=40 value=BR input type=submit name=submit value=Submit input type=reset name=reset value=Clear It /form /body /html add.php html body ?php $db = pg_connect(dbname=friends); $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), '$firstname', '$surname'); $result = pg_exec($db, $query); if (!$result) { printf (ERROR); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf (These values were inserted into the database - %s %s, $firstname, $surname); pg_close(); ? /body /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] value passing from html form to php variable.
$query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); which returns error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5 When using arrays in strings, things are done a little differently: print a $arr[key] string; print a {$arr['key']} string; print a . $arr['key'] . string; Be sure to always surround keys with quotes outside of strings otherwise PHP looks for a CONSTANT named key first, instead. define ('a','b'); $arr = array('a' = 'apple', 'b' = 'banana'); print $arr[a]; // banana print $arr[a]; // apple print $arr['a']; // apple Regards, Philip Olson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] value passing from html form to php variable.
On Saturday, June 1, 2002 at 5:00:18 PM, you wrote: Do you mind telling me where this php.ini is? Create a php script containing just ?php phpinfo(); ?. That page will tell you where your php.ini is (or should be). And I tried the second attempt like this: $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); which returns error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5 Try this... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] value passing from html form to php variable.
Create a php script containing just ?php phpinfo(); ?. That page will tell you where your php.ini is (or should be). it told me it's in php/lib, but it's not there. Try this... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); When I input Wei for firstname and Wang for surname in the form and submit, I got error: Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6 ERRORERROR: Attribute 'andras' not found ps. Philip, Great thanks for your detailed help. I still couldn't figure out how to access $firstname. And I couldn't find php.ini, which should be the most straightforward way to solve this. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] value passing from html form to php variable.
Sorry. When I input Andras as firstname in the form, ... On Sat, 1 Jun 2002 17:22:02 +0100 [EMAIL PROTECTED] (Wei Wang) wrote: Create a php script containing just ?php phpinfo(); ?. That page will tell you where your php.ini is (or should be). it told me it's in php/lib, but it's not there. Try this... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); When I input Wei for firstname and Wang for surname in the form and submit, I got error: Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6 ERRORERROR: Attribute 'andras' not found ps. Philip, Great thanks for your detailed help. I still couldn't figure out how to access $firstname. And I couldn't find php.ini, which should be the most straightforward way to solve this. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[4]: [PHP] value passing from html form to php variable.
On Saturday, June 1, 2002 at 5:22:02 PM, you wrote: Create a php script containing just ?php phpinfo(); ?. That page will tell you where your php.ini is (or should be). it told me it's in php/lib, but it's not there. The default php.ini is called php.ini-recommended and will be in the directory where you installed PHP. Copy it to php/lib and rename it to php.ini. When PHP can't find php.ini it uses it's built-in defaults - these set register_globals to off. When I input Wei for firstname and Wang for surname in the form and submit, I got error: Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6 ERRORERROR: Attribute 'andras' not found Show us what is on line 6 and a couple of lines either side of it. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] value passing from html form to php variable.
Is there anything I should do to make the php.ini come into effect? I did put the register_global = On but still got empty values. And my $_POST version is like this: ?php $db = pg_connect(dbname=friends); $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); $result = pg_exec($db, $query); if (!$result) { printf (ERROR); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf (These values were inserted into the database - %s %s, $firstname, $surname); pg_close(); ? /body /html On Sat, 1 Jun 2002 17:08:11 +0100 [EMAIL PROTECTED] (Stuart Dallas) wrote: On Saturday, June 1, 2002 at 5:00:18 PM, you wrote: Do you mind telling me where this php.ini is? Create a php script containing just ?php phpinfo(); ?. That page will tell you where your php.ini is (or should be). And I tried the second attempt like this: $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); which returns error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5 Try this... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[4]: [PHP] value passing from html form to php variable.
Sorry. I restared apache and php.ini came into effect. On Sat, 1 Jun 2002 17:29:13 +0100 [EMAIL PROTECTED] (Stuart Dallas) wrote: On Saturday, June 1, 2002 at 5:22:02 PM, you wrote: Create a php script containing just ?php phpinfo(); ?. That page will tell you where your php.ini is (or should be). it told me it's in php/lib, but it's not there. The default php.ini is called php.ini-recommended and will be in the directory where you installed PHP. Copy it to php/lib and rename it to php.ini. When PHP can't find php.ini it uses it's built-in defaults - these set register_globals to off. When I input Wei for firstname and Wang for surname in the form and submit, I got error: Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6 ERRORERROR: Attribute 'andras' not found Show us what is on line 6 and a couple of lines either side of it. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[4]: [PHP] value passing from html form to php variable.
On Saturday, June 1, 2002 at 5:35:03 PM, you wrote: Is there anything I should do to make the php.ini come into effect? I did put the register_global = On but still got empty values. you may not need to do anything or you may need to restart your http server. Have a look at your phpinfo() page. If it's picking up the php.ini file then it will show it's filename as well as it's path. ?php $db = pg_connect(dbname=friends); $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); $result = pg_exec($db, $query); if (!$result) { printf (ERROR); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf (These values were inserted into the database - %s %s, $firstname, $surname); pg_close(); ? /body /html Hmm, line 6 of that code would be printf (ERROR); but I'll assume that you haven't included the first few lines and that line 6 is actually the pg_exec line. You haven't changed $query as I suggested in a previous message. Change the $query = line to the following... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[6]: [PHP] value passing from html form to php variable.
On Saturday, June 1, 2002 at 5:37:37 PM, you wrote: Sorry. I restared apache and php.ini came into effect. If you're going to run with register_globals on you should make sure you understand the implications: http://www.php.net/manual/en/security.registerglobals.php. -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[4]: [PHP] value passing from html form to php variable.
Changed the query and get this error when input dave as firstname: ERRORERROR: Attribute 'dave' not found add2.php is: html body ?php $db = pg_connect(dbname=friends); $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); $result = pg_exec($db, $query); if (!$result) { printf (ERROR); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf (These values were inserted into the database - %s %s, $firstname, $surname); pg_close(); ? /body /html addform.php is: html body form action=add2.php method=post First Name : input type=text name=firstname size=40 length=40 value=BR Surname : input type=text name=surname size=40 length=40 value=BR input type=submit name=submit value=Submit input type=reset name=reset value=Clear It /form /body /html On Sat, 1 Jun 2002 17:44:57 +0100 [EMAIL PROTECTED] (Stuart Dallas) wrote: On Saturday, June 1, 2002 at 5:35:03 PM, you wrote: Is there anything I should do to make the php.ini come into effect? I did put the register_global = On but still got empty values. you may not need to do anything or you may need to restart your http server. Have a look at your phpinfo() page. If it's picking up the php.ini file then it will show it's filename as well as it's path. ?php $db = pg_connect(dbname=friends); $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname']); $result = pg_exec($db, $query); if (!$result) { printf (ERROR); $errormessage = pg_errormessage($db); echo $errormessage; exit; } printf (These values were inserted into the database - %s %s, $firstname, $surname); pg_close(); ? /body /html Hmm, line 6 of that code would be printf (ERROR); but I'll assume that you haven't included the first few lines and that line 6 is actually the pg_exec line. You haven't changed $query as I suggested in a previous message. Change the $query = line to the following... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reg exp problems
On Saturday 01 June 2002 23:56, Andrew Brampton wrote: Hi, I've never used a reg exp, but I was trying to do something simple, and I just can't seem to do it :) I have a varible $fdata which contains the contents of a webpage, and I want to strip out the base tag. I try: $fdata = preg_replace(base.*,,$fdata); But its stripping out everything between the first base and the last on that line, instead of the of the at the end of the base tag Try: (it should remove base /base) preg_replace(/(base)|(\/base)/, , $fdata); *** Untested, use at your own risk *** -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* When you make your mark in the world, watch out for guys with erasers. -- The Wall Street Journal */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[6]: [PHP] value passing from html form to php variable.
On Saturday, June 1, 2002 at 6:00:22 PM, you wrote: $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), .$_POST['firstname']., .$_POST['surname'].); It's so obvious you're gonna kick yourself (I did!). You need to enclose the two values in quotes, like so... $query = INSERT INTO friends (id, firstname, surname) values (nextval('friends_id_seq'), '.$_POST['firstname'].', '.$_POST['surname'].'); -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Possible to convert from Hex string to integer?
Does anyone know of a function within PHP that will convert a hexadecimal string (without the leading 0x) into an integer? regards, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Possible to convert from Hex string to integer?
Did you check the manual? http://php.net/hexdec On Sat, 1 Jun 2002, Michael Davey wrote: Does anyone know of a function within PHP that will convert a hexadecimal string (without the leading 0x) into an integer? regards, Mikey -- 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] Possible to convert from Hex string to integer?
On Saturday, June 1, 2002 at 6:29:59 PM, you wrote: Does anyone know of a function within PHP that will convert a hexadecimal string (without the leading 0x) into an integer? FFS!! http://www.php.net/hexdec -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reg exp problems
Hi, thanks for the suggestion, but the base tag doesn't have to have a closing tag, OR it appears many/all sites I've seen don't use the closing tag. Andrew - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 6:02 PM Subject: Re: [PHP] reg exp problems On Saturday 01 June 2002 23:56, Andrew Brampton wrote: Hi, I've never used a reg exp, but I was trying to do something simple, and I just can't seem to do it :) I have a varible $fdata which contains the contents of a webpage, and I want to strip out the base tag. I try: $fdata = preg_replace(base.*,,$fdata); But its stripping out everything between the first base and the last on that line, instead of the of the at the end of the base tag Try: (it should remove base /base) preg_replace(/(base)|(\/base)/, , $fdata); *** Untested, use at your own risk *** -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* When you make your mark in the world, watch out for guys with erasers. -- The Wall Street Journal */ -- 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] reg exp problems
On Sat, 1 Jun 2002 16:56:04 +0100, you wrote: Hi, I've never used a reg exp, but I was trying to do something simple, and I just can't seem to do it :) I have a varible $fdata which contains the contents of a webpage, and I want to strip out the base tag. I try: $fdata = preg_replace(base.*,,$fdata); But its stripping out everything between the first base and the last on that line, instead of the of the at the end of the base tag Try this (untested): $fdata = preg_replace (/base[^]*/,,$fdata); That should work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Possible to convert from Hex string to integer?
Which is so easy to find in the offline manual... Stuart Dallas [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Saturday, June 1, 2002 at 6:29:59 PM, you wrote: Does anyone know of a function within PHP that will convert a hexadecimal string (without the leading 0x) into an integer? FFS!! http://www.php.net/hexdec -- Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Speed comparison of PHP vs. PERL (not conclusive)
From: Jason Wong [mailto:[EMAIL PROTECTED]] Try comparing reading 10K rows from a DB using Perl and PHP would be a more useful benchmark. --- When's the last time you wrote a Web page that needed 10K rows displayed? Writing good _and relevant_ benchmarks is one of the more difficult things to do in CS. Personally, I look at the time it takes me to code and debug things since that's the most expensive part of the cost equation to my customers - hardware's cheap compared to me. I can get something of production quality up and running on PHP much faster than I can in Perl - probably due to 20 years of programming in C - so my customers are happy. Considering that 95% of the time the bottleneck is the bandwidth, not the application code, and the other 5% of the bottleneck is in the database application section, my customers don't demand any artificial language benchmarks. Mark C. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help me....S.O.S...my php doesn't ascend
Hi: I have a Big Problems for my. I have a server with WINNT 4.0 and IIS 3.0, I wanted to install PHP (ver. 4.2.1) and it doesn't ascend. I made it like it was indicated it configures in it paginates it http://www.php.net/manual/fi/configuration.php but neither I am this way, did I lack something?, that happen? I make test with one it paginates call it proves .php and I write several test instruction but it is not: ?php $myvar = Hola. Este es mi primer script en PHP \n; //es mi primer script en PHP \n; //Esto es un comentario echo $myvar; ? BR trtdForma 1/a/td ? echo Hola, este es un mensaje de Prueba con PHP; ? BR trtdForma 2/a/td ?php echo Hola, este es un mensaje de Prueba con PHP; ? BR trtdForma 3/a/td script language=php echo Hola, este es un mensaje de Prueba con PHP; /script BR trtdForma4/a/td % echo Hola, este es un mensaje de Prueba con PHP; % BRBR ? php phpinfo() ? Please that some of you me to help. Oscar Mora -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Is PHP used by U.S. Government? By U.S. DoD?
Another site that you should be aware of is for both internal and external, NASA uses PHP and MySQL, of which both are free. John Christopher [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I would like to use PHP in a project for a United States Government client. The client is skeptical because PHP is not a Microsoft product. I'm looking for statistics and links that show that PHP *is* currently in use by the US Government. Is PHP used by the U.S. Department of Defense? Examples? Is PHP a U.S. Military Standard? Any stats or links would be most helpful. Thank you. __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Speed comparison of PHP vs. PERL (not conclusive)
On Sunday 02 June 2002 02:12, Mark Charette wrote: From: Jason Wong [mailto:[EMAIL PROTECTED]] Try comparing reading 10K rows from a DB using Perl and PHP would be a more useful benchmark. --- When's the last time you wrote a Web page that needed 10K rows displayed? Never. Perhaps you didn't follow the thread. The gist of it was that someone was concerned that the code which does looping in PHP was slow (compared to Perl) and would like to see it increased in speed. What I was trying to point out was that the time it takes to do the loop is (probably) insignificant compared to whatever is happening /inside/ the loop. Thus my suggestion. Of course no (sensible) person would want to display 10K rows in a web-page anymore than one would want to display all the prime numbers from 1 to 10 trillion. However in the context of what PHP is (usually) used for it is a better measure of speed and more relevant than calculating those prime numbers. But it would be hardly useful to compare the speed of retrieval of a single row as other factors would make it unreliable. How many benchmarks do you see where the operation is only performed once? I would say not many. Writing good _and relevant_ benchmarks is one of the more difficult things to do in CS. Personally, I look at the time it takes me to code and debug things since that's the most expensive part of the cost equation to my customers - hardware's cheap compared to me. I can get something of production quality up and running on PHP much faster than I can in Perl - probably due to 20 years of programming in C - so my customers are happy. Considering that 95% of the time the bottleneck is the bandwidth, not the application code, and the other 5% of the bottleneck is in the database application section, my customers don't demand any artificial language benchmarks. And I agree, the MS method of throwing in hardware to mask inefficient programming is quite cost-effective. That is why today my 128MB/500MHz PIII system feels just a nippy as my 8MB/8MHz Amiga did 10 years ago ;-) -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Take everything in stride. Trample anyone who gets in your way. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] pcntl functions for task manager - comments?
I'm experimenting with PHP's pcntl_* functions using the PHP cgi ... I've never written a daemon before, and there doesn't seem to be a lot of information out there about how to do this with the pcntl functions. So, I've read what I can find on the subject as it deals with UNIX programming. The goal is a script that will run forever, checking a job queue ... If jobs are waiting, use pcntl_fork() to handle the jobs. To this end, I've come up with this pseudo-code ... Before going WAY off in this direction, I'd like to submit this for comments by those who've had more experience with this sort of thing. -- // run forever if necessary set_time_limit(0); // detatch from the controlling terminal if (!posix_setsid()) { die('could not detach from terminal'); } // setup signal handlers pcntl_signal(SIGTERM, sig_handler); pcntl_signal(SIGHUP, sig_handler); // loop forever waiting on jobs while(1) { // check queue for pending jobs // (db lookup omitted, let's assume jobs are waiting) $jobs_waiting = true; if($jobs_waiting) { $pid = pcntl_fork(); if($pid == -1) { die('could not fork'); } else if ($pid) { // parent // call waitpid to reap children that // have already terminated do { $tpid = pcntl_waitpid(-1,$status,WNOHANG); if($tpid == -1) die('error occurred while waiting for child'); } while (!$tpid); } else { // child // perform task on jobs waiting // when job(s) complete, quit exit(); } } // wait two seconds before checking queue again sleep(2); unset($jobs_waiting); } function sig_handler($signo) { // blah blah } I am open to suggestions or comments on this approach! Please let me know if you think this looks nuts. Thanks, Clay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] displaying client IP address
I an effort to deter fraudulent credit cards, I'd like to display the client's IP address. Anyone know how this is done with PHP scripting? There is SSI code Perl code for this, but I need to have this be a .php page since it's talking to MySQL. Any help would be much appreciated. Hugo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] displaying client IP address
$_SERVER['REMOTE_ADDR'] Hugo Gallo wrote: I an effort to deter fraudulent credit cards, I'd like to display the client's IP address. Anyone know how this is done with PHP scripting? There is SSI code Perl code for this, but I need to have this be a .php page since it's talking to MySQL. Any help would be much appreciated. Hugo -- Gerard Samuel http://www.trini0.org:81/ http://dev.trini0.org:81/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nathan-Re: [PHP] Julie- A small question - Mysql_insert_id
Hey dude, Yeah, I seem to have a talent for pissing people of unintentally, and Julie seemed to have gotten more than a little pissed at me. Anyway, the reason I didnt specify the type was that I was under the impression that if you have a auto_increment it has to be an integer...I mean you cant have a textand if you have a float/double like 2.23 what will it increment to? 2.24 or 3.23? just did not think of date, time. Guess she just had a bad day and I was the final straw...:) I kinda understood what you mean but not totally so am sending you the actual code used below. ?php $connect=mysql_connect(); $database[server] = localhost; $database[user] = ryan1; $database[password] = ryan777; $database[database] = ryan; if(!$connect = mysql_connect($database[server], $database[user], $database[password])) {print(Problem connecting, failed to connect to: . $database[server]);} $database[sql] = insert into Ref_Users values(NULL,'$FName','$LName','$SiteName', . '$SiteAddress','$Company','$Address','$Username','$pw','$Email',MONTH(now() ),YEAR(now()),0); mysql_select_db($database[database]); if (mysql_query($database[sql])) {} else {print(pPROBLEM, Could not create account...ERROR: . mysql_error() . /p);} ? What do you think? good, bad or ugly? Give me your comments/suggestions and if possible add the mysql_insert_id in the correct place and comment it so that I will know Wow, Ryan, lovely reception you've gotten on this one. :-) Julie has a point (she needs some Prozac or xanex or something, but she has a point) in that the ID field needs a type, either date/time, integer, or string of some sort... so you'd need to be more specific than your original layout: id (auto increment) name (varchar) hits (int) Something more along the lines of: id INT NOT NULL UNSIGNED AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, hits INT UNSIGNED NOT NULL DEFAULT 0 or something like that, depending of course on how you want the table to behave. You really should look into the MySQL manual a bit on table types; the information is well laid out and easy to understand, and if you figure this stuff out now, before you've started inserting stuff into the database, you'll save bunches of time by not needing to change much later (trust me on this one, hooo boy!). You might also want to purchase MySQL by Paul DuBois if you haven't already, it's a fantastic book and widely known on the MySQL mailing list as the MySQL bible. :-) Okay, so you have a table called bob or something, and your id is auto_increment, and you want to know what the last ID was from php. You've done an INSERT INTO bob VALUES (NULL,'myname',300) with php, and now you wanna know what it thinks id is. You need to remember what you named your connection variable, and pass that to mysql_insert_id like so: $last_ID = mysql_insert_id($this_connection); Auto_increment works on a per-connection basis, such that it will remember only the last ID for this specific connection, and as such you need to tell it which connection to get the ID for, NOT which query did the insert (that's what I thought it needed originally, didn't work very well). I hope that explains, lemme know if it doesn't :-) Cheers, # Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] New to PHP- Form Validation Logic/Design Question
I am *very* new to PHP am trying to write a tool where a user can add books to a library MySQL database. The user fills out an HTML form. I do some form validation if the form entries are ok, I need to run some SQL queries using the form variables. I have the HTML form posting back to itself to do the error checking. The part I am unclear on is how to handle the SQL queries. I was thinking that if the user filled out the form correctly, I could redirect to a new php script/page to handle the SQL queries. The problem is that if I do so, I do not have access to the form variables that I need. The only way I know to pass variables to a new script is through a form posting it doesn't make sense to have 2 form postings for one form. I suppose I could run the SQL queries from the same script although when I use my below logic, the SQL queries print out underneath the HTML form which looks pretty bad. I was thinking that if I approach it this way, I need some way to loop back through all my if statements so that I could catch the last one only ($REQUEST_METHOD == post $validated == yes) and therefore wouldn't get the HTML form again. I tried putting a while(true){ } loop around the entire thing which resulted in printing my HTML table infinity times :) I included a pseudocode form of my logic here my actual code below. If anyone has any thoughts, suggestions, ideas, or comments, I'd really appreciate it! Also, is there a good IRC channel for php users? Laura [EMAIL PROTECTED] Instant Messenger: lefindley if ($REQUEST_METHOD != POST){ include(./form.html); } else if ($REQUEST_METHOD == POST $validated == no){ perform error checking display errors at top of page include(./form.html); } else if ($REQUEST_METHOD == POST $validated == yes) { **here is where I need to run the SQL queries** } -- ? $err = ; $validated = no; // display form for user to fill out if ($REQUEST_METHOD != POST) { include(./form.html); } else if ($REQUEST_METHOD == POST $validated == no) { // if user is submitting the form, do error // checking. if there are errors, display them at // the beginning of the form if ($book_title == ){ $err .= LIfont color=redBook title cannot be blank!/fontbr; } if ($author == ) { $err .= LIfont color=redAuthor cannot be left blank!/fontbr; } if ($author != ){ if (!ereg('[a-zA-Z]', $author)){ $err .= LIfont color=redAuthor name must be . letters!/fontbr; } } if ($price == ){ $err .= LIfont color=redPrice cannot be left blank!/fontbr; } if ($price != ){ if (!is_numeric($price)){ $err .= LIfont color=redPrice must be numbers!/fontbr; } } if ($isbn == ){ $err .= LIfont color=redISBN cannot be left blank!/fontbr; } if ($isbn != ){ if (!is_numeric($isbn)){ $err .= LIfont color=redISBN must be numbers!/fontbr; } } if ($num_copies != ){ if (!is_numeric($num_copies)){ $err .= LIfont color=red# of copies must be . numbers!/fontbr; } } if ($checked_out != ){ if (!is_numeric($checked_out)){ $err .= LIfont color=red# of checked out copies must be . if ($checked_out != ){ if (!is_numeric($checked_out)){ $err .= LIfont color=red# of checked out copies must be . numbers!/fontbr; } } if (is_numeric($checked_out) is_numeric($num_copies)){ if ($checked_out $num_copies){ $err .= LIfont color=red# of copies checked out cannot . exceed number of copies in library!/fontbr; } } include(./form.html); if ($err == ){ $validated = yes; break; } print Validated: $validated; } // end of else if if ($REQUEST_METHOD == POST $validated == yes){ // if user has correctly filled out the form, I // need to run some MySQL queries using the form // variables - not sure if it is best to do this // on the same page or redirect to another. // if i run the SQL queries from the same page, // i need to be able to not display the HTML form // if i redirect to another script, I need a way // to pass the form variables print do some SQL stuff; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problems with Multi-Uploads (AGAIN)
Okay so this is what I'm trying, basically for the purposes of posting a news article I want to be able to upload supporting text files with the content of the article. Here's what I've got so far... I think I've totally missed the mark or understood the documentation in the manual on this... Someone please set me straight: ?php /*Some loops will be added to this after variables from the previous page. This is why this has been printed into PHP format.*/ print(form action=\process_form.php\ method=\post\ enctype=\multipart/form-data\); print(First File: input name=\userfile[0]\ type=\file\br); print(Second File: input name=\userfile[1]\ type=\file\br); print(input type=\submit\ value=\Upload Files\); print(/form); ? This is the catch file...: ?php if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'][0])) { copy($HTTP_POST_FILES['userfile']['tmp_name'][0], articles/placetogo); copy($HTTP_POST_FILES['userfile']['tmp_name'][1], articles/placetogo); print(Files Loaded Successfully!); } else { print(Unable to Load Files); } ? Any help is appreciated. Sorry if the formatting on this came out strange. __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New to PHP- Form Validation Logic/Design Question
I included a pseudocode form of my logic here my actual code below. A suggestion in similar pseudo code. top of page set a flag to display form If (form submitted) { validate entered data if (data is correctly validated) { enter data into database if (database operation ok) { include database ok page clear a flag to display form } else { include database error page clear a flag to display form (or not, depends on how you want to deal with this) } } else { display information about data entry problems set a flag to display form } } If (flag to display form is set) { display form } end of page This is much the same as yours but permits you to handle the whole thing in one page without having to re-display the form if you don't need to. I use this basic layout all the time and it has the advantage that you can keep the form but clear the data if you're expecting someone to enter more data into the thing. This method can also let you redisplay the form with data already provided in cases where the form validation has failed. You can also display the relevant validation errors in a way that highlights the problem within the actual form. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Nathan-Re: [PHP] Julie- A small question - Mysql_insert_id
Yeah, I seem to have a talent for pissing people of unintentally, and Julie seemed to have gotten more than a little pissed at me. Anyway, the reason I didnt specify the Perhaps the problem is that you're asking a question that you could solve yourself. You asked about mysql_insert_id() and what it would tell you. Surely the easiest way to do that would be to _USE_ that function and examine the result. You have a web server, you have php and you have a mysql server. You can, and if you can't then you should immediately correct that, examine the raw data in your database. Because of that you can see what you expect the relevant part of your code to return by looking at the raw data and then see if the code returns the correct data. If it doesn't then you can start figuring out why. For anyone else to answer your question you're asking them to figure out what you're doing, probably ask more questions to figure out what you could have told them first time around, provide a general answer to which you will reply that it doesn't work, have them ask for your source code so they can look at it, have them set the source code up as a test in their own development environment, etc, etc ,etc. Sorry, but this almost comes down to basic programming technique - if you want to do something apply some logic to what you want to achieve and then figure out a way to do it. If you think you've found a way, test it. If it doesn't work, try something else. If you are getting nowhere and decide to ask a question here, at least give some indications of what you've tried and had not work. Just some thoughts, and while directed at you, could equally apply to many others in here (no doubt myself included at times). CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Newman Says: Only one value from a msSQL field.
Only one value from a msSQL field. I have many values the same in a field and would like to know how i can select one of each (not mating). $sql = SELECT * FROM brands WHERE 1 ORDER BY `sId` DESC LIMIT 6; lists everything .. ANy help would be cool. Phil
php-general Digest 2 Jun 2002 00:39:52 -0000 Issue 1380
php-general Digest 2 Jun 2002 00:39:52 - Issue 1380 Topics (messages 100216 through 100264): Re: Variables - Using The Contents Of A Varibale Name Built Dynamically 100216 by: Michael Davey problems with installing freetype2 100217 by: andy Re: Affiliate PHP program project - Please help 100218 by: John Holmes Re: Apache, html, php and global variables 100219 by: Peter Goggin 100220 by: John Holmes Re: MS SQL Problem 100221 by: Sqlcoders.com Programming Dept A small question - Mysql_insert_id 100222 by: r 100223 by: Julie Meloni 100224 by: r 100225 by: Stuart Dallas 100226 by: Julie Meloni XML to ARRAY 100227 by: Christopher J. Crane Julie- A small question - Mysql_insert_id 100228 by: r value passing from html form to php variable. 100229 by: Wei Wang 100230 by: Stuart Dallas 100232 by: Wei Wang 100233 by: Philip Olson 100234 by: Philip Olson 100235 by: Stuart Dallas 100236 by: Wei Wang 100237 by: Wei Wang 100238 by: Stuart Dallas 100239 by: Wei Wang 100240 by: Wei Wang 100241 by: Stuart Dallas 100242 by: Stuart Dallas 100243 by: Wei Wang 100245 by: Stuart Dallas reg exp problems 100231 by: Andrew Brampton 100244 by: Jason Wong 100249 by: Andrew Brampton 100250 by: Michael Sims Possible to convert from Hex string to integer? 100246 by: Michael Davey 100247 by: Rasmus Lerdorf 100248 by: Stuart Dallas 100251 by: Michael Davey Re: Speed comparison of PHP vs. PERL (not conclusive) 100252 by: Mark Charette 100255 by: Jason Wong help meS.O.S...my php doesn't ascend 100253 by: omora.arauco.cl Re: Is PHP used by U.S. Government? By U.S. DoD? 100254 by: Christopher J. Crane pcntl functions for task manager - comments? 100256 by: Clay Loveless displaying client IP address 100257 by: Hugo Gallo 100258 by: Gerard Samuel Nathan-Re: [PHP] Julie- A small question - Mysql_insert_id 100259 by: r 100263 by: David Freeman New to PHP- Form Validation Logic/Design Question 100260 by: lfindle.mindspring.com 100262 by: David Freeman Problems with Multi-Uploads (AGAIN) 100261 by: Nick Patsaros Newman Says: Only one value from a msSQL field. 100264 by: Philip J. Newman Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- You could give the button the same name in each form - only the fields in between the form/form tags is actually submitted, then put a hidden field in the form that uniquely identifies the data being submitted. Just a thought... it is what I usually do... Mikey Jason Teagle [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I have found an alternate way of achieving what I want, but I'm wondering if there was an easier way. I have a PHP file that builds a Web page that includes forms. The forms are built dynamically based on the contents of a file, and thus there may be one or two or more forms on the page at any time. This means that I have controls named $btnChoice1 (first form), $btnChoice2 (second form), etc. (radio buttons). All of these forms are of a similar format, and so lead to the same PHP page in their action - a parameter is passed in the URL to identify which form it came from. When the form passes to its action file, another PHP file, there are two ways to get form data: $_POST[control_name] or $control_name. The problem is, the control name I need has to be built dynamically based on which form it came from. So I need this: $btnName = btnChoice . $form_number ; But now I have the tricky bit - $_POST[$btnName] doesn't work because it requires nested substitution of variables, and similarly I can't echo $btnName because that will of course use btnChoice2 instead of the _contents_ of the control named btnChoice2. Is it possible to 'dereference' (whatever the term is) the variable name twice? I tried $$btnName in the stupid hope that it would first interpret that to $btnChoice2 and then interpret that to the contents of the control, but of course it failed. I ended up using foreach on $_POST to pull out control names and their contents, and comparing the control name to my built-up name - but I was wondering if there's a more elegant way of doing what I wanted? Promise my next question to the group will be short {:v) -- _ _ o oJason Teagle [EMAIL PROTECTED] v
[PHP] PHP Coding Problem
Here is a piece of code, that is close to doing what I want it to. The end result I would like to have is an array that is simple to work with. If the XML tag was issue-nameRED HAT/issue-name, I would like something like the following: $Tags['issue-name']. So I could print it out. Something like, print $Tags['issue-name']br\n; I was able to get a numerical representation of the array like, $Tags[5] and the value of that tag was RED HAT, but then I would have to know what the position of the data I am looking for in the array. I would prefer to know the tag name and the array and get to the data that way. I know there is a way to do this, but I just can't figure it out. There is a lot of information on Parsing the XML file but not getting into a useful array, or at least that I have found easily to understand. if(!isset($Sym)) { $Sym = 'IKN'; } $URI = 'http://quotes.nasdaq.com/quote.dll?page=xmlmode=stocksymbol='; $simple = implode( '', file($URI$Sym)); $p = xml_parser_create(); xml_parse_into_struct($p,$simple,$vals,$index); xml_parser_free($p); file://echo Index array\n; file://print_r($index); file://echo \nVals array\n; file://print_r($vals); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New to PHP- Form Validation Logic/Design Question
if($REQUEST_METHOD == post) { //do validation of data if($validated == yes) { //do queries } else { echo not validated; include(form.html); } } else {include(form.html);} Maybe that'll work. I'm trying to follow your logic. That will check for the request method first. If it's POST, go on to validation. If it's not POST, show the form. If the validation succeeds (validation == yes), then do your queries, otherwise give an error message and show the form again. Works? ---John Holmes... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 5:11 PM To: [EMAIL PROTECTED] Subject: [PHP] New to PHP- Form Validation Logic/Design Question I am *very* new to PHP am trying to write a tool where a user can add books to a library MySQL database. The user fills out an HTML form. I do some form validation if the form entries are ok, I need to run some SQL queries using the form variables. I have the HTML form posting back to itself to do the error checking. The part I am unclear on is how to handle the SQL queries. I was thinking that if the user filled out the form correctly, I could redirect to a new php script/page to handle the SQL queries. The problem is that if I do so, I do not have access to the form variables that I need. The only way I know to pass variables to a new script is through a form posting it doesn't make sense to have 2 form postings for one form. I suppose I could run the SQL queries from the same script although when I use my below logic, the SQL queries print out underneath the HTML form which looks pretty bad. I was thinking that if I approach it this way, I need some way to loop back through all my if statements so that I could catch the last one only ($REQUEST_METHOD == post $validated == yes) and therefore wouldn't get the HTML form again. I tried putting a while(true){ } loop around the entire thing which resulted in printing my HTML table infinity times :) I included a pseudocode form of my logic here my actual code below. If anyone has any thoughts, suggestions, ideas, or comments, I'd really appreciate it! Also, is there a good IRC channel for php users? Laura [EMAIL PROTECTED] Instant Messenger: lefindley if ($REQUEST_METHOD != POST){ include(./form.html); } else if ($REQUEST_METHOD == POST $validated == no){ perform error checking display errors at top of page include(./form.html); } else if ($REQUEST_METHOD == POST $validated == yes) { **here is where I need to run the SQL queries** } -- ? $err = ; $validated = no; // display form for user to fill out if ($REQUEST_METHOD != POST) { include(./form.html); } else if ($REQUEST_METHOD == POST $validated == no) { // if user is submitting the form, do error // checking. if there are errors, display them at // the beginning of the form if ($book_title == ){ $err .= LIfont color=redBook title cannot be blank!/fontbr; } if ($author == ) { $err .= LIfont color=redAuthor cannot be left blank!/fontbr; } if ($author != ){ if (!ereg('[a-zA-Z]', $author)){ $err .= LIfont color=redAuthor name must be . letters!/fontbr; } } if ($price == ){ $err .= LIfont color=redPrice cannot be left blank!/fontbr; } if ($price != ){ if (!is_numeric($price)){ $err .= LIfont color=redPrice must be numbers!/fontbr; } } if ($isbn == ){ $err .= LIfont color=redISBN cannot be left blank!/fontbr; } if ($isbn != ){ if (!is_numeric($isbn)){ $err .= LIfont color=redISBN must be numbers!/fontbr; } } if ($num_copies != ){ if (!is_numeric($num_copies)){ $err .= LIfont color=red# of copies must be . numbers!/fontbr; } } if ($checked_out != ){ if (!is_numeric($checked_out)){ $err .= LIfont color=red# of checked out copies must be . if ($checked_out != ){ if (!is_numeric($checked_out)){ $err .= LIfont color=red# of checked out copies must be . numbers!/fontbr; } } if (is_numeric($checked_out) is_numeric($num_copies)){ if ($checked_out $num_copies){ $err .= LIfont color=red# of copies checked out cannot . exceed number of copies in library!/fontbr; } } include(./form.html); if ($err == ){ $validated = yes; break; } print Validated: $validated; } // end of else if if ($REQUEST_METHOD == POST $validated == yes){ // if user has correctly filled out the form, I // need to run some MySQL queries using the form // variables - not sure if it is best to do this
RE: [PHP] help me....S.O.S...my php doesn't ascend
Maybe you should just ask your question in Spanish, because I have no idea what you just asked... Does it just not work? ---John Holmes... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 2:34 PM To: [EMAIL PROTECTED] Subject: [PHP] help meS.O.S...my php doesn't ascend Hi: I have a Big Problems for my. I have a server with WINNT 4.0 and IIS 3.0, I wanted to install PHP (ver. 4.2.1) and it doesn't ascend. I made it like it was indicated it configures in it paginates it http://www.php.net/manual/fi/configuration.php but neither I am this way, did I lack something?, that happen? I make test with one it paginates call it proves .php and I write several test instruction but it is not: ?php $myvar = Hola. Este es mi primer script en PHP \n; //es mi primer script en PHP \n; //Esto es un comentario echo $myvar; ? BR trtdForma 1/a/td ? echo Hola, este es un mensaje de Prueba con PHP; ? BR trtdForma 2/a/td ?php echo Hola, este es un mensaje de Prueba con PHP; ? BR trtdForma 3/a/td script language=php echo Hola, este es un mensaje de Prueba con PHP; /script BR trtdForma4/a/td % echo Hola, este es un mensaje de Prueba con PHP; % BRBR ? php phpinfo() ? Please that some of you me to help. Oscar Mora -- 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] Newman Says: Only one value from a msSQL field.
I don't know about msSQL, but in mySQL you can do something like $sql = SELECT * FROM brands WHERE 1 GROUP BY field ORDER BY `sId` DESC LIMIT 6; Philip J. Newman wrote: Only one value from a msSQL field. I have many values the same in a field and would like to know how i can select one of each (not mating). $sql = SELECT * FROM brands WHERE 1 ORDER BY `sId` DESC LIMIT 6; lists everything .. ANy help would be cool. Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newman Says: Only one value from a msSQL field.
This has nothing to do with PHP. Subscribe to a database list. Use DISTINCT or GROUP BY ---John Holmes... -Original Message- From: Philip J. Newman [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 18, 2002 8:39 PM To: [EMAIL PROTECTED] Subject: [PHP] Newman Says: Only one value from a msSQL field. Only one value from a msSQL field. I have many values the same in a field and would like to know how i can select one of each (not mating). $sql = SELECT * FROM brands WHERE 1 ORDER BY `sId` DESC LIMIT 6; lists everything .. ANy help would be cool. Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Include question
Hi. When I've got code like the following: if($this) { include(this.html); } elseif($that) { include(that.html); } When are the includes() evaluated? Does the Zend engine do the includes first, pull in all of the code, then process it and produce output. Or does the engine start processing the code and only load the includes when it gets to them? Thanks for any explanations. ---John Holmes.
[PHP] Determine overhead of PHP script.
Is there a way to determine the overhead or memory usage of a PHP script as it runs? What I'm looking at is say I've got this nice simple script to display info. Now I want to add a database abstraction layer and a template engine. Sure, this makes it easy for me to control changes, but now I'm including a dozen other files that I may only use a percentage of. So, yeah, it's easy to control, but now it may be taking up 10 times as much memory as it was before. So is there a way to see how much memory/overhead a script is taking up after it does all of its includes? Let me know if I need to explain this more. I'm on a windows machine, but any ideas you have are welcome. I'm sure it's more of an OS-type question, though. ---John Holmes.
[PHP] massive words
hi all, looking for some advice on the best way to approach this: i have a guestbook running on a few sites, and occasionally we get creative people who think it's a good idea to post messages with really long words or URLs into the text, which totally mess up the layout of the page. what I need is an efficient way of checking the input for extremely long words (say about 60-odd characters +) I assume I just split the input by (space) into an array, and check that each word isn't longer than 60 chars, but this seems like a lot of work for the server... although I am limiting the entire input to 2000 chars, so maybe this isn't too much work for the server? this is what I'm using: ? $word_length = 5; $error = 0; $str = cat dog bird mouse elephant; // illegal $str = explode( , $str); foreach($str as $key = $word) { if(strlen($word) $word_length) { $error = 1; } } if($error) { echo sorry; } else { $str = implode( , $str); echo $str.BR; } ? any ways to improve it? Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Determine overhead of PHP script.
It's more of a time-consuming issue rather than memory usage IMHO. However, unless you make several extra database requests, I found that running PHP code is generally rather fast and adding considerable extra code doesn't affect the speed significantly. I must reiterate however that if your templating engine uses a database, that might increase parsing duration considerably. For your own tests, take a look at microtime() on php.net. Bogdan John Holmes wrote: Is there a way to determine the overhead or memory usage of a PHP script as it runs? What I'm looking at is say I've got this nice simple script to display info. Now I want to add a database abstraction layer and a template engine. Sure, this makes it easy for me to control changes, but now I'm including a dozen other files that I may only use a percentage of. So, yeah, it's easy to control, but now it may be taking up 10 times as much memory as it was before. So is there a way to see how much memory/overhead a script is taking up after it does all of its includes? Let me know if I need to explain this more. I'm on a windows machine, but any ideas you have are welcome. I'm sure it's more of an OS-type question, though. ---John Holmes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include question
Your second guess. But you could've tested it easily with two includes appending stuff to the same global var. Bogdan John Holmes wrote: Hi. When I've got code like the following: if($this) { include(this.html); } elseif($that) { include(that.html); } When are the includes() evaluated? Does the Zend engine do the includes first, pull in all of the code, then process it and produce output. Or does the engine start processing the code and only load the includes when it gets to them? Thanks for any explanations. ---John Holmes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] massive words
First, you don't need to explode and then implode - just use a different var for the exploded array and use the original after the test. My suggestion for testing (but you really must test it and see if it's faster or slower than your method) is using wordwrap() with your max word length and then check if any line is longer than your max allowed length. The advantage may be that you probably use 10-15 as the max length in real life and you would skip quite a few checks because you're going to end up with several words on a typical line. I guess it *might* be slightly fatser because wordwrap() is native to PHP - the job however is more complicated, so you may end up with a slower version than your current one. Bogdan Justin French wrote: hi all, looking for some advice on the best way to approach this: i have a guestbook running on a few sites, and occasionally we get creative people who think it's a good idea to post messages with really long words or URLs into the text, which totally mess up the layout of the page. what I need is an efficient way of checking the input for extremely long words (say about 60-odd characters +) I assume I just split the input by (space) into an array, and check that each word isn't longer than 60 chars, but this seems like a lot of work for the server... although I am limiting the entire input to 2000 chars, so maybe this isn't too much work for the server? this is what I'm using: ? $word_length = 5; $error = 0; $str = cat dog bird mouse elephant; // illegal $str = explode( , $str); foreach($str as $key = $word) { if(strlen($word) $word_length) { $error = 1; } } if($error) { echo sorry; } else { $str = implode( , $str); echo $str.BR; } ? any ways to improve it? Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Baffled, line producing error
I was happily coding when I came across a mysterious error. I've traced it to this line if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } commented out the script runs fine, if this line is active an error is produced. My eyes are going bug eyed trying to find what the problem is and I'm hoping a second pair of eyes may point out my error. I've provided the entire script in case by chance the error is actually stemming from elsewhere in the script and I'm missing that as well. The error message from the compiler states the error is stemming from line 15 (which is the line I posted above). Any suggestions? ?php require('config.inc.php'); authenticate(); if ($action == 'add') { // The connection/query commands will need to be modified once the db abstraction layer is ready mysql_connect($mysql_host, $mysql_user, $mysql_pass); mysql_select_db($mysql_database); $errmsg = ''; if (mysql_num_rows(mysql_query(SELECT player_id FROM eq_guildmembers WHERE player_name = '$player_name')) 0) { $errmsg .= 'Player name already existsBR'; $error = 1; } if (!$player_password) { $errmsg .= 'You must specify a password for this userBR'; $error = 1; } # For some weird reason the line below produces an error...I can't find anything wrong if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } if (!$error) { mysql_query(INSERT INTO eq_guildmembers (player_name, date_joined, player_email_address, player_icq, priv_admin, player_password) VALUES ('$player_name',NOW(), '$player_email_address','$player_icq','$priv_admin','$player_password')); else { echo 'Submission successful...A HREF=admin_roster.phpclick here to return to the roster/A'; exit; } } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] displaying client IP address
http://www.faqts.com/knowledge_base/view.phtml/aid/186 Hugo Gallo wrote: I an effort to deter fraudulent credit cards, I'd like to display the client's IP address. Anyone know how this is done with PHP scripting? There is SSI code Perl code for this, but I need to have this be a .php page since it's talking to MySQL. Any help would be much appreciated. Hugo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] massive words
Thanks! Justin on 02/06/02 1:18 PM, Bogdan Stancescu ([EMAIL PROTECTED]) wrote: First, you don't need to explode and then implode - just use a different var for the exploded array and use the original after the test. My suggestion for testing (but you really must test it and see if it's faster or slower than your method) is using wordwrap() with your max word length and then check if any line is longer than your max allowed length. The advantage may be that you probably use 10-15 as the max length in real life and you would skip quite a few checks because you're going to end up with several words on a typical line. I guess it *might* be slightly fatser because wordwrap() is native to PHP - the job however is more complicated, so you may end up with a slower version than your current one. Bogdan Justin French wrote: hi all, looking for some advice on the best way to approach this: i have a guestbook running on a few sites, and occasionally we get creative people who think it's a good idea to post messages with really long words or URLs into the text, which totally mess up the layout of the page. what I need is an efficient way of checking the input for extremely long words (say about 60-odd characters +) I assume I just split the input by (space) into an array, and check that each word isn't longer than 60 chars, but this seems like a lot of work for the server... although I am limiting the entire input to 2000 chars, so maybe this isn't too much work for the server? this is what I'm using: ? $word_length = 5; $error = 0; $str = cat dog bird mouse elephant; // illegal $str = explode( , $str); foreach($str as $key = $word) { if(strlen($word) $word_length) { $error = 1; } } if($error) { echo sorry; } else { $str = implode( , $str); echo $str.BR; } ? any ways to improve it? Justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Baffled, line producing error
What is the exact error message are you seeing? -Original Message- From: Craig Vincent [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 11:29 PM To: [EMAIL PROTECTED] Subject: [PHP] Baffled, line producing error I was happily coding when I came across a mysterious error. I've traced it to this line if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } commented out the script runs fine, if this line is active an error is produced. My eyes are going bug eyed trying to find what the problem is and I'm hoping a second pair of eyes may point out my error. I've provided the entire script in case by chance the error is actually stemming from elsewhere in the script and I'm missing that as well. The error message from the compiler states the error is stemming from line 15 (which is the line I posted above). Any suggestions? ?php require('config.inc.php'); authenticate(); if ($action == 'add') { // The connection/query commands will need to be modified once the db abstraction layer is ready mysql_connect($mysql_host, $mysql_user, $mysql_pass); mysql_select_db($mysql_database); $errmsg = ''; if (mysql_num_rows(mysql_query(SELECT player_id FROM eq_guildmembers WHERE player_name = '$player_name')) 0) { $errmsg .= 'Player name already existsBR'; $error = 1; } if (!$player_password) { $errmsg .= 'You must specify a password for this userBR'; $error = 1; } # For some weird reason the line below produces an error...I can't find anything wrong if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } if (!$error) { mysql_query(INSERT INTO eq_guildmembers (player_name, date_joined, player_email_address, player_icq, priv_admin, player_password) VALUES ('$player_name',NOW(), '$player_email_address','$player_icq','$priv_admin','$p layer_password')); else { echo 'Submission successful...A HREF=admin_roster.phpclick here to return to the roster/A'; exit; } } } ? -- 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] Include question
The global var wouldn't work. Even if both are loaded into memory before the script is ran, only one include will actually be executed along with the code, so only one would end up affecting a global var either way. What I'm looking at is if each include .html file is 50K, am I loading 100K into memory and then running the script, or running the script and only loading the appropriate 50K into memory when it's needed? ---John Holmes... -Original Message- From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 11:12 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Include question Your second guess. But you could've tested it easily with two includes appending stuff to the same global var. Bogdan John Holmes wrote: Hi. When I've got code like the following: if($this) { include(this.html); } elseif($that) { include(that.html); } When are the includes() evaluated? Does the Zend engine do the includes first, pull in all of the code, then process it and produce output. Or does the engine start processing the code and only load the includes when it gets to them? Thanks for any explanations. ---John Holmes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problems with upload
The answer... the php.ini did not accept the value 2M. it would, however accept 2097152. Aaron Aaron [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I am trying to upload files to a server. I have the script and it works on other servers but when I try to upload to this paticular server, I get the following: Warning: Max file size of 2 bytes exceeded - file [userfile] not saved in Unknown on line 0 I have checked the php.ini file and the upload_max_filesize = 2M. I checked with phpinfo and verified that it is set for 2M. Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] simple email validation ereg
Hi, I know that there are more complex functions and classes out there for validating email address', but some of them do return invalid on *technically* valid, although uncommon email address', so all I want is a simple test for: (anything)@(anything) followed by 1 or more (.anything) ie foo@foo : invalid [EMAIL PROTECTED] : valid [EMAIL PROTECTED] : valid i wish to allow ANYTHING really -- not just a-z,A-z,0-9,_,- technically spaces, brackets, and all sorts of crap are valid in the user portion of the email address :) this will return true for [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] etc etc... i'm aware that the results will not necessarily BE valid email address', but at least they'll *look* like valid email address'. it's for a simple guestbook/message board where some creative people have put in lalaland or myplace as an email address, rather than entering something that at least LOOKS like a valid address, or optionally leaving the field blank. my aim will be to strip out anything that doesn't at least LOOK like like an email address. regards, justin french -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Baffled, line producing error
If the error is a warning about undefined variable, then set a default value for $errmsg before you start adding strings to it. $errmsg .= this; That by itself means $errmsg = $errmsg . this;, but if $errmsg isnt' defined, you'll get the warning. Set $errmsg = ''; at the beginning of your script if that is the problem... For future reference, always give the exact error when posting. Trying to be psychic, ---John Holmes... -Original Message- From: Craig Vincent [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 11:29 PM To: [EMAIL PROTECTED] Subject: [PHP] Baffled, line producing error I was happily coding when I came across a mysterious error. I've traced it to this line if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } commented out the script runs fine, if this line is active an error is produced. My eyes are going bug eyed trying to find what the problem is and I'm hoping a second pair of eyes may point out my error. I've provided the entire script in case by chance the error is actually stemming from elsewhere in the script and I'm missing that as well. The error message from the compiler states the error is stemming from line 15 (which is the line I posted above). Any suggestions? ?php require('config.inc.php'); authenticate(); if ($action == 'add') { // The connection/query commands will need to be modified once the db abstraction layer is ready mysql_connect($mysql_host, $mysql_user, $mysql_pass); mysql_select_db($mysql_database); $errmsg = ''; if (mysql_num_rows(mysql_query(SELECT player_id FROM eq_guildmembers WHERE player_name = '$player_name')) 0) { $errmsg .= 'Player name already existsBR'; $error = 1; } if (!$player_password) { $errmsg .= 'You must specify a password for this userBR'; $error = 1; } # For some weird reason the line below produces an error...I can't find anything wrong if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } if (!$error) { mysql_query(INSERT INTO eq_guildmembers (player_name, date_joined, player_email_address, player_icq, priv_admin, player_password) VALUES ('$player_name',NOW(), '$player_email_address','$player_icq','$priv_admin','$player_password') ); else { echo 'Submission successful...A HREF=admin_roster.phpclick here to return to the roster/A'; exit; } } } ? -- 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] simple email validation ereg
Maybe I'm biased, but if you grab validateEmailFormat.php from www.killersoft.com, you'd be able to do something as simple as this: ?php include(/path/to/validateEmailFormat.php); $email = [EMAIL PROTECTED]; $isValid = validateEmailFormat($email); if($isValid) { // do whatever you need to do } else { echo sorry, that address isn't formatted properly.; } ? validateEmailFormat.php is a translation of the Perl regular expression that's widely considered to be the defintive test of a valid RFC822 address. Can't go wrong with that. : ) -Clay From: Justin French [EMAIL PROTECTED] Date: Sun, 02 Jun 2002 14:13:40 +1000 To: php [EMAIL PROTECTED] Subject: [PHP] simple email validation ereg Hi, I know that there are more complex functions and classes out there for validating email address', but some of them do return invalid on *technically* valid, although uncommon email address', so all I want is a simple test for: (anything)@(anything) followed by 1 or more (.anything) ie foo@foo : invalid [EMAIL PROTECTED] : valid [EMAIL PROTECTED] : valid i wish to allow ANYTHING really -- not just a-z,A-z,0-9,_,- technically spaces, brackets, and all sorts of crap are valid in the user portion of the email address :) this will return true for [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] etc etc... i'm aware that the results will not necessarily BE valid email address', but at least they'll *look* like valid email address'. it's for a simple guestbook/message board where some creative people have put in lalaland or myplace as an email address, rather than entering something that at least LOOKS like a valid address, or optionally leaving the field blank. my aim will be to strip out anything that doesn't at least LOOK like like an email address. regards, justin french -- 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] Baffled, line producing error
If the error is a warning about undefined variable, then set a default value for $errmsg before you start adding strings to it. $errmsg .= this; That by itself means $errmsg = $errmsg . this;, but if $errmsg isnt' defined, you'll get the warning. Set $errmsg = ''; at the beginning of your script if that is the problem... For future reference, always give the exact error when posting. Trying to be psychic, You'll notice a few lines up I have defined $errmsg =) It's a standard parsing error I'm getting Parse error: parse error in admin_add_player.php on line 15 Since this message does not arise when line 15 is removed I can only assume the error is actually on that line and not a missing quote or bracket somewhere else in the script. Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache, html, php and global variables
My script is: html body ?php session_start(); printf(P loggin on as ); printf (Puser name: ); printf ($HTTP_POST_VARS['User']); printf (PPassword: );printf ($HTTP_POST_VARS['Password']); printf (P); /* Connecting, selecting database */ $link = mysql_pconnect(localhost, $HTTP_POST_VARS['User'], $HTTP_POST_VARS['Password']) or die(Could not connect); print Connected successfullyP; printf (BR); print Setting Global variablesBR; $_SESSION_VARS[dbauser]=($HTTP_POST_VARS['User']); $_SESSION_VARS[dbapassword]=($HTTP_POST_VARS['Password']); printf ($_SESSION_VARS[dbauser]); printf (BR); printf ($_SESSION_VARS[dbapassword],BR); ? P /body /html The errors I get are: Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\databaselogin.php:3) in c:\usr\www\my-domain\databaselogin.php on line 4 Warning: Cannot send session cache limiter - headers already sent (output started at c:\usr\www\my-domain\databaselogin.php:3) in c:\usr\www\my-domain\databaselogin.php on line 4 loggin on as user name: stampuser Password: vantwest Connected successfully Obviously I have something not configured correctly, or I am calling the function in the wrong place. Any advice on how to overcome this would be very useful. Regards Peter Goggin - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Peter Goggin' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Sunday, June 02, 2002 12:09 AM Subject: RE: [PHP] Apache, html, php and global variables Sessions use cookies, which use headers, which have to be sent before any output. html is output. So, put session_start() before that. ? Session_start(); ... ? html body ... Where are you putting dbauser and dbapassword into the session? Your sessions still aren't going to work because the session.save_path isn't set correctly in your PHP.ini. Set it to a directory on your computer that the web server has access to write to. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 9:54 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables I am not clear what you mean by this. I have set session_start() on in the php script that logs onto the database initially. i then call a test php script from a button on the menu frame. This is the output it gives: Test php variables Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: Cannot send session cache limiter - headers already sent (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in c:\usr\www\my-domain\maintenance.php on line 5 Test of global variables DBA USER: DBA Password; Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 The script is: HTML BODY Test php variablesBR ?php session_start(); printf (Test of global variablesBR); printf (DBA USER: ,$_SESSION_VARS[dbauser],BR); printf (BR); printf (DBA Password; ,$_SESSION_VARS[dbapassword],BR); ? /BODY /HTML Is there a problem with how I am using sessiot_start, or is there a php config problem? Regards Peter Goggin - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Peter Goggin' [EMAIL PROTECTED]; php- [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 2:04 PM Subject: RE: [PHP] Apache, html, php and global variables You still have to connect to a database every time a script is run, whether it's loaded in a frame or run by itself. If you start a session and save the username and password in it, then you can use that login and password on every other page that you call session_start() on. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:12 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables I am not certain how this helps me, since it appears the data is only carried to pages called directly from where it is set. The page where the user logs onto the database does not link to other pages. This is done from the top frame of the form. The top frame of the inital page contains the menu, one option of which is to log onto the data base to start a session. The user will then select another page
RE: [PHP] Apache, html, php and global variables
Did you read my reply at all? Call session_start() before any output to the browser. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 02, 2002 1:20 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables My script is: html body ?php session_start(); printf(P loggin on as ); printf (Puser name: ); printf ($HTTP_POST_VARS['User']); printf (PPassword: );printf ($HTTP_POST_VARS['Password']); printf (P); /* Connecting, selecting database */ $link = mysql_pconnect(localhost, $HTTP_POST_VARS['User'], $HTTP_POST_VARS['Password']) or die(Could not connect); print Connected successfullyP; printf (BR); print Setting Global variablesBR; $_SESSION_VARS[dbauser]=($HTTP_POST_VARS['User']); $_SESSION_VARS[dbapassword]=($HTTP_POST_VARS['Password']); printf ($_SESSION_VARS[dbauser]); printf (BR); printf ($_SESSION_VARS[dbapassword],BR); ? P /body /html The errors I get are: Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\databaselogin.php:3) in c:\usr\www\my-domain\databaselogin.php on line 4 Warning: Cannot send session cache limiter - headers already sent (output started at c:\usr\www\my-domain\databaselogin.php:3) in c:\usr\www\my-domain\databaselogin.php on line 4 loggin on as user name: stampuser Password: vantwest Connected successfully Obviously I have something not configured correctly, or I am calling the function in the wrong place. Any advice on how to overcome this would be very useful. Regards Peter Goggin - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Peter Goggin' [EMAIL PROTECTED]; php- [EMAIL PROTECTED] Sent: Sunday, June 02, 2002 12:09 AM Subject: RE: [PHP] Apache, html, php and global variables Sessions use cookies, which use headers, which have to be sent before any output. html is output. So, put session_start() before that. ? Session_start(); ... ? html body ... Where are you putting dbauser and dbapassword into the session? Your sessions still aren't going to work because the session.save_path isn't set correctly in your PHP.ini. Set it to a directory on your computer that the web server has access to write to. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 01, 2002 9:54 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables I am not clear what you mean by this. I have set session_start() on in the php script that logs onto the database initially. i then call a test php script from a button on the menu frame. This is the output it gives: Test php variables Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: Cannot send session cache limiter - headers already sent (output started at c:\usr\www\my-domain\maintenance.php:4) in c:\usr\www\my-domain\maintenance.php on line 5 Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in c:\usr\www\my-domain\maintenance.php on line 5 Test of global variables DBA USER: DBA Password; Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0 The script is: HTML BODY Test php variablesBR ?php session_start(); printf (Test of global variablesBR); printf (DBA USER: ,$_SESSION_VARS[dbauser],BR); printf (BR); printf (DBA Password; ,$_SESSION_VARS[dbapassword],BR); ? /BODY /HTML Is there a problem with how I am using sessiot_start, or is there a php config problem? Regards Peter Goggin - Original Message - From: John Holmes [EMAIL PROTECTED] To: 'Peter Goggin' [EMAIL PROTECTED]; php- [EMAIL PROTECTED] Sent: Saturday, June 01, 2002 2:04 PM Subject: RE: [PHP] Apache, html, php and global variables You still have to connect to a database every time a script is run, whether it's loaded in a frame or run by itself. If you start a session and save the username and password in it, then you can use that login and password on every other page that you call session_start() on. ---John Holmes... -Original Message- From: Peter Goggin [mailto:[EMAIL PROTECTED]] Sent: Friday, May 31, 2002 11:12 PM To: [EMAIL PROTECTED] Subject: Re:
Re: [PHP] Baffled, line producing error
You have: if ($player_password != $player_password_verify) { $errmsg .= 'Password don't match. Please try againBR'; $error = 1; } Notice the ' inside the '', this is bad syntax. For more information on using strings in PHP, see: http://www.zend.com/zend/tut/using-strings.php http://www.php.net/manual/en/language.types.string.php One thing you can do is escape it: \' regards, Philip Olson On Sun, 2 Jun 2002, Craig Vincent wrote: If the error is a warning about undefined variable, then set a default value for $errmsg before you start adding strings to it. $errmsg .= this; That by itself means $errmsg = $errmsg . this;, but if $errmsg isnt' defined, you'll get the warning. Set $errmsg = ''; at the beginning of your script if that is the problem... For future reference, always give the exact error when posting. Trying to be psychic, You'll notice a few lines up I have defined $errmsg =) It's a standard parsing error I'm getting Parse error: parse error in admin_add_player.php on line 15 Since this message does not arise when line 15 is removed I can only assume the error is actually on that line and not a missing quote or bracket somewhere else in the script. Sincerely, Craig Vincent -- 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] Baffled, line producing error
Notice the ' inside the '', this is bad syntax. For more information on using strings in PHP, see: Sheesh you're right, as I said it was probably a dumb error, three other people have looked at this that I'm aware of and missed it toolol glad your eyes are better than ours. Thank you for pointing out the mistake Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache, html, php and global variables
On Sunday 02 June 2002 13:31, John Holmes wrote: Did you read my reply at all? Call session_start() before any output to the browser. The errors I get are: Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\databaselogin.php:3) in c:\usr\www\my-domain\databaselogin.php on line 4 Warning: Cannot send session cache limiter - headers already sent Also searching the list archives for headers already sent would (should) result in umpteen billions of hits with the solution. If you're intelligent enough to be writing a website then you should be intelligent enough to use a search engine. Heck, google - headers already sent brings up the answer straight away. So to all those lazy people out there, use your loaf and not someone else's. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* INSIDE, I have the same personality disorder as LUCY RICARDO!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Apache, html, php and global variables
Thanks, well said. John -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED]] Sent: Sunday, June 02, 2002 2:10 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Apache, html, php and global variables On Sunday 02 June 2002 13:31, John Holmes wrote: Did you read my reply at all? Call session_start() before any output to the browser. The errors I get are: Warning: Cannot send session cookie - headers already sent by (output started at c:\usr\www\my-domain\databaselogin.php:3) in c:\usr\www\my-domain\databaselogin.php on line 4 Warning: Cannot send session cache limiter - headers already sent Also searching the list archives for headers already sent would (should) result in umpteen billions of hits with the solution. If you're intelligent enough to be writing a website then you should be intelligent enough to use a search engine. Heck, google - headers already sent brings up the answer straight away. So to all those lazy people out there, use your loaf and not someone else's. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* INSIDE, I have the same personality disorder as LUCY RICARDO!! */ -- 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