RE: [PHP] Dear Lazy Web: Pseudo Randomisation Strategies on Listing Websites
Hi Col, Interesting problem. Are there any other approaches I've missed? Off the top of my head, how about this: 1. Add a new unsigned int column called SortOrder to the table of widgets or whatever it is you're listing 2. Fill this column with randomly-generated numbers between 0 and whatever the unsigned int max is (can't remember exactly but 4.2 billion ish) 3. Add the SortOrder column to the end of all your ORDER BY clauses - SELECT foo ORDER BY TypeOfListing, SortOrder will give you widgets sorted by Gold/Silver/Bronze type, but in a random order for each type 4. Every hour/day/week/whatever, update this column with different random numbers Advantages: practically no hassle/overhead/maintenance for you; provides same ordering sequence for all users at the same time; only breaks third one down-type references when you refresh the SortOrder column rather than on each session or page view; reasonably proxy- and cache-friendly especially if you send a meaningful HTTP Expires header. Disadvantages: breaks user persistence if they visit before and after a SortOrder refresh (I'm sure the one I wanted was at the top of the list yesterday...); more effort to demonstrate randomness to the client (OK, see how you're in ninety-third place today? Well, check again tomorrow and you should be somewhere else on the list). Hopefully food for thought anyway. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Text editor
Hi Jordan, Do you somebody know some simple text editor with buttons for bold italic etc. TinyMCE is worth a look: http://tinymce.moxiecode.com/ HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Counting back 90 days...
Hi Tris, But is there an easy was to calculate 90 days from the timestamp... There are 86400 seconds in a day... can't you just do something like: $timestamp -= (86400 * 90); Or even $timestamp -= 7776000; // 90 days Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] register_globals security
Hi Fernando, I have a PHP application that passes variables (values) from a form. I get these using $_POST However I do also post some variables via a link. Which ofcourse requires register_globals to be ON. Do you mean variables in a URL, like this: www.example.com/index.php?foo=1bar=2 If so you can access these via the $_GET array and leave register_globals turned off. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Allowing specific IP's to bypass security.
Hi Tris, reset the session variable: $_SESSION['details_captured'] == FALSE; Re-asign it to yes: $_SESSION['details_captured'] == yes; You're using ==, which is the comparison operator - give it a go with just a single = instead. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Resource Limits
Hi, How can I get the values of 'max_execution_time', 'max_input_time' and 'memory_limit' from my php script ? Use the ini_get function: http://php.net/ini-get Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Editor - which to use?
Hi, Good coder will understand this at a glimpse: [snip horrible code] if($pos_params!=false) Assuming it's a boolean, $pos_params is *already* true or false, so testing it like this is pretty much pointless. It makes more sense (and is much more readable IMHO) to do something like this: if ($pos_params) { // something } I'm not sure how the PHP interpreter works internally but that might even save your script the overhead of an unnecessary comparison ;-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting part of a string...Was protecting a file via php
Hi Steve, $pfile = str_replace('get.php?file=','','$file'); $p = explode('.', $pfile); // How do I say look at the extension and put it into the switch? $extension = $p; // end of the bit I'm stuck on. At this point $p is an array rather than a variable, so you'll need to get the last element of $p.Try something like this: $p = explode('.', $pfile); $extension = $p[sizeof($p)-1]; Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Training Help
Hi Ryan, Sounds like register_globals is turned off on your server (this is generally a Good Thing). Rather than having all your form fields converted directly into variables - which your book is assuming, as it's how PHP used to do it - you'll need to access them via the $_POST array. Try changing this line: echo $tireqty. tiresbr; To this: echo $_POST[tireqty]. tiresbr; Search the manual or the list archives for register_globals and you'll get loads of info about this. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Training Help
Hi Ryan, $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; That'll certainly fix the problem, but it kind of defeats the point of using $_POST :-) Ideally you'd clean the data at this point to make sure no-one's trying to submit anything nasty (Google on SQL injection for an idea of what can be done). Seeing as these are quantities, checking them via PHP's is_numeric() function would probably be a good idea, and making sure they're inside sensible ranges (between 0 and 50, say) might be worthwhile as well. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] game in php
Hi, I have this database with this fields; id and number_attacks. And every 10 minutes number_attack to be increased by 1. You'll need to set up some sort of scheduled task (if you're on unix, your best bet is probably cron) - this task should call a script that connects to your database and updates the field. If you like, you can write the script in PHP and use something like lynx or wget to access it. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can Objects be passed to another page?
Hi, is it possible to pass an Object to another php page? Have a look into serialization: http://php.net/manual/en/language.oop.serialization.php Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] snippet
Hi Harry, can someone explain this for me: ... $sFont =submit(font) ? SITE_ROOT . PROG_PATH . submit(font) : ; ... It's called the ternary operator, and it's a shorthand for if...else... The line you're asking about is equivalent to: if (submit(font)) { $sFont = SITE_ROOT . PROG_PATH . submit(font); } else { $sFont = ; } The format is: (condition to check) ? (result if true) : (result if false); Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] controlling winamp with COM
Hi, It might even be possible that Winamp itself provides hooks to a running instance of itself via command line parameters (one can hope) which would simplify the task greatly. Winamp (v2 at any rate, I haven't worked with v3) has a great API, including hooks via the command line, which is nicely documented here: http://winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to..
Hi Haseeb, i.e. divide the functions into files. and then include only that file that has the function. That's how I usually do it - for example, I have a file called dates.lib.php which contains all my functions for handling dates and times, a file called db.lib.php which has my database stuff, etc etc. You may also want to look into classes, which provide a neat way to compartmentalise your code. Personally I don't find them very useful unless the project is large or has many programmers, though. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] News Reader
Hi David, Could someone advise me of a good news reader. Agent is pretty good: http://www.forteinc.com/agent/ Mozilla has a mail and news component, which you can download on its own if you don't want the browser, IRC client, HTML editor, etc: http://www.mozilla.org/projects/thunderbird/ Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with Date
Hi Elliot, I need a function to create the dates of previous Fridays, in 21-JUL-2003 format. It'll be different depending on what you want to happen if you pass a Friday timestamp to the function, but it should be something like: function friday($ts) { while (date(w, $ts) != 5) $ts -= 86400; return date(d-m-Y, $ts); } Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with UPDATE command...
Hi Tony, The UPDATE command does not seem to support the ORDER BY part despite it being listed in the instructions on the mysql.com website. This is only supported in versions 4 and above - if you're using 3.23 you can get away with LIMIT in your update queries, but not ORDER BY. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Communication between PHP Server code and HTML/JavaScript client without refreshing the page
Hi Sharat, How do I communicate betwen an HTML page having JavaScript and a PHP server code without having to refresh the HTML page. I don't think this is possible: once PHP has run (and sent your Javascript to the browser), it's finished - you can't use it again until the next time the page loads. If you want to do this sort of thing you're looking at a Java applet or something along those lines. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] - Default Date
Hi Gary, Is there a default variable built into PHP that has today's date? Have a look at http://php.net/date for this - http://php.net/mktime will probably be of interest as well. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] typecasting .. easy?
Hi Roy, If $amount equals for example 52., how do I get that to print as 52.00 similarly, if amount = 52.5 how do I get that to print as 52.50 Have a look at the number_format() function, it should do what you want. It'll also add commas to break up any thousands in your number (you can bypass that if you like). Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] convert seconds to hours, minutes, seconds
Hi Chinmoy, I have a value 178607, which is stored as seconds. I like to convert it (178607 Secs) to Hours, Minutes and Seconds appropiatly. Can anybody help me supplying the code? Try something like this: ?php function sec2hms ($secs) { $hms = ; $hours = intval(intval($secs) / 3600); $hms .= $hours. :; $minutes = intval(($secs / 60) % 60); $hms .= str_pad($minutes, 2, 0, STR_PAD_LEFT). :; $seconds = intval($secs % 60); $hms .= str_pad($seconds, 2, 0, STR_PAD_LEFT); return $hms; } echo sec2hms(6). br; echo sec2hms(60). br; echo sec2hms(66). br; echo sec2hms(3600). br; echo sec2hms(3666). br; echo sec2hms(178607); ? HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] determine action of a form dynamically?
Hi Mukta, I want action of a form to be PHP_SELF untill user presses continue button. If continue button is pressed than next.php should be the action of the form. how to do this? One way would be to have two buttons in your form, but submit to only one page: form action=process.php input type=submit name=op value=Continue input type=submit name=op value=Stop /form ... and then, on process.php, you decide what to do: if ($_GET[op] == Continue) { // do continuation stuff, or redirect somewhere } elseif ($_GET[op] == Stop) { // do stopping stuff, or redirect somewhere } else { // handle gracefully } Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Opinion on a method....
Hi Dan, I would like to get some opinions here on a method I'm doing to grab connect information for a mysql connection. Currently I am doing: $pinfo = fopen (/director1/directory2/filename.ini,r); Does this filename.ini contain the code to connect to your database? If so, I usually do two things with this file: 1. put it outside the document root, so users can't browse to it 2. put any code that might output something (an error message, for example) inside a function, so even if it is run, nothing will happen - you need to include() it and then call the function yourself. If it's just connection information, with no code (I'm a bit confused by the .ini extension :-) then just make sure it's somewhere outside your document root. Is XML a solution? I don't think XML is inherently any more secure than plain text - it's all down to how you store and transmit the data. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Opinion on a method....
Hi Dan, the ini file looks like: hostipuserpassworddatabasename after I import it, I split it up, and assign each to a variable name. I also have it outside the doc root, and it gives a generic error msg for every error in the system. Should do it - it's a bit of a long-winded route, though. As Kevin said, why not just use include()? It'll be a lot easier and just as safe :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] checkdate function
Hi Siva, checkdate function verifies whether the date is valid or not by taking month, day and year as arguments. The problem is when someone enters a three digit year by mistake (200 instead of 2003), this function does not catch it. Yes, I've been bitten by this as well :-) We are separating the year part from the string and validating separately to solve this problem. Is there a better way to do it? I think you're stuck with the extra validation step, but you can do it quite neatly with a replacement function that looks something like this: function myCheckdate ($m, $d, $y, $min = 1900, $max = 2100) { // check whether $y is within allowable range if ($y = $min || $y = $max) return false; // the year is OK: checkdate can do its stuff return (checkdate($m, $d, $y)) } You can adjust the default allowable years to match what you usually need, and then override them as necessary. Personally I'd like to see PHP's checkdate() work a bit like the one above, or maybe have checkReasonableDate() and checkImprobableDate(): I'm prepared to believe that some PHP developers need to validate three- and five- digit years, but I can't believe that it's *that* common :-) Cheers Jon -- Need a web or desktop developer in the London area? Hire me! http://www.laughing-buddha.net/jon/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] FTP
Hi Tomás, What's the meaning of this error?: FTP_PUT: Could not determine CWdir: No such directory. ^ Are you trying to save a file in a directory that doesn't exist? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] [Newbie] Password()
Hi Bobby, In my code I am trying to send an email (containing a password) to a user when he has forgotten his password. [...] The problem is that security leads to needing to encrypt passwords in the database. Im using the password function within mysql. Is there any way of reversing the password function to get the original password to send out to the user? I think it's a one-way hash, like MD5. You could set their password to something else - a random 8-letter string, for example - and send them that along with a note encouraging them to change it. If you want two-way encryption, have a look at AES_ENCRYPT and AES_DECRYPT: http://www.mysql.com/doc/en/Miscellaneous_functions.html (scroll down a bit) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] problem with mysql.
Hi Ryan, when configuring php i use --with-mysql and it configures just fine. i've even added an =/path/to/php after it to no avail. Try --with-mysql=/path/to/mysql instead of --with-mysql=/path/to/php. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] global var.
Hi Sebastian, $variable = $id; // some other stuff @mysql_query here $id = mysql_insert_id(); How do I get $id from insert_id() to pass to $variable above? Hard to explain the situation i am in, but the query has to be below $variable ::blink:: Perhaps something like: $loc = $PHP_SELF. ?variable=. $id; header(Location:. $loc); You'd have to put something in to stop an infinte loop though. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session Theft
Hi Haseeb, if i can get something from user end that is unique for that user.for e.g. his/her IP . Firstly, an IP address can be shared between multiple users, or it can change constantly for one user. Here's what a page request from an AOL user looks like (I've snipped the request paths, but left the timestamps and IPs untouched): 205.188.209.165 - - [14/Jan/2003:13:01:36 +] 205.188.209.9 - - [14/Jan/2003:13:01:37 +] 205.188.208.38 - - [14/Jan/2003:13:01:37 +] 205.188.208.134 - - [14/Jan/2003:13:01:38 +] 205.188.209.77 - - [14/Jan/2003:13:01:38 +] 205.188.208.136 - - [14/Jan/2003:13:01:39 +] 205.188.209.48 - - [14/Jan/2003:13:01:40 +] 205.188.208.169 - - [14/Jan/2003:13:01:40 +] 205.188.209.72 - - [14/Jan/2003:13:01:41 +] [...] Notice how the IP changes - they requested the page from 205.188.209.165, and then got each of the images from a separate IP. but it will not work when they are behind firewall.they will be assigned same IP.is there a way for me to get the IP (e.g. 202.202.202.202 thats just an e.g. ) plus computer ip(192.168. 0.1 e.g.) i saw once a java chat server do this. Instead of just checking the REMOTE_ADDR, try this: ?php if (getenv(HTTP_X_FORWARDED_FOR)) { $ip = getenv(HTTP_X_FORWARDED_FOR); } else { $ip = getenv(REMOTE_ADDR); } echo Your IP is $ip; ? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] connecting to mysql db
Hi Iggy, I mean the difference between having that code on every page or calling it from an external page doesn't tell me if it is realy necessary to do it all the time. Yes, you do have to connect to the database in every script that needs to access it. Usually this is done at the start of the script, along with any calls to session_start() and other global stuff. For convenience and ease of maintenance, however, it makes good sense to write a separate file that does nothing but connect to the database. This separate file then needs to be attached to the running script via include(), at any point before the first call to the database. HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] random letter/character?[Scanned]
Hi, function gen_password($length = 8) { $chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789; [snip] Just as a tip - if you want to save hassle for yourself and your users, remove the following characters from that string: - 1 (number one) - l (lower-case letter L) - I (upper-case letter I) - 0 (number zero) - O (upper-case letter O) These often look the same (for instance, in Courier New at 9pt, 1/l and 0/O are pixel-perfect matches of each other) and can cause major confusion amongst less technically gifted users :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: newbie:restricting users to change data in a textarea
Hi Coert, There is one field that I whant to stop them from changing You can put READONLY in your TEXTAREA tag While this would probably keep the honest people honest (assuming it's supported across all browsers), it won't stop anyone who wants to pollute the database. What's to stop me making my own version of your form, without READONLY, and submitting that? If the OP doesn't want users to change the data in the field, he/she should either display it so it's non-editable (i.e. in a p, or something), or simply ignore any changes users make to it. As a rule of thumb, *never* *ever* trust data that has left your server and then come back, regardless of whether it's in a readonly textarea, a hidden field, a cookie, whatever. Good programmers look both ways before crossing one-way streets. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] querying for values inside range
Hi Jason, $sql = select * from table where age=$age1 and age=$age2; what if i don't know which is value is greater, age1 or age2? PHP has a couple of handy functions for this: min() and max() $min = min($age1, $age2); // get smallest of two values $max = max($age1, $age2); // get largest of two values $sql = select * from table where age = $min and age = $max; You could also use BETWEEN in your query, which I think reads better: $sql = select * from table where age between $min and $max; This isn't connected to your question, but have a look at this when you have a spare 5 minutes: http://adopenstatic.com/faq/selectstarisbad.asp Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] table cell space under image in IE
Hi Larry, Why would they have /form take up visible space? It's a block-level element, like a paragraph or a div. Hmm, I guess I'll have to find a new angle or hide the closing form beyond the table. You don't have to resort to kludges, just tell the browser what you actually want: td form style=margin: 0px; padding: 0px !-- form elements -- /form /td Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how to uploads files
Hi Luis, how can i uploads files to my server by php script ? The manual explains this (read the user notes as well, though): http://www.php.net/manual/en/features.file-upload.php Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] rates for differents date?
Hi Shaine, ok question: 7days in a week. day 1-2 costs $10, day 3-5 cost $15, day 4-7 costs $10. I'm assuming you meant 6-7 here instead of 4-7, otherwise you've introduced a contradiction with days 3-5. how can I work out the total if someone stays from say day 2-5? or what about day 3-7? Try this: ?php // assume $start holds start day // assume $end holds end day // note that the first array element is 0 - this is // because day 0 doesn't exist :-) $costs = array(0, 10, 10, 15, 15, 15, 10, 10); $total = 0; for ($i = $start; $i = $end; $i++) $total += $costs[$i]; echo pTotal is $total./p; ? Working out how to change it so people can stay from day 6 in week 1 to day 4 in week 2 is left as an exercise for the reader ;-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] \n
Hi John, Nothing fancy. Can't get it to echo ¶ Is that a pilcrow sign? If so, have you tried para; instead, like this: $inputresult = str_replace('\n', 'para;\n', $testtextarea); Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] formtext
Hi Diksha, Parse error: parse error in /var/www/html/bdoi_change/f1.php on line 10 html head title /title /head /body h1Business Directory Of India/h1 pre ?php form You can't use HTML directly when you're inside a PHP block - het rid of the ?php on line 9, or use echo from line 10: ?php echo form; // etc Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: RE: [PHP] formtext
Hi Diksha, Parse error: parse error, expecting `','' or `';'' in /var/www/html/bdoi_change/f1.php on line 11 the code is: ?php echoform Please enter other login id:input type=text name=login /form; You need to escape the quotes inside the string, or use single quotes to define it. Either this: echo formPlease enter other login id:input type=\text\ name=\login\/form; ^^^^ ^^ ^^ note escaped quotes here Or this: echo 'formPlease enter other login id:input type=text name=login/form'; ^^^ ^^^ note single quotes here... ...and here Here's a great article that should clear all this up for you: http://www.zend.com/zend/tut/using-strings.php Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] info required reg. PHP
Hi, 1) Can we display an alert box using PHP. No, you need to use Javascript's alert() function. PHP is server-side only. 2) I would like to know the max. number of records or max. space a database (mentioned below) can provide. Oracle, MySQL and SQL Server are limited only by the space available on the server. Access has a defined limit, but it's quite large (2 gigs, I think), and it chokes when you have more than 5 connections open. I would *strongly* advise you not to use Access for a website - give MySQL or Postgres a go, they both beat it hands down. Access is a desktop database, not a server - it's great for holding your CD collection, but that's about it :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: RE: [PHP] formtext
Hi Diksha, Please excuse the line wrapping in my last post - you may have to copy 'n' paste into a text editor to see it as it should be :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP on IIS session problems
Hi Victor, Warning: session_start() [function.session-start]: open(/tmp\sess_f4aa3ef3c537bb6327d5e7b991e91be7, O_RDWR) failed: No such file or directory (2) in c:\inetpub\wwwroot\picoblog\admin.php on line 2 Pay attention to the error messages. This one explains exactly what you're doing wrong, if only you'd read it. You're trying to save your session files into your /tmp directory, which only exists on unix-based systems. You can fix this by editing your php.ini (specifically the session.save_path directive), but it's probably a good idea to RTFM as well. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Preventing the hijacking of pictures
Hi, $_SERVER[HTTP_REFERRER] does not help. Not sure if you've got it that way in your code, but that might be because it's spelt HTTP_REFERER - yes, it's wrong, you're right, but you have to live with it :-) I think you may also need to quote it like this, but I'm not sure: $_SERVER['HTTP_REFERER'] Also, if you're on Apache, there are numerous ways to block this sort of image hijacking using .htaccess files - a couple of minutes on Google will doubtless turn up all sorts of ideas. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Capitalising Personal Names
Hi Danny, I need to clean up the capitalisation of user-entered personal names. Well it's hardly rocket science - a flick through the manual and I came up with : $name=ucwords(strtolower($name)); While that would work in many cases, how do you catch exceptions such as the following? ?php $names[] = Ludwig van Beethoven; $names[] = Ronald MacDonald; $names[] = Alexis de Tocqueville; $names[] = Tim O'Reilly; foreach ($names as $name) echo $name. - . ucwords(strtolower($name)). br /; ? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] date, first of next month?
Hi Bryan, $t = mktime(0,0,0,date('m')+1,1,date('Y')); Gives you timestamp of first day, next month. Format accordingly with date(). is there such a say to now get the date of the first weekday after that date? You can brute force it: // grab the timestamp $t = mktime(0,0,0,date('m')+1,1,date('Y')); // if it's a saturday or sunday, add 86400 seconds (1 day) while (date('w',$t) == 0 || date('w',$t) == 6) $t += 86400; This doesn't take into account any bank holidays, of course - you'll need to do a lookup against a database or an array if you want to test for these as well (not sure if you want the first weekday or the first working day). There might be a more elegant way to do this, but with a maximum of three iterations round the while loop, I don't know if it's worth looking for :-) HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Date check
Hi Fredik, I have to dates that i want to check who is biggest. This does not work: if( $date1 $date2){ How can i check them? Presumably they're in SQL format, or something similar? The easiest way is to convert them to unix timestamps (look into the date() and mktime() functions to see how this is done). Timestamps are integers representing the number of seconds since 1st January 1970, so comparisons are extremely easy :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dynamic input fields in Form
Hi Frank, I have a form where the user selects for example; how many cars you have: 4. Then it most dynamicly create 4 input fields [...] Using only PHP, you'll have to make this a two-step process where page 1 collects the number of cars and posts to page 2, which generates the form accordingly. If is has to be done on the same page, you'll need to call a Javascript function every time the number of cars changes. That function will have to add or remove inputs from the form depending on the number of cars entered, and of course the whole page will break completely for anyone without Javascript. I'd make it a two-step process myself, it's considerably more robust and offers considerably less room for problems (what happens if I claim I have five cars, fill out their details, and then change it to three cars? which details do you get rid of?) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql auto increment question
Hi Robbert, Is there an easy way to find out what the auto_incremented number is so I can use it to update the other table? Sure, have a look at mysql_insert_id: http://php.net/mysql_insert_id Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Include today's date in a SQL statement?
Hi Brian, What would the SQL be to find a record where: start_date today = end_date ... WHERE start_date today AND today = end_date If you're asking how do I get today's date into an SQL statement, there are two ways: - use your DBMS's built-in function to get today's date - use PHP's date() function to format a timestamp as -MM-DD Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Documentation Help
Hi Hardik, I worked on educational intranet and library management system. I did comment my code but i dont know how to document functional and technical specification as well as database schema. Theoretically, you should write the specs before the program (that way, the program matches the specs, not the other way round) Looks like it's too late for that now though :-) Here's a good article on writing functional specs (part 1 of 4): http://joelonsoftware.com/articles/fog36.html Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] reading CD information
Hi Adam, Is it possible to have PHP read cd label information? Where is the CD? If it's in the CD-ROM drive of the webserver: probably. If it's in the CD-ROM drive of a visitor to your website: no. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HTML if no PHP
Hi Bob, I want to display an HTML page if PHP can't load an include file or otherwise has an error or just doesn't work. How do I do this? Not sure you can, especially not for the just doesn't work scenario. FWIW, you can test for the existence of a file before including it: if (file_exists(file/to/be/included)) { include (file/to/be/included); } else { include (backup/plain/HTML/file); } but that doesn't cover all the bases you asked about. I'd certainly be interested to hear any solutions to this one :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SQLqry in PHP
Hi Per, I try to use a SQLqry in PHP, but i get this anwser in my browser: FATAL: emalloc(): Unable to allocate 1073741824 bytes 1,073,741,824 bytes is exactly 1 gig - that's a *lot* of memory... Is this an astonishingly large query? Seems the PHP interpreter can't grab enough memory to do whatever it's trying to - I could well be wrong though. Got any code we can see? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] SQLqry in PHP
Hi, Yes, the field in the mssql database is 1073741824, but i want only to grab a few byte. I think you'll need to do this in the database, then. If you try and grab the whole field and then parse it in your script, you have to actually get that gig of data into your script - I assume this is where the error is happening, as your server doesn't have enough memory to store the query results. Here is my code: $sql = SELECT tblSamNr.Body FROM tblSamNr where ID like '$id'; Can you do select a substring with MSSQL? Something like: SELECT SUBSTR(tblSamNr.Body, 500, 2048) (assuming the 2kb text you want to grab starts at character 500) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] A way to break up the string????
Hi Scott, Just curious, is there a PHP function that will break up the string for us? http://php.net/explode Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Adjusting Indexed Field After Deleting Entry
Hi, I originally had a link #1, #2, and #3. I obviously deleted them. I was wondering if there is a way to use PHP/MySQL to get the indexed numbers to re-assign so that the first link you see is always #1 the second link you see is always #2 and so on? Thanks in advance, Roger PS The original script was not mine, it came from a 'php how to' article at web monkey, I did some modifications to fit what I needed. We don't want anyone thinking that I'm taking credit for their knowledge ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ This e-mail has been scanned for viruses by the WorldCom Internet Managed Scanning Service - powered by MessageLabs. For further information visit http://www.worldcom.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Adjusting Indexed Field After Deleting Entry
Hi, I originally had a link #1, #2, and #3. I obviously deleted them. I was wondering if there is a way to use PHP/MySQL to get the indexed numbers to re-assign so that the first link you see is always #1 the second link you see is always #2 and so on? (apologies for previous incomplete message - pressed Ctrl+Enter by mistake :-) If these are the primary keys in your database, you can reset the auto_increment with this query: ALTER TABLE tablename AUTO_INCREMENT = 1; Or set it to whatever you like: ALTER TABLE tablename AUTO_INCREMENT = 23; Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] IFRAMES PHP
Hi Greg, But the buttons are outside of the iframe, so that no matter how large the frame gets, the buttons are always in the same place :/ So stick an image of the button outside the iframe, wrap it in an a, and use the onclick handler to call a javascript function that submits the form. Of course, this will break for anyone who doesn't have javascript enabled (some estimates put this as high as 20%, but it depends on your audience). Alternatively, put your form inside a div with a fixed height and width, and the overflow property set to scroll or auto. This should behave in much the same way as your iframe, but with everything on the same page. Again, this will break for some users (those whose browsers *cough*NN4*cough* don't support fixed positioning and overflow), but at least it degrades more gracefully than the scripted solution. Thirdly, if you provide a link to a sample page, someone might be able to come up with a way to rework your form so you can avoid all this entirely :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] A rather strange problem.
Hi Denis, if the field is Jane Enterprises, the textbox shows only jane. At the moment, if you view the HTML, you'll see: input value=Jane Enterprises Your browser sees this as an input with a value of jane and an attribute called enterprises, which it doesn't recognise (and therefore ignores completely). What you need to do is stick quotes round this, so it'll become: input value=Jane Enterprises HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] $_GET space in index changed to underscore
Hi Per, Anyone who knows why get variables whit spaces in looking like this in the URL blah.php?aa+bb=1 is changed to aa_bb in $_GET resulting in $_GET['aa_bb'] instead of $_GET['aa bb']? I don't think spaces are legal in variable names - PHP's probably just trying to recover from the dodgy data it's getting. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with functions
Hi, I keep getting errors in my script that says 'x' function is undefined or 'y' function is undefined. I defined it as 'function test ($a, $b)' and call it using 'test($a, $b)' You need to post code :-) Try this: ?php function test ($a, $b) { echo I am the test functionbr /; echo a is $abr /; echo b is $bbr /; } test(1, 2); ? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Displaying first 20 characters of a comment
Hi Kevin, I am trying to find out what the best way is to display only the first 20 or so characters of a comment. [...] I am not sure if it is best to do it with the select statement or format it with the PHP. Either way I am not sure how. If you only want the first 20 characters, and that's all you ever want, it's probably best to do it with the select statement, because then you're not spending time and bandwidth getting data you don't need from your database. SELECT LEFT(someField, 20) FROM someTable will get you the first 20 characters. Of course, you now have a problem with words splitting :-) You can get around this either by grabbing the whole comment and splitting it on spaces, or by having a separate synopsis field in your database (this is how I do it). Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] validate date
Hi Diana, If a user inputs a date into a form, what function can I use to validate that he put in a valid date? You can't. Here are two dates in two different formats. Only one is valid. - 13/04/01 - 13/04/01 Can you spot which is which? I want to use checkdate but that needs the date split up into day, month year. Anyone have an easy way of doing this? You could try separate drop-downs: one for day (with numbers 1-31), one for month (with names) and one for years (whatever you need). This gives you three variables that you can easily pass to checkdate(). Don't fall into the trap of thinking that if you put some text on your form saying please enter dates in mm-dd-yy format that that's what you'll get, unless you *really* know your audience. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Undefined variable error message
Hi Michael, All of the PHP scripts hosted on a Linux server I'm working with have suddenly begun producing an error message: undefined variable 'variablename' Looks like someone's tweaked the error reporting level so it's on E_ALL, which can be a somewhat alarmist setting :-) Read all about it at http://php.net/manual/en/ref.errorfunc.php The latter would suggest fairly significant security issues. Does anybody have any ideas as to how this might have occurred Are you on a shared host, or is there someone else who admins your box? If so, have a word with them and see if they've been fiddling with php.ini - that's where the error reporting level is set. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Javascript var to PHP
Hi Cesar, I want one of my links to open a brand-new pre defined window using a javascript but I don't know how to pass a variable so the opened PHP file knows which info to get from MySQL... In your launchinfopage() function, presumably you're specifying the url of the page (foo.php or something)? If so, just tack the variables on the end of the url as normal: foo.php?varname=varvalue And then, in foo.php, look in the $_GET array: echo varname is . $_GET['varvalue']; I do this quite a lot, I can go and dig up the code if you're still having problems. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Javascript var to PHP
Hi Cesar, Jon, thanx for the fast response, but the problem is that the link is made dynamically from a DB and the varvalue changes on every link... if it helps, I make this link list with a FOR loop in PHP and the varvalues I want to pass are the IDs of a table elements. You probably need to do it along these lines: // assume ids are in $id[1...10] for ($i = 1; $i = 10; $i++) { echo 'a href=javascript:lauchinfopage('; echo $id[$i]; echo ')click for more info/abr /; } and, in your JS function: function launchinfopage(id) { url = infopage.php?id= + id; // open url however you like } I imagine you have your url hardcoded in your launchinfopage() function... this makes it less portable, you may want to consider passing the complete url to a generic open new window function. HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to upload a file
Hi Somesh, This works fine for small files of like some Kbs but fails to upload larger files near to 1MB. What's your upload_max_size set to in php.ini? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to upload a file
Hi Somesh, This works fine for small files of like some Kbs but fails to upload larger files near to 1MB. What's your upload_max_size set to in php.ini? It is as follows ; Maximum allowed size for uploaded files. upload_max_filesize = 8M I don't have a clue then, sorry :-( Might be a timeout thing, but I can't see how that could affect it... you could try bumping up max_execution_time and see if anything happens grin Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Use of undefined constant error
Hi, Notice: Use of undefined constant id - assumed 'id' in ... Try changing this: if(isset($_GET[id])){ to this: if(isset($_GET['id'])) { note quotes PHP thinks you're trying to use a constant called id, which you haven't defined - hence the undefined constant error ;-) Note how the message says assumed 'id', which is what you should change it to - this shouldn't stop your script from running, as the parser can work out what you meant, but your error reporting is set sufficiently high that PHP lets you know about it. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Showing 10 record items per page...?
Hi David, If I have lets say 30 items that match the query, I would like the page to display this at the bottom Previous 10 page 1 2 3 Next 10 of 30 To get the 20 results starting at #100, your query will be something like SELECT foo FROM bar LIMIT 100, 20 To do paged results with MySQL, have a variable (called $start or something) that keeps track of how many pages into the results you are, and increment or decrement it in the next and previous page links: a href=results.php?start=?=($start-1)?previous/a a href=results.php?start=?=($start+1)?next/a And construct your query along these lines: SELECT foo FROM bar LIMIT ($start * 20), 20 Hope this gets you started. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP with GD Support
Hi Oliver, ich want to install php.4.2.3 with gd-suport. Any hints are welcome. You'll need to look it up, or do a configure --help or something, but I imagine you compile with something like --with-gd=/path/to/gd Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] if question
Hi John, Can anyone tell me why this doesn't seem to work ?? It probably is working, but it's obviously not doing what you want :-) if (($stelle_who != '1') OR ($stelle_who != '2') OR ($stelle_who != '3') OR ($stelle_who != '5') ) { This will always evaluate to true: if $stelle_who is 1, it doesn't equal 2 or 3 or 5 if $stelle_who is 4, it doesn't equal 1 or 2 or 3 or 5 and what can i use as an alternative syntex ?? Depends what you're trying to do... most likely switch your ORs to ANDs, though (that'll evaluate to true if $stelle_who is neither 1 nor 2 nor 3 nor 5, and to false if it is any of these). Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Performance issues
Hi Karel, mysql entries: at least 2M php code: at least 1M lines More than a million lines of code? That's a *big* app. 1megabyte of code :) not 1M lines Aha :-) and the problem began slow, not noticable... But it's now worse then ever. Are you doing something that degrades, like reading in an entire text file, adding a line to the end of it and saving it again? (Each time you do this it will take a bit longer). Did you look at the output from top (assuming unix) or task manager (assuming windows)? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filter vulger / controversial words - need word source
Hi Christopher, I'm wondering if someone has a great source for a master-list of controversial and vulger words that I can use on my site. I would like to pattern match input text against this master-list in order to prevent vulger and controversial words from appearing on my site. Before you spend ages finding a good list, get the routine working. Once you've got the routine working, post it here, because there are many people who would like to know how to do this properly. The problems that others have experienced in the past are: - what happens with misspellings, e.g. fsck? - what happens with dodgy formatting, e.g f s c k? - what happens with words like Scunthorpe? Additionally, from my experience of the mail content filters we use here at $WORKPLACE, you will also need to be careful not to cause offence by catching peoples' names. We have a Chinese gentleman as a client with a surname that could be mistaken for an offensive word - he was not best pleased to receive a bounce message telling him that his email hadn't been delivered because he was using profanity. May I suggest, rather than picking your way through this minefield, you provide a report abusive comment link instead? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filter vulger / controversial words - need word source
Following up to my own post Once you've got the routine working, post it here, because there are many people who would like to know how to do this properly. I didn't use any profanity I was aware of in this post, but I still received this a few minutes later: Trend SMEX Content Filter has detected sensitive content. Place = 'Christopher Raymond'; [EMAIL PROTECTED]; Sender = Jon Haworth Subject = RE: [PHP] Filter vulger / controversial words - need word source Delivery Time = December 11, 2002 (Wednesday) 22:13:00 Policy = Dirty Words Action on this mail = Delete message I wonder if it was Scunthorpe I suppose I'll find out when/if I get another bounce :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filter vulger / controversial words - need word source
Following up to my own post And again... I wonder if it was Shorpe I suppose I'll find out when/if I get another bounce :-) I got another bounce :-) Whoever is running this filter obviously doesn't want to do business with any of the 70,000 odd people who live in a particular town in the north of England. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filter vulger / controversial words - need word source
Hi, I think we've seen this discussion on the list before (so Christopher, check the archives!) Quite :-) The problems that others have experienced in the past are: - what happens with misspellings, e.g. fsck? - what happens with dodgy formatting, e.g f s c k? - what happens with words like Scunthorpe? Problem 1: add likely/popular mis-spellings to the list of vulger/vulgar language So when I'm giving a Linux user advice on how to recover from a disk crash, my run fsck comment will get trapped the problem here is that context is *everything*. You just can't know, by seeing the word fsck without any of the surrounding text, whether I'm swearing at another geek or helping them out :-) There will also be problems with slang and idiom - e.g. fag in .uk is a cigarette, but it's something quite different on the other side of the pond. Again, this can only be judged from the context. Finally, the more words you have in your list (to cover common misspellings), the more likely you are to get a false positive (again, context) - and you *will* cause offense if you trap someone's name, for example. Problem 2: (contrived) very few single-letter words exist so remove intervening white space prior to analysis Yup, also line breaks, dashes, asterisks, plus signs, etc etc :-) Problem 3: Scunthorpe contains an unfortunate series of letters (amongst the town's many disadvantages) however the critical four are not a word in and of their own right so employ whitespace (\s) in the RegEx or token analysis. That's a good solution, but it's something that obviously is being missed by many developers of this sort of algorithm... see the couple of followups I made immediately after my original response. May I suggest, rather than picking your way through this minefield, you provide a report abusive comment link instead? However some countries are now legislating responsibility that ISPs/employers must discharge Whoops, forgot about that... In this case perhaps one could analyse the incoming text and place an embargo on its publication on the web site until it has been reviewed by a human editor? Looks like the best solution possible. If the OP is interested I will see if I can get our content filter word list from the network manager here... no promises though. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filter vulger / controversial words - need word source
Hi Sean, if you want a partial list of offensive terms - try looking at the meta keywords on a few porn sites ... Excellent idea! Unfortunately I'd have to explain that to my boss... No, really, I'm doing some research... Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Filter vulger / controversial words - need word source
if you want a partial list of offensive terms - try looking at the meta keywords on a few porn sites ... Excellent idea! Unfortunately I'd have to explain that to my boss... No, really, I'm doing some research... but won't your gateway/web server's filter prevent access to such sites anyway? Nope, only the really offensive ones like http://www.thisisscunthorpe.co.uk/index.jsp ;-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How know from wich page you came from
Hi Rodrigo, Hi guys I need a way to know how to know from wich page the visitor came echo $_SERVER[HTTP_REFERER]; HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] run query
Hi Diana, After I run a query lik this, $db-query($sql); what is the quickest way to find out how many records result? Look into mysql_num_rows (or the equivalent if you're not using MySQL) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Pls Help: Moving script from Win to Linux
Hi Shane, I can pass variables till I am blue in the face, even see them in the URL but they are still showing up as (!isset) Are you accessing these variables through $var or $_GET[var]? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Creating a report in PHP
Hi Todd, Is there a report generator that will give me the flexibility to use fonts and fontfaces that works with PHP and MySQL? I don't know of a PHP-based report generator (although a hunt round sourceforge might turn something up), but you can: 1. use PHP scripts to output your reports in HTML, with CSS for styling and layout 2. use a standalone reports package like Crystal Reports which will talk to MySQL directly 3. build an MS Access front-end to your MySQL tables and use its native reporting functions At $WORKPLACE we have a number of reports generated as HTML pages by PHP scripts - these are the ones that get run many times on a daily basis and always look the same - and Crystal installed on the managers' PCs for ad hoc reporting. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How do I run a command as root?
Hi Luke, I'm trying to find out how to run a command on the server as root. Does anybody know how to do this? How about using a combination of exec() and sudo (assuming you're in the sudoers file, that is)? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie Question
Hi Hacook, I have a mySQL database called srchresult in a srchresult base. In it, i have 9 fields. Everything works perfectly. I would like to know how can i list in a HTML table 30 results for example but only with 7 columns (7 fields only) ? Try this: ?php // open the db connection - replace these with your own settings $db = mysql_connect([server], [username], [password]); // select the database - replace with your own mysql_select_db([database], $db); // get the query - add your own field names here $q = mysql_query(SELECT Field1, Field2, Field3 FROM srchresult LIMIT 30); // start the table echo table; // loop through the results while ($r = mysql_fetch_array($q)) { // echo a table row ? tr td?=$r[Field1]?/td td?=$r[Field2]?/td td?=$r[Field3]?/td /tr ?php // end of while() loop } // finish the table echo /table; ? It's untested - shout if it doesn't work. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Who can tell me the best php-base webmail?
Hi Joskey, Who can tell me the best php-base webmail? IMP (http://www.horde.org/imp/) is pretty good, I use it for my webmail and don't have any complaints. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Hello ! How to write a programme in PHP which executes a routine at a given time ?
Hi Jonathan, Do you mind to tell me how to make a PHP programme to execute a centian routine at a given time ? Thank you ! PHP doesn't have anything built in that'll do this for you (at least, nothing that I'm aware of). The best solution is to call your script from your OS's scheduler - cron under unix/linux, or task scheduler in Windows. I usually trigger the script with lynx and pipe it to /dev/null, but if you have PHP compiled as a standalone instead of a server module, you could call it directly. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] character ' in switch
Hi Martin, I would like to know how can I put ' character to case in switch... switch ($action) { case about: code break; case what's new: -- i want this... code break; Try wrapping the cases in quotes: switch ($action) { case about: code break; case what's new: code break; } HTH Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] url - self
Hi Paul, I just need to know how to get the url of the page calling the function so I can delete the information from the appropriate table. Does $PHP_SELF not give you what you're after? Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] New generation of PHP Program, reaction to ASP.NET
Hi, Are you interested in this?! New generation of PHP Program, reaction to ASP.NET I saw it when you posted it yesterday and tried it out, but it didn't work for me. I imagine this is because I've disabled Javascript. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Loooooooooonnnnnnnnnnggggggggg
Hi, I made a script that works on a very long charachter chain and its process is lnggg about 5 minutes ! Do you have any tips to make it faster ? My mysterious ninja PHP developer powers have told me that you need to fiddle with lines 23 and 72, that's where it's slowing down. IOW, it would be helpful if you could post the code for this script. Without seeing it the only thing I can suggest is you minimise the amount of string concatenations, as this is a fairly expensive operation. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] something like array_walk?
Hi, I want to take an array and get the soundex() for each element in that array and return the results into another array. How about: $color = array(blue, green, orange, purple, red, yellow); $soundex = array(); foreach ($color as $foo) { $soundex[] = soundex($foo) } HTH Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm in need of a PHP web host recommendation
Hi Phil, would like to hear some recommendations of some good companies that host PHP/MySQL and also JSP. http://34sp.com/ are great if you don't mind .uk-based hosting. I've heard good things about http://oneandone.co.uk/ but haven't used them myself. At the other end of the scale, you should stay *well* away from http://zenithtech.com/ - they're without a doubt the worst host I've ever used. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: How do i make an upload script?
Hi, How do i make an upload script? http://us.php.net/manual/en/features.file-upload.php ok, this is upload.php: form enctype=multipart/form-data action=upload.php method=post input type=hidden name=MAX_FILE_SIZE value=1000 Send this file: input name=userfile type=file input type=submit value=Send File /form Yup, copied and pasted from the manual page, that should work. what else do i need? 1. A script to receive the uploads 2. A file to upload The manual page you linked to above will be of use in completing stage 1 - there's a bit further down that you need to copy and paste as well. Read the user comments as well, as they will answer questions that will inevitably come up. Stage 2 - well, you're on your own, but there should be something on your hard drive that's suitable. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] airport codes db
Hi Eddie, I am working on a php page where I need some airport codes data, I have seen a few places online where you can buy this data so I was wondering if anyone has used any of these databases and if anyone had a good source for a mysql airport code db. Google is your friend. http://www.google.com/search?q=airport+codes ^ (note similarity of search phrase to subject line of this message) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can somebody help me with making a login Script?
Hi Matt, can somebody please help me make an login script step one by one? My website is Http://tweak2x.cjb.net and I am looking for a login section for memebers. Start by reading this article: http://zend.com/zend/tut/authentication.php And then get back to us with any problems you run into. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] random numbers
Hi Tamas, /* srand is not important since php v=4.2.0 */ $numbers = range (1,90); $x = array_rand ($numbers, 5); foreach ($x as $v) echo {$numbers[$v]} ; It works fine, except the first query: php may restart the random numbers, if it is not used for some seconds. I'm not sure how to solve this, but I'm curious as to why you don't want to use mt_rand: ?php for ($i=1; $i=6; $i++) $x[] = mt_rand(1, 90); foreach ($x as $current) echo $current. br /; ? You still get an array at the end of it, which seems to be what you're after. Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] random numbers
Hi Tamas, ?php for ($i=1; $i=6; $i++) $x[] = mt_rand(1, 90); foreach ($x as $current) echo $current. br /; ? Thanks for help, but your program may generate same numbers between the 5 generated numbers, hovewer I want to generate different numbers such as lottery-numbers. That's not a problem: just add a couple of lines to test for existence: $i = 0; while ($i6) { $pick = mt_rand(1, 90); if (!in_array($pick, $x)) { $x[] = $pick; $i++; } } But if this is the only solution I'll do it in this way. It's *never* the only solution :-) Cheers Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php