Re: [PHP] Uninitialized string offset: 0
Can you show us what you're calling it with? Al Padley -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk
Re: [PHP] newbie question regarding URL parameters
Wow, there are some really bitchy, unattractive people here. No wonder some people bail out of IT. Don't confuse knowledge for wisdom. On 1/9/07, tedd <[EMAIL PROTECTED]> wrote: At 9:17 PM -0500 1/5/07, <[EMAIL PROTECTED]> wrote: >You'll probably get 50 answers to this, but here's probably what happened. > >There's a setting called "register globals" that will turn your >name=me and age=27 into $name = "me" and $age = "27". It used to be >turned ON by default. This was generally considered to be bad >security, so it now defaults to OFF. > >To get these variables, just use the $_GET system variable. > >$name = $_GET['name']; >$age = $_GET['age']; > >Easy! > >Best of luck! > >-TG Just to add to -TG advice, you should also clean those inputs. IWO, make sure the values fall within what you expect. Basic security. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk
Re: [PHP] newbie question regarding URL parameters
Read the reponses.
Re: [PHP] Please Help with simple Noob problem
Why not check php.ini to see whether display_errors is set to off and switch it on until you are back in business? Check the httpd.conf file to make sure Apache is parsing .php files correctly.
Re: [PHP] no database selected
mysql_select_db
[PHP] Encoding issue with £
This may be more of a mysql issue, but I am using php for my app so here goes... I have a fee field in the database, and when users post events they can specify entrance fee in £. In some, not all, of the fields I am getting, for example, £7 rather than £. Is this an encoding issue? Many thanks in advance... -- http://www.web-buddha.co.uk
Re: [PHP] Encoding issue with ?
Thanks guys. The issue is that users can specify text as well as currency in the input field ie '£2 students / £5 general admission'.
[PHP] Ongoing encoding issues
Hi all, I posted a question a couple of days ago regarding a web app I have wherein users are able to indicated prices and concessions via a text field, and the resulting encoding issues I have experienced, the main one being seeing the pound sign as £ if viewing the results in a browser with the encoding set to Latin-1. My question is, how do I overcome this. If I set my browser encoding to Latin-1 and enter the data I get that odd symbol, if I set it to UTF-8 I get clean data. Is there a way to sniff out what encoding the browser is using and then clean the data in any way. I am googling for help also but you guys have been so helpful in the past I thought I'd try you also. -- http://www.web-buddha.co.uk
Re: [PHP] php code to upload a url correctly
This is what I use: $site = (!preg_match('#^http://#', $_POST['c_site'])) ? raw_param(trim(strip_tags("http:\/\/" . $_POST['c_site']))) : raw_param(trim(strip_tags($_POST['c_site']))); don't worry about raw_param, that's a function of my own, but you get the idea.
[PHP] Sorting a multidimensional array
Hi all. I am building an online events directory and as part of the system users can search for events by date, category etc. The logic involved in finding events that match the user-entered dates works like so: 1. we create a range of dates from the start and end dates specified by the user 2. we then poll the database for any events that encompass or intersect this range (using the start_date and end_date fields from events table). 3. we then find out the frequency of the event ie weekly, monthly and then map out its lifetime. 4. we then go through those dates, and for any that match a date in the user range, the event on that date (ie all it details, name, venue, date, start time etc) is added to an array. ...etc etc So we eventually have a large multidimensional array whose elements contain arrays of events that fall on a specific date. I am using usort to ensure the events are sorted by date, but I also want to sort by time, for instance if there are five events on one day I want to sort them by start_time. Here's an example of how the event array looks: element [0] contains an array as follows ('date', 'name' venue', 'start_time', 'category...'); element [1] contains an array as follows ('date', 'name' venue', 'start_time', 'category...'); I tried using array_multisort but it didn't seem to do what I wanted. I want to sort by date, then start_time if the dates are equivalent. Any ideas? -- http://www.web-buddha.co.uk
Re: [PHP] Sorting a multidimensional array
Thanks for that - can't do that as all I know in the database is the start and end date for each event (so I don't have to create mapping tables and perform massive joins), the rest is handle dynamically. I think I can do it using usort, this seems to work, any comments? function compare($x, $y) { if (($x['date'] == $y['date']) && ($x['start_time'] == $y['start_time'])) { return 0; } else if (($x['date'] == $y['date']) && ($x['start_time'] < $y['start_time'])) { return -1; } else if (($x['date'] == $y['date']) && ($x['start_time'] > $y['start_time'])) { return 1; } else if ($x['date'] < $y['date']) { return -1; } else { return 1; } }
[PHP] Problems processing UNIX timestamps in events directory
Hi all. I have an odd problem. I am building an events directory and when users search, they provide a date range ie Feb 16 2007 to March 12 2007 as one of the options for searching. The system then creates an array of timestamps from this and then polls the database for all events whose lifetimes (start to end data) intersect with or contain the user date ranges. The system then checks how many of those dates map onto the dates provided by the user and returns an array of events on specific dates, all by comparing timestamps. The system is working like a dream apart from the following. If the user selects a start date prior to March 26 2007 or after October 29th 2007 all is well. If they specify a start date after March 26 the events are not being pulled in. I have converted the user-friendly date output to timestamps to check and sure enough, when the user selects a start date before March 26 2007, March 26 2007 is output as: 1174863600 ...after that it becomes: 117486 ...a difference of 3600 Is this anything to do with leap seconds or any other clock drift phenomenon anyone has seen before? Much hair being torn out at present! -- http://www.web-buddha.co.uk
Re: [PHP] Problems processing UNIX timestamps in events directory
I AM using the logic you and Jochem suggest in the query, I am not performing any joins. I query for certain criteria re the start and end dates held in the database, and once I have my set I then work with it dynamically as I need to know, based on the event frequency, how many events from that range fall on dates within the user range.
Re: [PHP] Problems processing UNIX timestamps in events directory
Thanks all for your input - you're all correct, I don't really need to use timestamps as I am only interested in dates so will be reworking the app to use dates only. I still need to generate sequences of dates and really don't want to deal with DST, so my question is: can I add days to dates without converting to timestamp and adding 86400 for example. If I can it will make things much simpler. I am talking about doing this dynamically with php rather than at database level. Many thanks in advance, I will also start googling... -- http://www.web-buddha.co.uk
Re: [PHP]Transform a block of code in PHP
I assume you mean you want to hold that html in a variable? Use a heredoc.
Re: [PHP] Option Value
Also, if you want to get into the habit of writing valid xhtml, use lowercase and selected="selected"
[PHP] IE6 session issues
Hi all. I am running an online charity lottery and am having issues with IE6 and sessions. To fix them, I added the following at the top of each file: ini_set('session.name', 'tlc'); header("Cache-control: private"); session_start(); ...ran a local test in IE6 worked fine, then noticed more blank entries coming in. I am not using third-party cookies, the system is built on php sessions, any more ideas? -- http://www.web-buddha.co.uk
Re: [PHP] Check if link is on a page
$web = fopen('http://google.com/index.php', 'r'); $contents = file_get_contents($web); if (preg_match('/$link/', $contents))... you got it simplified and no error checking but you get the idea.
Re: [PHP] GET doesn't work as POST
On 2/24/07, Otto Wyss <[EMAIL PROTECTED]> wrote: With method="post" just $kind works fine (register_global) yet I've also tried any combination of $_GET['kind'] and $_POST['kind']. With method="get" it doesn't work. O. Wyss Peter Lauri wrote: > How are you fetching the GET and POST? With $_GET and $_POST? > > Best regards, > Peter Lauri > > www.dwsasia.com - company web site > www.lauri.se - personal web site > www.carbonfree.org.uk - become Carbon Free > > > > -Original Message- > From: Otto Wyss [mailto:[EMAIL PROTECTED] > Sent: Saturday, February 24, 2007 12:51 PM > To: php-general@lists.php.net > Subject: [PHP] GET doesn't work as POST > > On the page > > http://www.orpatec.ch/turniere/5erfussball/index.php?page=bvallist.php&kind= > regions > > > I have a form with method="post" and action=" ?>". While it works fine this way, as soon as I change the form to > method="get" it looses the parameter "kind" when I change e.g. the > second parameter from "-Alle-" to "Gültig". Has anybody an idea why it > works with POST but not with GET? > > > ... > > > O. Wyss > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ...do you need to run urlencode() on the stirng you pass via GET? -- http://www.web-buddha.co.uk
Re: [PHP] GET doesn't work as POST
On 2/24/07, Dotan Cohen <[EMAIL PROTECTED]> wrote: Also, if you're using the variable in a print string, then you'll need to exit the string, like so: $print "Hello, $kind!"; would become: $print "Hello, ".$_GET["kind"]."!"; Dotan Cohen http://easyanswers.info http://nirot.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Or just interpolate it like so: print "Hello, {$_GET['kind']}!"; -- http://www.web-buddha.co.uk
Re: [PHP] Re: how to display images stored in DB
On 2/25/07, zerof <[EMAIL PROTECTED]> wrote: Alain Roger escreveu: > Hi, > > i stored all my pictures in my PostgreSQL DB as bytea type. > Now i would like to know how can i display them in my PHP pages ? > > where can i find some example ? > > thanks a lot, > -- It is not a good practice to store pictures in DataBases, use links, instead of. -- zerof http://www.educar.pro.br/ Apache - PHP - MySQL - Boolean Logics - Project Management -- Você deve, sempre, consultar uma segunda opinião! -- Deixe todos saberem se esta informação foi-lhe útil. -- You must hear, always, one second opinion! In all cases. -- Let the people know if this info was useful for you! -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Indeed. I am building an events directory at the moment that allows posters to upload images and I store all the images on the file system and the links in the db. -- http://www.web-buddha.co.uk
Re: [PHP] Populating array with function
You have a typo in your code...
Re: [PHP] IE6 session issues
OK. Blank entries means that as date is passed in and validated via forms, it is then entered into $_SESSION so data can be persistent as the user goes back and forth. These values are eventually entered into the database and are blank, whereas the few values that are entered from $_POST (ie credit card numbers that I don't want to carry around in the session) are fine. The system works in IE7, FF and Opera and has also worked on my local version of IE6. I have created a session name and send the Cache-control:private header, which fixed similar issues in the past, but no success in this case. -- http://www.web-buddha.co.uk
Re: [PHP] echo text - anti-spam-spider measure
On 2/28/07, tedd <[EMAIL PROTECTED]> wrote: At 11:22 PM -0500 2/27/07, John Taylor-Johnston wrote: >I need an anti-spam-spider measure for my site. Too many addresses >are getting raked. In once instance, I created a flash page: >http://erasethis.glquebec.org/English/contact.htm >But I just don't have the time to create a flash image for every >single instance, most of which come from dynamically printed PHP >pages from a MySQL database. > >Could I dynamically create a flash image, input the email and tell >the flash image to mailto:[EMAIL PROTECTED] > >Do anyone have a solution? Does one already exist? I agree with Stut that entities are the easiest for bots to handle. As for myself, I use javascript Enkoder -- you can Google it for a way to use it. As for an example of its use, please review: http://sperling.com/contact.php and inspect the source. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://automaticlabs.com/products/enkoderform/ -- http://www.web-buddha.co.uk
Re: [PHP] Intro to PHP question
Of course it's possible to output raw html in a php file, that's one of it's fundamental uses! In fact, it's more efficient to switch the php parser off and send raw html as the php parser doesn't need to get involved.
Re: [PHP] Intro to PHP question
If you are running that from the command line, why do you need html? Not sure why you're doing that.
Re: [PHP] Intro to PHP question
Why not learn in a web environment if your goal is to build a website? Just create the following file: save it, upload it and view it. If you see the php details you have the system set up as you need it and can just start writing php-driven web pages (the file you are using now is one!). If you really want to run that on the command line, you will need the path to php on the first line of the file. Please, forget the command line stuff unless you want to write command line scripts, and get that file running in a web environment where it belongs. happy to help if you need any more assistance doing that!
[PHP] Variable variables and references
Hi guys, I have just read 'Programming PHP' (O'Reilly) and although I think it's a great book, I am confused about variable variables and references - not the mechanics, just where you would use them. The subject of variable variables is explained but no examples are given as to why and where you would utilise them. As for references, the examples given with regard to passing and returning by reference in functions is clear, but no real examples are given as to when this would be a preferred approcah - in fact, the authors stress that due to PHP's copy-on-write mechanism, it is not a frequently-used approcah. So my question - are there any 'classic' situations in which either should be used, and where and when do you guys use them in your real-world efforts? -- http://www.web-buddha.co.uk
Re: [PHP] Redirecting in a PHP script
If you do want to use the header function after html has been output, you can always look at using output buffering (ob_start()).
Re: [PHP] Capitalizing the first letter
ucwords(strtolower($string)) or ucfirst(strtolower($string)) On 3/13/07, Todd Cary <[EMAIL PROTECTED]> wrote: I would like to write a filter that takes the text "smith" or "SMith" and returns "Smith"; same for "ralph smith". Is the a good source on using filters this way? Thank you... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk
Re: [PHP] Re: [PHP-WIN] Re: [PHP] Re: Question on virus/worms
Turn off register_globals - if you pollute your scripts with global variables like that you are asking for trouble. If you can't make sure you clean the variable. Using include("$page.php") is asking for trouble. If you can get register_globals switched off (it's off by default in PHP5 for this very reason) then use the kind of security procedure so well explained on brainbulb.com (also well worth watching the audit cast): Maybe something like: $page = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : 'page'; // clean data here, ie check suffix, reun tests, and only then... include "$page.php";
Re: [PHP] image digit to check password
Have a look at this: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image digit to check password
Om On 3/20/07, Jochem Maas <[EMAIL PROTECTED]> wrote: Tijnema ! wrote: > On 3/20/07, Dave Goodchild <[EMAIL PROTECTED]> wrote: >> Have a look at this: > > Have a look at nothing :) I believe this Dave's way of pointing people to the Great Void :-) >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > -- http://www.web-buddha.co.uk
Re: [PHP] POST + QUERY
use: $_POST['max_id'] == or even better: if (empty($_POST['max_id']))
Re: [PHP] POST + QUERY
Because isset will return true if the variable is set, even if it is blank. Empty will return true is the variable holds an empty string.
Re: [PHP] What is wrong with this INSERT?
Because of this: $sql = mysql_query("INSERT INTO tbl (WHEN, WHAT, WHO) VALUES ('$WHEN','$WHAT','$WHO')"); $result = mysql_query($sql) or die("Fatal Error :".mysql_error()); ...you are running the query and assigning the results into $sql and then running mysql_query again in the line below. So the second query runs on a result set rather than a query statement and fails. Better to do this, at this rudimentary level: $result = mysql_query("INSERT INTO tbl (WHEN, WHAT, WHO) VALUES ('$WHEN','$WHAT','$WHO')") or die(mysql_error()); -- http://www.web-buddha.co.uk
[PHP] Duplicate dates in array
Hi all, I have an array containing a sequence of dates in the following format, for example: Mon 26 Nov 2007 Mon 24 Dec 2007 Mon 31 Dec 2007 Mon 28 Jan 2007 ...and I want to remove any the first element in cases where the Mondays fall in the same month, so in this case I want to be left with: Mon 26 Nov 2007 Mon 31 Dec 2007 Mon 28 Jan 2007 Any ideas on the most efficient way to do it? I am working on using combinations of array_search, in_array and so on and want to avoid regular expressions if I can. Many thanks in advance for any suggestions! -- http://www.web-buddha.co.uk
Re: [PHP] Duplicate dates in array
Amazing, just what I needed - many thanks. Have been coding non-stop for 10 days and things are getting foggy. Grats for your informed and quick response and have a fantastic day!
Re: [PHP] Question about form submitting
Not true. You can submit the form back to itself as many times as required by making the form action $_SERVER['PHP_SELF'] and checking for various sequences and outputting different html in each case.
Re: [PHP] which CMS are you using and why?
I have just upgraded to Drupal 5 and so far am very impressed - D5 comes bundled with the jquery library and I have found drupal to be very powerful with a wide and supportive community.
Re: [PHP] header('Location:') works locally but not remotely
Provide some code...?
Re: [PHP] redirect with header still not working
Can you re-iterate what is happening - I have a site with 1and1 and use header() with no issues.
Re: [PHP] redirect with header still not working
That is, unless you use output buffering. It may not be the most elegant solution (using header() to redirect users increases server calls), but I built a template-driven php site that calls: ...depending on certain conditions which means I can then use header() even after I have started output.
Re: [PHP] Re: CSS vs. Tables OT
Tables used for presentational layout are a hack, implemented in an albiet ingenious way to overcome the shortcomings of the Web quite a while ago now. Tables should be used for the display of tabular data, ie spreadsheets, calendars etc. Table layout increases download times, the deeper nested the worse it becomes. They compromise accessibility and the semantic structure of the content, and confuse screen readers and search engine bots. Clearly laid out with the proper use of captions, summaries, headers, etc for tabular data they are a beautiful thing. CSS layout is possible, faster, easier to maintain, more flexible and more accessible and the situation is only going to improve. The pain experienced by old-school designers at making the transition is understandable, but necessary. At the moment it's a subject of hot debate, but the tables-for-layout crowd are going to be increasingly marginalised as we move forward - and this is the way it should be as we try to evolve the web.
Re: [PHP] CSS vs. Tables OT
Can we kill this now please? It's not a php issue, is an old and endless argument and is better addressed on a css / design list.
Re: [PHP] Looking for a framework
You mean a javscript library? If so, check out jquery and moo.fx. On 10/23/07, Merlin <[EMAIL PROTECTED]> wrote: > > Hi there, > > I am looking for a framework to integrate some AJAX Functionality into > my PHP4 MySQL Apache webapp. First thing I would like to do, is an edit > function that opens up a layer with an edit field and shifts the content > underneath further down. > > I had a look on prototype and sript.aculo.us but could not get the > desired function with the edit field. > > Thank you in advance for any hint on this and maybe a few tipps how to > get it startet. > > Best regards, > > Merlin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] moving over to php 5
Support for php4 will be dropped at the end of the year so hosts will be forced to make the upgrade at some point. On 10/29/07, Hulf <[EMAIL PROTECTED]> wrote: > > Hi, > > > It is about time I made the jump to 5, however the only thing that is > holding me back is the problem with hosts. How many hosts still run php 4 > and am I going to have to spend hours and hours persuading them to upgrade > before I can run my code? > > I have very little time as it is and am anxious that this is going to be > swallowed up on the phone to hosing companies and their rubbish technical > staff. > > Please let me know if I will find this an easy transition or should I hold > off for now. > > > R. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Need a hint how to track an error
Start by coding proper semantic xhtml and you will have less headaches too - that code looks very ugly. On Nov 12, 2007 8:38 AM, Ronald Wiplinger <[EMAIL PROTECTED]> wrote: > Chris wrote: > > Ronald Wiplinger wrote: > >> My php program is working with Firefox, but not with Internet Explorer. > > > > Nothing to do with php, your problem is javascript. > > > >> Is there a tool to find the problem? > > > > For IE, try > > > > http://www.microsoft.com/downloads/details.aspx?familyid=e59c3964-672d-4511-bb3e-2d5e1db91038&displaylang=en > > > > > > Why do you guys assume javascript > > I am disappointed that after switching totally from XP to Ubuntu to > suggest me a Windows tool! I installed in a VirtualBox XP again and > above tool helped me to find the mistake: > > } > ?> > > > The tool helped me to find the missing ``>'' after showed me no value for the submit buttons. > > Is there no other tool available that can find such errors? tool > error.list > > bye > > Ronald > > -- > 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] tell me :which book is good for newman??
Start with Programming PHP and then get Upgrading To PHP5 (both by O'Reilly) On Nov 17, 2007 2:31 PM, David Giragosian <[EMAIL PROTECTED]> wrote: > On 11/17/07, joychen <[EMAIL PROTECTED]> wrote: > > > > tell me :which book is good for newman?? > > > You mean paul? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Convertig xml into array
Hi guys. I have the following XML file which I want to convert into a multidimensional array. I am using PHP5 so don't want to use SimpleXML as apparently there are issues with sessions and after conversion I want to pass this array into the session. Any ideas on the best and cleanest way to do this? 0.1 http://cpl.jellyfish.co.uk/service/ userid 19.99 25.99 monthly 20% Credit Card Direct Debit 12345 gift UK EIRE CHEESE 8.99 12.99 annually 25% Credit Card Direct Debit 12345 standard subscription UK EIRE CHEESE Enter your first name: Enter your surnane: Enter your email address: campaign_header.jpg logo.jpg submit.jpg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Select Box CSS OT
Why not try a css list? css-discuss for example? On Dec 18, 2007 8:06 PM, Børge Holen <[EMAIL PROTECTED]> wrote: > On Tuesday 18 December 2007 20:03:53 Stut wrote: > > VamVan wrote: > > > Please apologize for sending this question to PHP forums. > > > > If you know this already why ask the question here? Also, this is not a > > forum. > > > > > But I would appreciate it very much if some could please help me > styling > > > in HTMl with CSS? > > > > > > I have .selectmulti { border: 1px solid #c9c9c9 } this code but it > only > > > works in firefox How can I make this work in IE? > > > > > > And also I want to change the selected color. > > > > AFAIK this can't be done without some very nasty code due to the way IE > > renders select elements. Google has the answer if you really want it. > > Trinity renders shit, but for gods sake I would prefer if gecko would > render > atleast acid2 and keep up with the demands of the stylists, before they > call > themselves better than others. But then again, neither webkit or khtml is > as > versatile as the other two. > Anyone with thoughts on opera... > > > > > -Stut > > > > -- > > http://stut.net/ > > > > -- > --- > Børge Holen > http://www.arivene.net > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] best way for PHP page
If MVC is too heavy for you it may also be worth exploring templating engines such as Smarty: http://www.smarty.net/ On Jan 2, 2008 4:10 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > On Jan 2, 2008 2:17 AM, Alain Roger <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > i would like to improve my coding quality when i use PHP code and for > that > > i > > would request your help. > > in my web developer experience, i have to confess that i've never > > succeeded > > in spliting PHP code from HTML code. > > > > i mean that all my web pages consist of PHP code mixed with HTML code > (for > > rendering pages). > > Some developers tell it's possible to write only PHP code for web page. > i > > agree with them but only when those PHP pages do not render web elements > > (write text, display pictures, display formular, ...). > > > > the purpose of my post is to know if i can really (at 100%) split client > > code (display images, write text,...) from server code (move or copy > data > > to > > DB, create connection objects,...) > > > > so what do you think about that ? > > > > study up on mvc > http://en.wikipedia.org/wiki/Model-view-controller > > then look at some of the popular open source php implementations. > code igniter is very thin and straightforward. > you can quickly see how a php application can be separated into layers. > > -nathan >
Re: [PHP] First stupid post of the year.
don't use nonbreaking spaces use CSS to style the input button then you wont have to deal with redundant presentational gunk in your data On 1/2/08, David Giragosian <[EMAIL PROTECTED]> wrote: > On 1/2/08, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > > > > On Jan 2, 2008 1:34 PM, tedd <[EMAIL PROTECTED]> wrote: > > > > > Hi gang: > > > > > > I have a > > > > > > $submit = $_POST['submit']; > > > > > > The string contains: > > > > > > A > > > > > > (it's there to make a submit button wider) > > > > > > How can I strip out the " " from the $submit string leaving "A"? > > > > > > I've tried > > > > > >trim($submit); > > > > > > but, that don't work. > > > > > > Neither does: > > > > > >$submit = str_replace(' ','',$submit); > > > > > > or this: > > > > > >$submit = str_replace(' ';','',$submit); > > > > > > I should know what to do, but in this case I don't. > > > > > > Help is always appreciated. > > > > > > why dont you just style the button w/ css? > > > > style="width:200px" > > > > -nathan > > > > Parse the string character by character discarding '&' , 'n' , 'b' , 's' > , 'p' , and ';'. Assuming of course that the part of the label you want to > keep is none of those characters. > > -David > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] http_request
Also, supply an absolute URL when using header redirects. On Jan 5, 2008 3:44 PM, Daniel Brown <[EMAIL PROTECTED]> wrote: > On Jan 5, 2008 9:06 AM, peeyush gulati <[EMAIL PROTECTED]> wrote: > > Greetings on New Year :) > >To you, as well! > > > We have a script, say layer.php, which uses HTTP_REQUEST package to > > authenticate a user to an existing application (viz., wordpress, > > mediawiki etc.) > > > > I would like help on the following two fronts: > > > > 1. How do I return the cookies, headers etc. from the layer (which are > > being sent from the application) to the browser? > > 2. How do I redirect browser from the layer.php to a page of the > application. > > > > > > I was thinking that if I could find a way to send the headers and > > cookies to the browser, I could also send a 302 status code, along > > with the cookies, to redirect the user to a page of the app. > >When you create a cookie in your script, it is automatically sent > via the HTTP server to the client (browser). The same occurs with > $_SESSION information, as the PHPSESSID cookie is sent to the browser > to track the session name. > >With regard to redirection, there are a lot of ways to do that, > but the easiest is as follows: > > header("Location: somefile.php"); > exit; > ?> > >Just be sure to always exit; after using the header("Location: > xxx"); to stop the current script from running, unless you have > explicit reasons not to do so. > > > -- > Daniel P. Brown > [Phone Numbers Go Here!] > [They're Hidden From View!] > > If at first you don't succeed, stick to what you know best so that you > can make enough money to pay someone else to do it for you. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] http_request
It's advisable as the page you will be redirected to will be relative to the one the browser actually requested, so it's a good habit to get into. On Jan 5, 2008 4:05 PM, Daniel Brown <[EMAIL PROTECTED]> wrote: > On Jan 5, 2008 10:59 AM, Dave Goodchild <[EMAIL PROTECTED]> wrote: > > Also, supply an absolute URL when using header redirects. > >That's not necessary, as far as I know. Relative redirections > have always worked just fine. > > -- > Daniel P. Brown > [Phone Numbers Go Here!] > [They're Hidden From View!] > > If at first you don't succeed, stick to what you know best so that you > can make enough money to pay someone else to do it for you. >
Re: [PHP] More frustration with MySQL and PHP
Don't be scared of functions, no magic or mystery there, all you are doing is putting your code in a function like so: function add($a, $b) { return $a + $b; } ..for example and calling it like so: $a = 12; $b = 100; $sum = add(12, 13); ...etc etc, not too much more to learn than that and now I can call add() in many places... On Jan 21, 2008 8:47 PM, Robert Cummings <[EMAIL PROTECTED]> wrote: > > On Mon, 2008-01-21 at 15:28 -0500, Jason Pruim wrote: > > On Jan 21, 2008, at 3:27 PM, Robert Cummings wrote: > > > > > On Mon, 2008-01-21 at 15:20 -0500, Jason Pruim wrote: > > >> > > >> I try so hard to NOT rely on the wealth of info available here, but > > >> you guys don't make it easy!! :) > > > > > > The only good thing to do with wealth is share. > > > > Now you're just trying to add to your post count! :P > > Quit responding, you're diluting my post wealth! >:) > > Now I just need to find a way to increase the content of my posts. Best > bet I guess would be to not trim the posts to which I reply :) Then > again, endless rambling could help too... while honing my writing > skill... WOOT! Two birds with that stone. Talking about stones, someone > mentioned to me once a perplexing question whereby God was asked if he > could create a stone he could not lift... well I... crap, list cops are > at my door. I'll be write back!!! > > Cheers, > Rob. > -- > ... > SwarmBuy.com - http://www.swarmbuy.com > >Leveraging the buying power of the masses! > ... > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Question about functions
Methink you're a little confused. A function is a piece of code that performs a specific job that can be called. You may send it data, you may not. It may return data, it may not. If your link goes to logout.php, that script may use functions to do it's job. You can't call a function in a link as php is server-side. What you are thinking of is an event handler, ie client side (javascript). Example of how you could achieve what you want: logout.php include 'logfunctions.php' logout($_GET['id']); header("Location: index.php"); exit(); logfunctions.php function logout($id) { unset($id); } etc etc etc - crude example but pushed for time and you get the idea! On Jan 24, 2008 8:00 PM, Jason Pruim <[EMAIL PROTECTED]> wrote: > Hi everyone! > > So, I'm trying to learn about functions, and I think I understand what > to use them for... And one of the ideas I had was to write a function > to logout of an application. The question I have though, is how do I > call it? > > Right now I just have a link like this: Click > here to logout Can I do the same thing with a function? And if > so, then maybe I don't really understand functions like I thought I > did... Because to me, that would look like it would be just the same > as calling a single script to logout vs. a function? > -- > > Jason Pruim > Raoset Inc. > Technology Manager > MQC Specialist > 3251 132nd ave > Holland, MI, 49424 > www.raoset.com > [EMAIL PROTECTED] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Question about functions
Said it was a crude example and I was pushed for time On Jan 24, 2008 8:13 PM, Eric Butera <[EMAIL PROTECTED]> wrote: > On Jan 24, 2008 3:08 PM, Dave Goodchild <[EMAIL PROTECTED]> wrote: > > header("Location: index.php"); > > Redirect uri's should be absolute. >
Re: [PHP] Re: Why use session_register()?
session_register is old school. RTFM. On Mon, Mar 10, 2008 at 4:26 PM, Al <[EMAIL PROTECTED]> wrote: > Read the current php manual. > > Lamonte H wrote: > > Is it necessary to use session_register()? What exactly was the point > of > > this function if you can set sessions using $_SESSION it self? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] What's wrong the __autoload()?
Will you two pricks cut it out. How fucking tedious. On Wed, Mar 12, 2008 at 9:34 PM, Robert Cummings <[EMAIL PROTECTED]> wrote: > > On Wed, 2008-03-12 at 22:26 +0100, Aschwin Wesselius wrote: > > Robert Cummings wrote: > > > On Wed, 2008-03-12 at 16:11 -0500, Greg Donald wrote: > > > > > >> On 3/12/08, Robert Cummings <[EMAIL PROTECTED]> wrote: > > >> > > >>> > -1 for not recognizing a rhetorical question. > > >>> > > >>> +2 for setting his tongue firmly in cheek and providing you with an > > >>> answer to your rhetorical question. > > >>> > > >> -1 for thinking rhetorical question responses mean jack. > > >> > > >> -1 for thinking +2 exists. > > >> > > > > > > *Yawn* > > > > > > > -5 for not keeping this kind of childish behavior of the list (both of > you) > > You're new around here right? > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] PHP and #if
in php you have a number of constructs that can be used to execute code (or not) based on certain conditions ie is_defined(). Not sure if the comparison with C holds true as C is compiled and PHP is interpreted. On Fri, Mar 14, 2008 at 6:34 PM, Eric Gorr <[EMAIL PROTECTED]> wrote: > If you are talking about simply commenting code out, yes, I am aware > of this...however, the #if technique is far more capable in certain > situations. > > There are reasons why C, etc. has included the ability to comment out > lines of code and also provide #if's. > > But based on your reply, I have to assume that PHP does not current > provide such a technique...as I suspected. > > > On Mar 14, 2008, at 2:22 PM, Børge Holen wrote: > > > On Friday 14 March 2008 19:19:30 Eric Gorr wrote: > >> In C, etc. one can place #if's around code to determine whether or > >> not > >> the compiler should pay any attention to the code. > >> > >> Is there a similar technique for PHP? > >> > >> I've not seen anything like this before and a brief search hasn't > >> turned up anything either...just thought I would ask to make sure. > > > > # Notin' here > > // here neither > > */ > > Nor there > > /* > > > > -- > > --- > > Børge Holen > > http://www.arivene.net > > > > -- > > 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: fwrite/fclose troubles
Why are you writing a logging class? Why not use error_log and enable error logging? On Fri, Mar 21, 2008 at 1:11 PM, Al <[EMAIL PROTECTED]> wrote: > int file_put_contents ( string $filename, mixed $data [, int $flags [, > resource $context]] ) > > This function is identical to calling fopen(), fwrite() and fclose() > successively to write data to a > file. > > This native function does it for you > > Mark Weaver wrote: > > Hi all, > > > > I've been lurking and reading now for some time, but have decided to > > come out of the shadows cause I've got an issue that's gonna drive me > > crazy! > > > > I'm developing an application and within this application is a class > > that is very simple and only serves a singular purpose - to make log > > entries to help with debugging. Problem is, now I'm debugging the damned > > logging class that is supposed to be helping me debug the application as > > I'm putting it together! I've looked and looked all over the > > place, but I don't seem to be able to find an answer to this problem. > > The only information that I have found so far deals with permissions and > > I don't think that's the problem. At first I was getting an access > > denied error but since setting dir perms and log file perms so that both > > apache and my user can right to both the directory and the file that one > > has gone away. > > > > Log Directory permissions: /mystuff/logs rwx-rwx-rwx > (777) > > Log file permissions: /mystuff/logs/run.log rwx-rwx-rwx > > (777) > > > > At any rate, the following is the information I'm getting in the apache > > error_log while working on this particular portion of the application: > > > > PHP Warning: fwrite(): supplied argument is not a valid stream resource > > in /mystuff/inc/Log.inc on line 22, > > PHP Warning: fclose(): supplied argument is not a valid stream resource > > in /mystuff/inc/Log.inc on line 23, > > > > The Log class: > > - > > class Log{ > > public $path, $entry, $logfile; > > > > public function Log(){} > > > > public function setLog($path,$file){ > > $this->path = $path; > > $this->logfile = $file; > > } > > > > public function writeLog($entry){ > > // open the file, in this case the log file > > $h = "$this->path/$this->logfile"; > > fopen($h, 'a+'); > > fwrite($h,$entry); > > fclose($h); > > } > > } > > > > Code snippet where attempting to write log entry from program: > > > > > > > $pl_log = new Log; > > $pl_log->setLog($logpath,"run.log"); > > > > $usernanme = $_POST['username']; > > $password = $_POST['secret']; > > > > /** > >* (debugging) logging incoming values from form: > >*/ > > $pl_log->writeLog("getDateTime(): Incoming values from Login > Form: > > blah...blah...blah\n"); > > > > Any help with this would be most appreciated. (be gentle... I'm a PERL > > program learning PHP OOP) > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] ${}
You can also use that in interpolations where the variable name may be ambiguous ie "My name is Stephen and I am a {$type}drone" ..or to interpolate array lookups: "This is {$desc['mood']} don't you know!"
Re: [PHP] Re: everything printed suddenly has blue text, as if were a link
View the source, you have this: which is not closed, therefore everything after it will be blue.
[PHP] IE and cookie issues in PHP app
Hi all. I have built an online events directory in php ( http://dontjustsitthere.co.uk) where people can find local events and also post their events. The app is composed of a single page, index.php, that generates different content depending on the parameters passed to it and uses sessions for persistence. I have had nothing but pain with IE6 with this, I don't use any third-party cookies and one issue was resolved by using this line at the top of the page: ini_set('session.name', 'couchy'); session_start(); To post an event, the first form processes the category and postcode of the event plus a captcha field. The fields are validated and cleaned and then passed into $_SESSION. On the next stage I perform a cookie check, and if there are issues warn the user. This has been happening to every IE6 user, they can't get past the first page - so that means that $_SESSION['category'] and $_SESSION['postcode'] are not being populated. I thought I had this nailed but it's rearing it's butt-ugly head again. Anyone aware of the probable cause of this? -- http://www.web-buddha.co.uk
Re: [PHP] Why does this encoding work in PHP?
The characters are encoded in octal and the php interpreter converts them into the corresponding ASCII characters and then the sequence is represented as a string which is included?
Re: [PHP] GET variable unexpectedly assigned to session variable
Another small and unrelated point - you don't need to use double quotes inside the array brackets - you're not processing them at all.
Re: [PHP] Do you use any framework in your applications?
It's a personal thing. I use Code Igniter (codeigniter.com), which is fast, lightweight, has a great community and excellent documentation, as well as some very good video tutorials. It pales in comparison with Ruby On Rails, of course, but that's another thread on another list...
Re: [PHP] problem with string & floats in PH
What function(s) are you using to read the file contents? How are you inserting them into the array? Code examples please...
Re: [PHP] Re: Tipos about which CMS use
You could also try Drupal. Drupal 5 comes bundled with jQuery. Drupal is powerful and flexible and the community is large and supportive.
Re: [PHP] Return or not to return, that is the question
If there is no need to return a value then I don't do so. However, the function is going to process something, and surely you should check that the processing has succeeded or failed?
Re: [PHP] Attempting to search a MySQL database from PHP not working
Your problem is this: $result_row[] = mysql_query($query) or die(mysql_error()); ...you are assigning a query to a variable. What you need to do is something like this: $result = mysql_query($query) or die(mysql_error()); while ($result_row = mysql_fetch_array($result)) { . }
Re: [PHP] Re: directories - again
umask
Re: [PHP] file permissions
Why not use umask?
Re: [PHP] Re: any security problems with this?
Unless some server config error causes that stuff to be output on the page? I tend to put such functions in a .inc file and amend the .htaccess to prevent download.
Re: [PHP] Re: any security problems with this?
Sure, I usually put these files outside the docroot - unless I am in some f**ked-up hosting environment that doesn't let me change the include path...
Re: [PHP] Re: Form Data Filtering
I use something like this: $_SESSION['profane'] = false; foreach ($_POST as $value) { foreach ($swearbox as $profanity) { if (preg_match("/$profanity/i", $value)) { $errors = true; $_SESSION['profane'] = true; mail(TECHEMAIL, 'profane content attack attempt on DJST', "Word: $value From: {$_SERVER['REMOTE_ADDRESS']} Time: " . date('d F Y G:i:s', time()-TIMEDIFF), '[EMAIL PROTECTED]'); } } } // second pass - words that are offensive in isolation but could be part of acceptable words above foreach ($_POST as $value) { foreach ($refined_swearbox as $profanity) { if (preg_match("/\b$profanity\b/i", $value)) { $errors = true; $_SESSION['profane'] = true; mail(TECHEMAIL, 'profane content attack attempt on DJST', "Word: $value From: {$_SERVER['REMOTE_ADDRESS']} Time: " . date('d F Y G:i:s', time()-TIMEDIFF), '[EMAIL PROTECTED]'); } } }
Re: [PHP] Re: Form Data Filtering
No, because extra processing is done on the other side - now fuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuckfuck off
Re: [PHP] Programming question - New to PHP
On 29/06/06, Chris <[EMAIL PROTECTED]> wrote: Russbucket wrote: > I took an example of a script from the PHP documentation and try to connect > to my database. If I leave in the or die part of line 3, I get nothing, if > I comment out that part I get the echo message on line 4. > > // Connecting and selecting the database > $conn = mysql_connect ('localhost', 'finemanruss', 'XXXl') or die ('Could > not connect : ' . mysql_error()); > echo 'Connected successfully'; > mysql_select_db ("Lions", $conn); > > // Preform SQL query > $query = 'SELECT * FROM Moses_Lake_Lions'; > $result = mysql_query ($query) or die ( 'Query failed; ' . mysql_error()); > ?> > > I know line three works without the or die part since I have a 2nd script that > is almost the same (no or die) and it retrieves info from my DB. Try it the same as the php manual page: $conn = mysql_connect(''); if (!$conn) { die("Could not connect: " . mysql_error()); } You may be logging the errors. Tty echoing the value of the resource ($conn) - it should be an integer. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Re: Find out cookies on a computer?
On 29/06/06, Jay Blanchard <[EMAIL PROTECTED]> wrote: [snip] But I am loosing hope that it can be done now :) [/snip] I will go ahead and remove all hope. If you do not own the cookie, you cannot see it or use it. It is a rule of this jungle that has been in place for years. Yes, let's put this baby to bed. You have access to the $_COOKIE superglobal array and that is it. Period, Full stop. End. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] ONE PAGE CONNECTS MANY DATABASE
On 30/06/06, John Nichel <[EMAIL PROTECTED]> wrote: BBC wrote: > Hi again.. > > I'm wondering is it possible to make one page which connects to many > DataBase? > Yes. If you are using mysql, why not create connection functions that sit outside the server root (in the include path) for security and pass in the database names to the function (if they all reside on the same server). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Filter php page
On 05/07/06, Jay Blanchard <[EMAIL PROTECTED]> wrote: [snip] can I create a script that will search a php page for iframes. And have it check the path of the iframe, If the iframe is listed as bad don't show. (list I make) Trying to do something with virus like through an iframe. I don't really know where to start looking for help. [/snip] Best thing to do is open the file, use regular expressions to capture all text that begins and ends with 'iframe', parse that for src=url, attempt to get the url, if it fails it's bad and you can rewrite the string back into the file, perhaps adding a css class such as 'class=bad' that has display set to none. So, have a look at files, regular expressions and css. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] $previous variable ?
On 12/07/06, Jay Blanchard <[EMAIL PROTECTED]> wrote: [snip] A bit off topic, but I hadn't heard about short tags being a bad idea. What reasons make short tags worse than the regular tags. Just curious. [/snip] Two words, XML. Yep, they can interfere with xml processing, and they also make your code less portable, as they may not be enabled in another environment. If you are sure your code is never going to move or be mixed with xml, by all means use them, but why not get into good habits? -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Silly varible question
On 13/07/06, Ed Curtis <[EMAIL PROTECTED]> wrote: I know this is probably simple as all get out but it's early and I can't find an answer anywhere after searching for a while I need to assign a number to a variable and then use that variable in a session to store an array. It's for a shopping cart system I'm building. What I've got is: $count = 1; //First item in the cart passed from form to form $item = array(); $item[] = $_POST['phone']; $item[] = $_POST['category']; $item[] = $_POST['copy']; $item[] = $_POST['pic_style']; $item[] = $cost; $item[] = $image; session_register('item'); In the session the item is known as 'item'. What I need for it to be is 'item1' so when the customer chooses another product I can increase $count by 1 and have the next array with values stored as 'item2'. Thanks for any help, Ed First off, don't use session_register, use the $_SESSION superglobal array, that way you can create: $_SESSION['count'] = 1 and increment like so: $_SESSION['count']++ then you can create the cart like so: $item{$_SESSION['count']} = array(); does this make sense. Maybe not, but then again I've had far too much coffee. Make sense to the php gurus out there? -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Upload a big file.
On 13/07/06, João Cândido de Souza Neto <[EMAIL PROTECTED]> wrote: Hello gang. I´ve got a e-commerce system where one can import data from his management system. This importation files sometimes has a size about 8Mb. Unfortunatly, when one try to put this file into e-commerce, generaly one gets any error because your connection speed is very slow and can´t send this file. There´s any way to increase this wait time and get big files? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php First of all, use set_time_limit(0) in your script, which gives an unlimited execution time. Then amend the max files size limit in php.ini, or locally. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] regular expression to extract from the middle of a string
On 14/07/06, Steve Turnbull <[EMAIL PROTECTED]> wrote: Hey folks I don't want to "just get you to do the work", but I have so far tried in vain to achieve something... I have a string similar to the following; cn=emailadmin,ou=services,dc=domain,dc=net I want to extract whatever falls between the 'cn=' and the following comma - in this case 'emailadmin'. Question(s); is this possible via a regular expression? does php have a better way of doing this? Some pointers would be greatly appreciated. Once I have working, I will be creating a function which will cater for this and will post to this list if anyone is interested? Cheers Steve I think you will have to use minimal matching to ensure you only grab the first sequence. the following pattern should do the trick: '/cn=(\w+,?) -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
[PHP] Htmlentities vs htmlspecialchars
Hi all. I know htmlspecialchars converts the smallest set of entities possible to generate valid HTML, and that htmlentities goes much further, so what is the difference? Is it not better to use htmlentities in every case, making htmlspecialchars somewhat redundant, or is there a performance tradeoff? -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
[PHP] Postcode proximity classes
Hi all. I am about to start writing an events listing application (nationwide) and want users to be able for example to specify events within a 5, 10 and 15 mile radius of their postcode. Does anyone know of a set of classes/library that can provide this, would rather not fork out on a bespoke piece of kit. Any suggestions appreciated! -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] is it possible to manipulate vars here..
On 02/08/06, Jochen Kaechelin <[EMAIL PROTECTED]> wrote: .. to build a url like http://devil.server.com/vitims_page.php?? Not sure what you're trying to do, but switch register_globals OFF. Also, if you are trying to concatenate strings inside the function, use ., not +. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] The difference between ereg and preg?
On 04/08/06, Chris <[EMAIL PROTECTED]> wrote: Dave M G wrote: > PHP List, > > Recently I wrote a piece of code to scrape data from an HTML page. > > Part of that code deleted all the unwanted text from the very top of the > page, where it says " of a "" tag. > Is there any reason why either ereg or preg would be more desirable over > the other? > Ereg uses POSIX regular expressions which only work on textual data and include locale functionalily. preg uses PCRE, which work on binary as well as textual data and is a more sophisticated regex engine, incorporating minimal matching, backreferences, inline options, lookahead/lookbehind assertions, conditional expressions and so on. They are often faster than the POSIX equivalents also. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Regular expression to find from start of string to first space
On 08/08/06, Dave M G <[EMAIL PROTECTED]> wrote: PHP, Shouldn't this regular expression select everything from the start of the string to the first space character: $firstWord = preg_match('#^*(.*) #iU', $word); It doesn't, so clearly I'm wrong, but here's why I thought it would: . stands for any single character, not *. Also, # is the delimiter, but you can use a variety of deliimters. The following should work: ^[\w\d]+\s{1} ^ start of line [\w\d]+ range of any digits or letters, one or more (\s{1}) exactly one whitespace character hope this helps! -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] break up variable and put each element in an array
On 08/08/06, Reinhart Viane <[EMAIL PROTECTED]> wrote: A. I have a page on which people can supply dates in a text area. Dates are entered like this: 3/01/2005 29/12/2005 2/01/2006 20/02/2006 28/12/2006 1/01/2007 15/02/2007 B. Now I need this Post element to be broken into pieces (per date) and each of those pieces should be put into a text so the outcome (echo on screen) would be like this: Date=3/01/2005 Date=29/12/2005 Date=2/01/2006 Date=20/02/2006 Date=28/12/2006 Date=1/01/2007 Date=15/02/2007 The posted variable from A looks like this (when written on screen): 3/01/2005 29/12/2005 2/01/2006 20/02/2006 28/12/2006 1/01/2007 15/02/2007 So I need break this up and store any individual date into a key of an array Afterwards I need to loop through this array and use the value of each key to be printed after 'Date=' try this: $string = "3/01/2005 29/12/2005 2/01/2006 20/02/2006 28/12/2006 1/01/2007 15/02/2007"; $array = explode(' ', $string); foreach ($array as $value) echo "Date: $value";
Re: [PHP] preg_match
On 09/08/06, Peter Lauri <[EMAIL PROTECTED]> wrote: Hi, How do I add so that it checks for a comma , in this preg_match. I think the documentation is not that good for the pref_match: preg_match('/^[a-z0-9-_\'() +]*$/i', $s); Check for a comma inside a range - use a comma! -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] preg_match
On 10/08/06, Peter Lauri <[EMAIL PROTECTED]> wrote: Hi there, You are correct that I am stupid to call the manual bad, it was not meant like that. It was that it was not suited to me, and that I actually just wanted to find a solution to my problem directly, and it did not give me that. I have never worked with Regular Expressions before, so I might need to do some more research on that, it seams to be a good tool :) I will do some testing in the CMD to learn how to use it, should not be that big of a deal :) Many times the regex looks like rubbish, but that is just because I do not know the "language" :) Indeed - remember, regex is a language all of its own and it takes a while to get comfortable with the syntax and think in regex. The Regex Coach is great by the way. Also, when you build expressions, build them up slowly, testing each part as you go.
Re: [PHP] Parsing RSS
On 12/08/06, John Taylor-Johnston < [EMAIL PROTECTED]> wrote: Is there something already created to open an rss file, parse it, and include() the useful stuff into an html file? Not all my students have an rss reader. http://jtjohnston.ca/jtjohnston.rss Yep. The PEAR XML_RSS class. for example: $feed = 'foo.rss'; $rss =& new XML_RSS($feed); $rss->parse(); foreach ($rss->getItems() as $item) { // output rss } -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
[PHP] Include and require
Hi all - I have several require_once statements in my web app to load in small function libraries. A common one bundles a variety of functions to handle date math and map month numbers to month names. I originally defined an array in that file plus a bunch of functions but when I loaded the page, the array variable, referenced further down the page, was NULL. I wrapped a function def around the array and returned it and all was fine. I may be suffering from mild hallucinations, but can you not define variables in a required file? It is not a scope issue as the array variable is referenced in the web page, not in any function. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Creating custom superglobals
On 15/08/06, Richard Lynch <[EMAIL PROTECTED]> wrote: On Mon, August 14, 2006 8:40 am, Ville Mattila wrote: > Does the PHP environment (5.1.4) provide a way to define some custom > variables as a superglobal? It would be useful for saving certain site > preferences and settings that must be referred in many variables and > classes, without every time writing global keyword at the beginning of > a > function definition. ...or why not keep it simple and use include_once/require_once? I generally have a config file for every app that contains constants, variables and so on that are used across the application.
Re: [PHP] login script
On 15/08/06, Ross <[EMAIL PROTECTED]> wrote: Hello, I have a couple of questions first how do I check two tables is it? $sql = "SELECT * FROM mytable, mytable2 WHERE username = '$username' AND userpass = '$userpass'"; Secondly my table just sends and returns straight values from the db but I expect some kind of encription is required. What is a simple, secure method. md5() or another method. Do I store an encypted file on the server and just decrypt it at the php page. my auth script at present $pass = md5(password); select * from table 1 where password = '$pass'; I think the php and mysql md5 functions differ but I may be wrong! -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Espanol en esto lista
Hablo espanol, pero lo que Rory dice es verdad, hay otra lista en espanol. Pero, si quieres, you tratare entender tu palabra. In short, speaking a language other than English on this list( especially considering that there is a php.general.es - http://news.php.net/php.general.es ), is similar to whispering in company. Most of us don't understand what you're saying. Rory -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] Espanol en esto lista
I don't speak enough Spanish to understand it all, but tratare according to altavista is "to treat" - not really sure I get it. Sorry, should be 'yo tratare', tratar also means to try - I will try and understand... -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk