[PHP] Re: Feature request for print_r() and var_dump()
"Daevid Vincent" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I suggest a slight but useful change to these two functions, or possibly an > alternate parameter. > > I find myself always having to do this annoyance: > > echo "myDevice"; > print_r($myDevice); > > To get: > > myDevice > Array > ( > [] => Array > ( > [range] => range_3 > [scanner] => scanner_3 > [record] => record_3 > ) > > [] => Array > ( > [range] => range_4 > [scanner] => scanner_4 > [record] => record_4 > ) > ) > > It seems to me the functions should just print out the name of the array > you're looking at, at the very top, just as it prints out the keys. I > already know it's an "Array" or I wouldn't be print_r()'ing it. print_r() can also be used to output the contents of an object. So it's not always an array! To output the type of the variable *does* make sense. Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [HAB] Remove empty cells from an array
"OOzy Pal" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dears, > > How can I remove empty cells/places in an array. For > example: > > a[1]='John'; > a[2]='Mike'; > a[3]='Lisa'; > a[4]=''; > a[5]=''; > > How can I remove a[4] & a[5], so the array is only > > a[1]='John'; > a[2]='Mike'; > a[3]='Lisa'; unset($a[4]); Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Date()
"John Taylor-Johnston" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I might be doing this backwards, but how do I extract the date from $week5 and display $week5 + 4 days. I would like to create a function so when I pass > > echo displaydate($week5); > > it echos "February 14-18" > > $week0 = "2005-01-10"; > $week1 = "2005-01-17"; > $week2 = "2005-01-24"; > $week3 = "2005-01-31"; > $week4 = "2005-02-07"; > $week5 = "2005-02-14"; > $week6 = "2005-02-21"; > $week7 = "2005-02-28"; > > `Doable´? Easy enough to learn how to do? > > John Hi John, // convert your data to a timestamp: $firstDayTs = strtotime($week5); // add 4 days $lastDayTs = $firstDayTs + (4 * 86400); echo date('F', $firstDayTs) . ' ' . date('m', $firstDayTs) . '-' . date('m', $lastDayTs); Not tested. Maybe there's an easier way to do this. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Get name of extending class with static method call
"Morten Rønseth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I just tried the example code at > http://www.zend.com/lists/php-dev/200307/msg00244.html using PHP 5.0.3 > > The backtrace doesn't see class b at all, all references to it have > vanished into thin air. > > I spent days trying to solve this on my own until I happened upon this > thread - it appears that there is no clean way of retrieving the name of > the calling class, in a classmethod defined in the superclass. I do not > want to overload the sperclass' method. > > I do not accept that this is misusing the static concept - without it, > PHP 5 seems rather lame. How does one go about making a feature request? > There has to be a way to get this implemented into PHP 5... > > Cheers, > -Morten Hi guys, I guess it's time to risk asking on php-dev ;) I will try my luck. Let's see what the gurus say! Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Get name of extending class with static method call
> Torsten, I also found the following link to be helpful. Check out the > user notes from michael at digitalgnosis dot removethis dot com (he did > something similar to what I have already suggested, i.e. call_user_func) > > http://www.php.net/manual/en/language.oop5.static.php Hi Jason, thanks for the link. It helped me to find out that this does work: class Car { function drive() { echo '';print_r(debug_backtrace()); } } class Porsche extends Car { function drive() { parent::drive(); } } By "tunnelling" the call through Porsche's own drive() method debug_backtrace() will contain two traces, one of them with the correct class name. I tried using reflection but "reflecting" car by using __CLASS__ doesn't give any information about the classes that extend it. So this doesn't work either. Rory's proposed way of reading in the file contents and preg_matching the method name works, but it's very, very ugly, indeed! ;) Isn't it somewhat ridiculous that there is no *easy* way in PHP5 to achieve what I consider to be a pretty straightforward requirement?: "Get name of the class that invoked a static call of an inherited method" I would like to thank all of those that cared about my problem and tried to find a solution by providing a wide variety of ideas. Thank you very much!!! Do you think it would be wise to ask for help on php-dev? Best regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Get name of extending class with static method call
"Jason Barnett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The only other solution that comes to mind is a little messy but it lets > you get away with no object. Instead of calling the method statically > you can use call_user_func_array() with the child class name as a > parameter. Then change the parent method to accept the child class name > as a parameter. > > > function call_static_child() { >$drive_args = func_get_args(); >/** assume that first parameter is child of class Car */ >return call_user_func_array(array($drive_args[0], 'drive'), $drive_args); > } > > ?> Hi Jason, thanks for taking a look but there *must* be a way to achieve this without passing any parameters around. Otherwise I could just do: Porsche::drive('Porsche'); Best regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get name of extending class with static method call
> I'm not sure if this will work, but hey, you could give it a try. > > class Car > { >public static $className = __CLASS__; > >public static function drive () >{ > return self::$className; >} > } > > class Porsche extends Car > { >public static $className = __CLASS__; > } > > Porche::drive(); // Should return "Porche" Hi Daniel, thanks for the idea but it causes an error: Fatal error: Cannot redeclare property static public Car::$className in class Porsche If I ommit the definition of $className in Car I get this error: Fatal error: Access to undeclared static property: Car::$className If I ommit the definition of $className in Porsche the return value is 'Car' not 'Porsche'. Arrrgh! Will keep on trying. Best regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get name of extending class with static method call
"Christopher Fulton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Not sure if this is the best way to do it or not, but you can do this > and it should (untested code) work. > > class Car { > function drive() { > return $this->getClassName(); > } > function getClassName() { > return "Car"; > } > } > > class Porshe { > function getClassName() { > return "Porshe"; > } > } > > $foo = new Porshe(); > echo $foo->drive(); Of course this might work but it requires the definition of such a method in *every* class I have. Any more ideas? Thanks in advance! Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Get name of extending class with static method call
"Jason Barnett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > M. Sokolewicz wrote: > > try using __CLASS__ > > > > Torsten Roehr wrote: > > > > This is a good suggestion but I wonder... Torsten do you have a large > heirarchy of parent classes or just one parent? E.g. Car -> Sports Car > -> Porsche. More importantly will __CLASS__ resolve to the class name > that you need... > > If __CLASS__ works for you then I would go with it. If not can you just > send the appropriate class name as a parameter? __CLASS__ contains the name of the class the method is in. In my sample it would be 'Car' and not 'Porsche'. What I don't understand is why the behaviour of debug_backtrace() has been changed!?! Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Get name of extending class with static method call
Hi list, in PHP4 it was possible to get the name of the calling class with debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I didn't find a solution in the archives. Is there *any* way to get the name of the calling class?: class Car { function drive() { // I need the name of the calling class here // in this case it should be 'Porsche' } } class Porsche extends Car { } Porsche::drive(); Any help is greatly appreciated! Thanks and best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to read the path of the current document's url
"Tim Burgan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I have a page where the URL is along the lines of > http://www.example.com/test.php > > I've tried using the parse_url() function without success.. I'm trying > to just get "test.php" returned as a string. > > Can someone please point me in the right direction with this. > > Thank you for your time. > > Tim http://de3.php.net/manual/en/function.basename.php Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Propel Persistence Layer
Hi, I'm considering the Propel DB Persistence Layer for an upcoming project. Does anyone have experience (good or bad) with it? Any things to watch out for? Haven't found much in the list archive. Any comments are much appreciated! Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PEAR Spreadsheet_Excel_Writer
"Pedro Irán Méndez Pérez" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > somebody have a example of this class?, because the package don't have, > thank's :) > > = > "¿Acaso se olvidará la mujer de su bebé, y dejará de compadecerse del hijo > de su vientre? Aunque ellas se olviden, yo no me olvidaré de ti" > > Isa 40:27 > = > > Atte Pedro Irán Méndez Pérez Wrong list ;) Anyway, take a look at the documentation: http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.p hp Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: creating multiple sessions
>"John Gostick" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Hi, > >I've encountered a situation where I need to have two or more SEPARATE sessions running in separate windows. The reasons >are complicated, so I'll keep things simple by just explaining the problem! > >Unfortunately my understanding of sessions is a little sketchy at best so please stick with me... > >As I understand it, you can start a new session by manually opening another separate Internet Explorer window, but I wish >the new session to start in a window I've opened automatically from a previous page. Unfortunately this appears to carry >on the session from the source window, which I don't want - I want a new, separate session. > >I've considered calling session_start(); in the new window, then destroying the session and calling session_start(); to >start a new, separate session, but surely this will destroy the session in the original window, which I want to keep >intact! > >So put simply, is there anyway to 'force' a new session? > >Thanks, > >John Hi John, this problem was discussed some days ago on this list. Please search the archives. If those messages don't help come back again. Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php|works in Toronto - anyone going?
"Chris Shiflett" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > --- Aaron Gould <[EMAIL PROTECTED]> wrote: > > Just curious if anyone on the list was headed to Toronto on Sep 22-24 > > for php|works. I live about two hours from Toronto, and my company > > is sending me. > > > > I wonder what kind of reception this conference will get... > > I'm giving a talk on PHP session security, so I'll be there. > > If anyone from the list is coming, please drop by and say hi. > > Chris I'm only in Toronto from 13th to 16th, unfortunately. So all the best and good luck to those that are able to attend! Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: multi dimension array
"Dan McCullough" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I believe that would be the correct term for what I need. > > Here is what I have been trying to do. > > I have orders and customers. Customers are required to do a few things before we can process the > order. Some times they are very slow in doing so. So I wanted to write a little reminder script > to poke us to email/call them. > > So I have orders and customers. I need to go through and list out the orders and then I need to > use the customer to grab all the order associated with them, then list out their contact > information. Anythough on how I can group orders by customer, list the customer information (from > another table) and then go on to the next order and so the same thing all over again? Load all customers and while looping through the result set load all orders associated with the current customer: // open db connection etc. // load all customers $result = mysql_query('SELECT * FROM customers'); while ($row = mysql_fetch_assoc($result)) { // output customer data if required echo $row['customerName']; // load all associated orders $tempResult = mysql_query('SELECT * FROM orders WHERE customerID = ' . $row['customerID']); while ($tempRow = mysql_fetch_assoc($result)) { // output order data if required echo $tempRow['orderID']; } } Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to access one class from another
"Brent Baisley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What is the best way to access one class from another? What I have is a > couple of "core" classes that are loaded into instances at the start of > each page. I then load instances of page specific classes. How would I > access the already loaded instances of the core classes from inside one > of the page specific classes? > > I tried a few things that didn't work. Is the only way to do this is to > load another instance of the core classes? > I'm finally trying to really get my hands around OOP, which has gone > very smooth up until this instance:). I'm using v4 not v5. > > I'm looking for something like this: > class Lists { > function UserList() { > } > ... > } > $coreLists = new Lists(); > ... > class Data { > function Entry() { > $users = $coreLists->UserList(); file://Accessing Lists Class > ... > } > } Hi Brent, this is a case of variable scope: http://de2.php.net/variables.scope There are different ways to solve your problem: 1. Declare $coreLists global in your method: function Entry() { global $coreLists; $users = $coreLists->UserList(); } 2. Access it via the superglobal $GLOBALS: function Entry() { $users = $GLOBALS['coreLists']->UserList(); } 3. Pass the variable it to the class constructor and assign it to a class property: var $coreLists; function Data($coreLists) { $this->coreLists = $coreLists; } Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to redirect ?
>"Cbharadwaj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Hi > >I have used >Header (Location:PATH) function for redirection. >it is giving some errors. >is there any other method other than HEADER() funtion for redirecting ? > > >Bharadwaj It will work if you specify a *full* URI: header('location: http://www.yoursite.com/page.php'); exit; Pay attention to the exit. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: help-fetching-url-contents
"Vijayaraj Nagarajan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi all > i would like to fetch the content of a url. > and then would like to put in my page... dynamically > refreshing it once in a day... > > is it possible to do this in php. > i have used perl get url option and then parse the > file, with the date and time function...to do this. > > pls help. > thanks in advance > vijay http://de3.php.net/curl Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: referencing a class
"Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Quick question here. Has anyone run into trouble with a variable reference > to a class object? > > Here is the code: > $_SESSION['database'] = new Database; > $this->db = &$_SESSION['database']; > > Everything goes screwy after a call like this. > > Thanks in advance! What do you mean with "screwy"? Change $_SESSION['database'] after your second line and print out $this->db to see if that was changed too. By the way, you mean "referencing an object" (not a class). Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: referencing a class
"Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Quick question here. Has anyone run into trouble with a variable reference > to a class object? > > Here is the code: > $_SESSION['database'] = new Database; > $this->db = &$_SESSION['database']; > > Everything goes screwy after a call like this. > > Thanks in advance! What do you mean with "screwy"? Change $_SESSION['database'] after your second line and print out $this->db to see if that was changed too. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Is ob_gzhandler interfering with dynamic zipping???
"Thomas Hochstetter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi there, > > Still sitting on this problem of not being able to dynamically zip a bunch > of files together, to output them as a Save Dialog box for downloading. I am > using the rather old pclzip classes for the zipping part (still wrestle with > the server admin to get Archive_xxx stuff from PEAR installed - hate Debian > servers!). Hi Thomas, why not using your own PEAR version of Archive_xxx? Install it locally (or download/unpack the archive), upload it into a custom PEAR dir and set the include path to it (maybe just in the script where you need it). Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Session again !!!
"Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I added print_r($_SESSION); after the session start(); > and the printed text was > > Array( ) Which means that your session value is NOT set. Your if/else should look like this: if (!isset($_SESSION['uname'])) { header('Location: ../../index.php'); exit(); } else { // output contents } Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session again !!!
"Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I really did > and it behaves the same > > I tried isset() also but there is no good it still does not work !!! > > > "Afan Pasalic" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Try use > > > > if(empty($_SESSION['uname']) > > > > instead > > > > if($_SESSION['uname'] = = "") > > > > > > Afan You should try a bit more debugging than just posting your code here. Try this at the top of your second page: print_r($_SESSION); Then you will see which values are set in $_SESSION and you can check if that is what you are expecting or not. Another idea would be using a ready made authentication/permission package like PEAR::LiveUser: http://pear.php.net/package/LiveUser Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: interface problem in PHP5
"Erik franzén" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If you want to delete an object, when you have other references to it, > you must use the & operator, otherwise the object will not be killed for > all references. > > I tested without the &-operator, but that did not work > > The &-operator is still important in PHP5. Look at the folling example > > $a = new stdclass; > $b = $a; > $c =& $a; > ?> > > unsetting a will only kill a, b and c will still be "alive". > setting a to null will kill c but not b > > /Erik OK, but what about your interface problem? Could you solve it with this?: >>> I think you have to also define the arguments you want to use for item() in your interface: function item($a_iIndex); <<< Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: interface problem in PHP5
"Erik franzén" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Can anuyone describe this error? > > Compile Error: E:\Source\CMAES\src\include\dom.inc.php line 67 - > Declaration of CMAES_DOM_Node_List::item() must be compatible with that > of CMAES_DOM_Node_List_Interface::item() > > > // {{{ interface CMAES_DOM_Node_List > /** > * > * @access public > */ > interface CMAES_DOM_Node_List_Interface > { > function item(); I think you have to also define the arguments you want to use for item() in your interface: function item($a_iIndex); > function search(); > function addItem(); > function removeItem(); > } > // }}} > /** > * CMAES_DOM_Node > * > */ > class CMAES_DOM_Node_List implements CMAES_DOM_Node_List_Interface > { > // {{{ properties > /** > * Number of elements in node list > * @var integer > */ > public $iLength = 0; > > /** > * Nodes in list > * @var array > */ > private $_aNodes = array(); > // }}} > > // {{{ item > /** > * Returns the nth index given in item. > * > * @param inte $a_iIndex - index in list > * @return mixed node object or null if item was not found > * @access public > */ > function &item($a_iIndex) Are you sure you need '&' here? Shouldn't PHP5 pass all variables by reference on default? Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: function problem
"Matthias Bauw" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm having a problem with a php application; > > I have two files: one is ccadduser wich adds users to a controlcenter > that I am currently designing for a website. > > In that ccaduserfile I call for a function checkpermission(); this > function is defined in another file called ccfunctions > > When a user does not have access to the script it should abort the > script, this is done using a header("location: ccnopermission.php"); > statement > > But now it seems that while executing the function checkpermission() > the code in ccadduser just keeps running and the database query that > inserts the new user is executed before the user can be redirected to > ccnopermission. > > Is there a way to make php wait until checkpermission is completely executed? > > I know it is not a simple question, but I really need a solution to > ensure the safety of my system. > > grtz & thanks > > DragonEye I'm not completely sure if I understand your question but PHP will process one function after the other. Without seeing some code I'm afraid we can't help you much. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Drop directory with PHP
"Kioto" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all I have create this function to delete directory and file but i > have no result . > When i call the function i don't receive any errors by PHP. > I have test this function with PHP 4.3.6 and Apache for NT version 1.3.1 > on Windows Xp Professional > I write this code : > > error_reporting(E_ALL); > > function DropDir($dir) { > > if (is_dir($dir)) { >if (!($handle = opendir($dir))) > die("It' no possible open directory $dir"); > > while(false !== ($file = readdir($handle))) { > if ($file != '.' && $file != '..') { > if (is_dir($dir . '/' . $file)) { >DropDir($dir . '/' . $file); >exec("rmdir $file"); > } > else { >exec("del $file"); > } > } > } > closedir($handle); > exec("rmdir $dir"); > } > } > file://call function DropDir > DropDir('my_folder'); > ?> > I think that it' impossible for me find solution to this problem. > Can you help me ? > Thanks so much to all an sorry for my bad language I guess you'll first have to delete all files in the directory. Try this function: /** * Recursively clear a local directory * * @param string $sourceDirdirectory to delete * @param integer $leveldirectory level (to avoid deleting the root dir) */ function clearDirectory($sourceDir, $level = 0) { // proceed if source directory exists if (is_dir($sourceDir)) { // read dir contents if ($handle = opendir($sourceDir)) { /* This is the correct way to loop over the directory. */ while(false !== ($dirItem = readdir($handle))) { if ($dirItem != '.' && $dirItem != '..') { // directory if (is_dir($sourceDir . '/' . $dirItem)) { clearDirectory($sourceDir . '/' . $dirItem, $level + 1); } // file elseif (file_exists($sourceDir . '/' . $dirItem)) { unlink($sourceDir . '/' . $dirItem); } } } // remove directory if it's not the root one if ($level > 0) { rmdir($sourceDir); } } closedir($handle); } } It will delete all direcotries and files *inside* the specified directory. So the directory itself will not be deleted. Just call it like this (without trailing slash!!!): clearDirectory('/path/to/directory'); // or on windows clearDirectory('c:\path\to\directory'); Hope it works for you. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: !!Urgent .. Session Problem
"Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > session_register('uname'); > $_SESSION['uname'] = $username; Hi Dre, Nick already answered your question so just a short note: you should not use session_register() with your PHP version anymore, so just delete the first of the upper two lines. Excerpt from the manual: >>> Caution If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister(). <<< Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sessions and Logins
Hi Dennis, see below "Dennis Gearon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Please CC me > - > > I am designing my own 'usr' class that takes care of logins. I need > to know the following to finish it. > --- > A/ Does anybody use sessions for users who are not logged into the site, and why? This might make sense when you have a protected area on your web site. Having the session run all the time would allow the user to naviagte the whole site *after* login without losing his authentication. When he is logged in, just store some kind of value or object in the session. On the protected pages check for this value. If it's not in the session redirect to a login page. > > B/ If a user goes from unlogged in, unidentified user to a logged in, identified user, is the first session canceled and new session started? You can control this yourself - usually you don't have to start a new session after login. But applying session_regenerate_id() adds a bit of security because it changes the session id (which might have been public before login). See: http://de3.php.net/manual/en/function.session-regenerate-id.php > > C/ (The reverse), if a user goes from logged in, identified user to a unlogged in, unidentified user, is the first session canceled and new session started? Use session_destroy() and redirect to the start/login page with a clean: header('location: http://www.yoursite.com'); exit; This will start a new session. You might also need to unset a cookie before session_destroy() if you are using cookies. > > D/ How is it possible, using PHP4+ sessions, to cancel a session a page is opened with, and starting a new session? Again, use a header redirect. > thanks all of you. I **LOVE** using this PHP 'thang' :-) > > Dennis Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function Get Error
>"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >I write this function to delete directory and file but when i 've a directory not empty i get error >The code that i write is this: > >I receive this warning: >Warning: rmdir(cartella): Directory not empty in c:\programmi\apache group\apache\users\test\project\delete.php on line 23 >I have set chmod on linux chmod to 777 but i can delete folder only when is empty. >What I do ? >Thanks to all and sorry for my bad language. I guess you'll first have to delete all files in the directory. Try this function: /** * Recursively clear a local directory * * @param string $sourceDirdirectory to delete * @param integer $leveldirectory level (to avoid deleting the root dir) */ function clearDirectory($sourceDir, $level = 0) { // proceed if source directory exists if (is_dir($sourceDir)) { // read dir contents if ($handle = opendir($sourceDir)) { /* This is the correct way to loop over the directory. */ while(false !== ($dirItem = readdir($handle))) { if ($dirItem != '.' && $dirItem != '..') { // directory if (is_dir($sourceDir . '/' . $dirItem)) { clearDirectory($sourceDir . '/' . $dirItem, $level + 1); } // file elseif (file_exists($sourceDir . '/' . $dirItem)) { unlink($sourceDir . '/' . $dirItem); } } } // remove directory if it's not the root one if ($level > 0) { rmdir($sourceDir); } } closedir($handle); } } It will delete all direcotries and files *inside* the specified directory. So the directory itself will not be deleted. Just call it like this (without trailing shlash!!!): clearDirectory('/path/to/directory'); Hope it works for you. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Help
"Conbud" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hey, Im making a site to where I can fill out a form and it adds updates to > the main page, but I only want the site to display 5 updates on it, now I > know how to make it only show 5 updates, but then that means when a new > update is posted to the site, it just stores the old updates in the database > and over time this can make the database quite large, How would I make it > delete the oldest update and just add the newest update to the top of the > list ? So this way I only have 5 updates stored in the database at all > times. > > Thanks > ConbuD Insert your new item, then delete the oldest one: DELETE FROM table ORDER BY date asc LIMIT 1 Whereas 'date' is your date column. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Large database, slow search times
"Adrian Teasdale" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi there > > I have been given the task of integrating a search into a database we > have which contains 40 million records and I would really do with some > advice! Thanks to everyone the other day who helped us parse this same > database into mysql. > > Basically the database consists of only 1 field that stores a set of > character strings. I need to be able to do a wildcard search that will > find any matches, so if I'm looking for any matches containing "ABC" > then it should pull up the record "123ABCDEFG". Now, I know that under > normal circumstances this wouldn't be too bad, but under this database > I'm getting search times of 3.5 minutes just to run one search. > Considering that there might be 500 users interested in doing searches > on this info, 500 x 3.5 minutes per search is too much. Just wondering > what the experts would suggest for managing a database this size and > getting the search times down to something manageable. > > Thanks in advance for your advice > > Ade Have you put an index on the column? Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Session understanding
"Michael Gale" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > Morning .. at least it is where I am :) > > I have a small issue with sessions, at the moment I am using sessions on our web site and storing the session > information in a db_table. It is working great. Right now I am only storing the users ID, name and role in the session > data, but I would like to store other information as well. The problem is ... that if that person opens another browser > window and connects to the site another session is not created. > > So if I try and store a variable that would be unique to each window it would get over written. Is this a configuration > problem ? > > > Thanks. An alternative might be omitting cookies and passing the session id around via GET/POST. This would solve your problem but might require some work to adapt your application. Another advantage of this would be that you would not have to rely on your user's cookie setting being enabled. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: trying to do too much with functions?
"Justin French" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have a few functions with way too many parameters in them, or > functions which have a non-obvious order of parameters which I > constantly have to refer to as I'm working. Since I'm using PHP as my > templating language (none smarty here!) as well as the programming > language. So I've been looking for some alternatives... > > My main objectives: > >1. have all parameters optional >2. have a mixed order for the paramaters > > Other languages seem to do this well (Ruby, or perhaps RubyOnRails > seems good at it), but in PHP I can only see a few options... I'm > hoping someone might offer a few more ideas. > > '123','b'=>'456'); echo doStuff($params); ?> > '123','b'=>'456'))?> > > > > > So, is that it? Have I thought of all possible options? As you should have a fixed parameter order in your function you don't need to pass the variable names in. So this is OK for up to three or four params: doStuff('value1', 'value2', 'value3', 'value4'); If your function takes more than four parameters an associative array would be the way to go (your first example). You might consider splitting it up into several functions if it takes that many arguments. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Handling XML output in a slim way
"Markus Fischer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > up until now, when outputing XML I've been constructing the output as a continous string-soup in such ways like > > [...] > $xml .= printf('%s', makeXmlSave($name), makexmlSave($contentOfItem)); > [...] > > makeXmlSave() makes sure that quotes, ampersand, < and > are properly escaped with their entity reference. However I was thinking if it wasn't possible to e.g. generated a a complete DOM tree first and then just having this tree being dumped as XML. > > I'm using PHP4 right now. > > thanks, > - Markus > Hi Markus, take a look at this package: http://pear.php.net/package/XML_Tree Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $_SERVER['HTTP_HOST'] without the 'www.'
"Shaun" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > How can I get the URL of the page I am on without the 'www.' i.e. just > mydomain.com? I need to enurse this is correct in case the user types in the > domain without using the 'www.'. > > I have looked at using substr but if the user leaves out the 'www.' then > substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a better > function to use in this instance? > > Thanks for your help Does your Apache provide $_SERVER['SERVER_NAME']? For me it outputs the domain like "google.com". Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing image in database
"Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > line 8 is > just that .. and the code before it is the following > > file://== > > > Untitled Document > > > > Why not putting your PHP code at the top of the page? The blank line between and might cause the error. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP- Dependant dropdown based on Mysql queries
wrote in message news:[EMAIL PROTECTED] > Hi All, > I'm trying to generate a PHP page with 3 or 4 dropdown menus, each of one dependant upon each other, that means: > #2 dropdown should change upon selecting something on dropdown #1, #3 should change based on the selection at #2 to finally submit the desired query. Each dropdown menu should be generated from a mysql query based on the previous selection. > I need to generate mysql queries based on each dropdown selection and the page should reload the content for the next dropdown menu. I couldn't yet figure out how to accomplish this. > Let me know if I make myself clear enough :) > Any help is very welcome!! > > Thanks in advance, > > Francisco Hi Francisco, just point the form action to $_SERVER['PHP_SELF']. Then check the POST value of the relevant dropdown and do your queries. For example: // the value of your selects will probably be ids that's why you should cast them to integers if (isset($_POST['select1'])) { $select1 = (int) $_POST['select1']; // do your query for select2 } if (isset($_POST['select2'])) { $select2 = (int) $_POST['select2']; // do your query for select3 } if (isset($_POST['select3'])) { $select3 = (int) $_POST['select3']; // do your query for select3 } if (isset($_POST['select4'])) { $select4 = (int) $_POST['select4']; // insert your data } I hope you get my point. For user convenience you could use JavaScript's onChange() event to auto-submit the first three selects when the user has selected a value. Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: newbie questions
"Kevin Bridges" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings php-general, > > I'm just starting out with php ... judging from the posts I've been > reading on this list I'm thinking this question is so basic it might > almost be pathetic! I'm assuming the answers are in the php manual, > but I have not found the correct pages ... any pointers to manual > pages, tutorials, or an explanation would be greatly appreciated. > > require_once 'library/functions/dbConnect.php'; > class Content { > var $db = null; // PEAR::DB pointer > function Content(&$db) { > $this->db = $db; > } > } > ?> > > I'm writing my first class following an example I found on the web > and I have 2 questions. The constructor for Content accepts an > object ... why is &$db used instead of $db? > > I'm used to a this.varName syntax from other languages ... I grasp > what is happening with $this->db, but I don't understand the literal > translation of -> and would like help understanding. Hi Kevin, with PHP4 &$db means the value is passed by reference. Otherwise a copy of $db would be passed to the method. See here: http://de2.php.net/references With PHP5 variable assignments or passing variables to functions by reference is standard. $this->db is the PHP equal to this.varName. You access property db of the current object. Methods are called this way: $this->methodName() Hope this clears things up a bit. Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: List of cities
"Harlequin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Morning... > > Does anyone know of a site that or resource available where I could pull a > list of ALL UK cities and towns for an option list...? > > I started out with 100+, then expanded this list to over 200 but still get > complaints that certain towns are not listed. Ask the UK postal service (or whatever it is called). They should have such a list/directory containing all cities with zip codes in digital form (probably on CD-ROM). Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: paste values for one pop-up. And this pop-up is one frame
"Andre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Yes and don't work. > > The code of the frameset > > > Untitled Document > > > > > > > > > > > You have to pass the variable from the frameset to the page that will be using the variable. Change the first line into: Then in imprimir_factura.php you can acces the variable via $_GET['factura_id']. This should work. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: paste values for one pop-up. And this pop-up is one frame
"Andre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > But don't work that's is my problem, > And I think this don't work because the pop-up window is a frame > Help?? Have you seen my other post from two minutes ago? You mean your popup contains a frameset? Then post your frameset code and we might be able to help. Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: paste values for one pop-up. And this pop-up is one frame
"Andre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > Hello > > Someone now how to paste values for one pop-up. And this pop-up is one frame > I am doing like this to open pop-up > > echo" onclick=\"NewWindow('fact_imprime.php?factura_id=$factura_id','Ficha','700', > '300','no','left');return false\" onfocus=\"this.blur()\"> > height=\"31\" border =\"0\">"; > > And in the pop-up I do like this. > echo"$_REQUEST[factura_id]"; > > Thanks for the help... Remove the double quotes and put quotes around the array key: echo $_REQUEST['factura_id']; Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: paste values for one pop-up. And this pop-up is one frame
"Andre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > Hello > > Someone now how to paste values for one pop-up. And this pop-up is one frame > I am doing like this to open pop-up > > echo" onclick=\"NewWindow('fact_imprime.php?factura_id=$factura_id','Ficha','700', > '300','no','left');return false\" onfocus=\"this.blur()\"> > height=\"31\" border =\"0\">"; > > And in the pop-up I do like this. > echo"$_REQUEST[factura_id]"; > > Thanks for the help... What you described should work, so *where* is your problem? Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sharing records with assigned users
"Php Junkie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ave, > > I'm working on a Phonebook Application for my company. Much of it's > functions and application are pretty much clear and workable for me. But > there's one aspect which I'm trying to figure out. > > It's a multi-user application where there's 2 kinds of users... Admin & > User. > > The User can only view, add, edit, browse through his own records. > Each user does get a public & private option, wherein the user can make the > record either private, so only he can see it, or public which anybody can > view. > > The Admin can do absolutely anything. > > There is one feature that Admin gets which I'm trying to figure out. > When the Admin is adding a record, he gets to decide which users he wants to > share the record with. He can choose particular Users by clicking on their > name to share that record with. How do I make that happen? > > Any suggestions? > > Thanks. I guess you need to create a table that maps users to records with two columns $userID and $recordID. Then you look up in that table if the user is allowed to edit/see this record. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XML_sql2xml
"Brian Anderson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I am trying to install XML_sql2xml > > I followed the directions to install XML_sql2xml at: > > http://php.chregu.tv/sql2xml > > I used pear and typed: > > "pear install XML_sql2xml" > > The result I got was: > > " No release with state eqal to: 'stable' found for 'XML_sql2xml' " > > Is there someplace that the php class file can be downloaded from and > manually installed? Anybody know? > > -Brian Hi Brian, I found this link on the page you mentioned: http://pear.php.net/package-info.php?pacid=18 Click on "download", download the archive and extract it to your PEAR directory. Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Exporting Dbase to CSV
"Harlequin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using MySQL Jay > > I can present the results in a table easy enough and if I replace the TD > TAGs with commas etc. I get a screen output that resembles a CSV file but > need to go that one step further and don't know how... Please specify what you mean with "one step further"? You can assign the contents to a variable and write it to a file. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: crypt()
"Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have developed a PHP based site that requires users to login. Their login > information is kept in a MYSQL database. Currently, I am using an IF > statement to verify what the user enters as their password with what is in > the the database. If they are the same a session is created and they have > access to the content of the site. > > As far as I know the password is being sent to the script in clear text and > I was wondering what a good way would be to get this to be encrypted. My > first thought is to encrypt the password in the database using crypt(). So > if I view the table I will see the encrypted characters. Then change the IF > statement to encrypt the password that the user enters and then just check > if its the same as what is in the database. That sounds like the same as I > am doing now only instead of checking a password that is a name, its > checking the encrypted characters of the name. > > So it seems my idea would hide the real characters. > > Can anyone tell me if this is a bad idea. And maybe point me toward a good > one. > > Thanks, > > Aaron Hi Aaron, encrypting passwords in the database is generally a good idea. You can use md5() as an alternative to crypt(). MySQL itself has an MD5 function you can directly use in your SQL statements. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] crypt()
"Afan Pasalic" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi everyone! > > My hosting company has global turned on. But I want to code using more safe > global off. My question though is how I can do it "locally", in my script? > I tried to use > ini_set("register_globals", FALSE); > but it still doesn't work. > On php.net manual I can find WHAT I have to do and reasons but not HOW. > > Thanks for any help! > > Afan Please don't hijack other people's thread: Try this at the top of *every* script: ini_set('register_globals', 0); Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is javascript enable?
"Marcos Thiago M. Fabis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > i share your opinion, but belive-me when i say that this situation requires > it. > > i have to check if it´s inside frames, pass values for only one a respective > frame that is responsable for logging, start procedures with setTimeOut, > etc... > > maybe next time the project can be better planned, but i can´t see how at > this time! > > [s] > Mt Hi, one way could be to setup an empty "intro" page that has two ways of redirecting: 1. Redirect via meta-refresh tag after 2 seconds to page2.php?js=off 2. Redirect via JavaScript immediately to page2.php?js=on If JS is enabled the second redirect will be processed, if it's off the first one will. Then on page2 you'll have $_GET['js'] with on/off as the value. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP Login Script
"Chuck" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Could anyone let me know or point me to where I could find out how to setup > a login for my php site. I've been looking around and found plenty of stuff > for PHP/Apache, but nothing for just PHP. > > Any help or info about this would be appreciated. > > Thanks, > Chuck Hi Chuck, you could try those two PEAR packages: http://pear.php.net/package/Auth http://pear.php.net/package/LiveUser If you have any questions about those packages that the docs and the source code can't answer there is the PEAR general mailing list to help ;) Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Destroying a Session
"Shaun" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >> function clear_orderinfo() { > > >> global $_SESSION; > > >> unset($_SESSION["orderinfo"]); > > >> } > > >> > > >> However this function doesnt seem to work and the session remains > > >> active, is > > >> there another way to clear a session? > > > > I'm not triffically experienced, but I do have notes on the subject. > > You're wanting to clear the whole session, right? > > > > $_SESSION=array(); > > session_destroy(); > > > > For specific variables, try assigning FALSE to it > > ($_SESSION['name']=FALSE; or 'unset' works for versions >=4.2.2. Otherwise > > use session_unregister. For me under 4.1.2 I had to set to null. > > > > HTH > > J > > > > > > Hi, > > Thank you for your replies. I am using version 4.3.3 yet unset() doesn't > seem to work. To test this I have placed this line of code in my footer.php > file that appears at the bottom of every page: > > echo 'load_orderinfo() = '.load_orderinfo(); > > Here is the load_orderinfo() function: > > function load_orderinfo() { > global $_SESSION; > if (empty($_SESSION["orderinfo"])) { >return false; > } else { >return $_SESSION["orderinfo"]; > } > } > > Before the $_SESSION["orderinfo"] is created the output in the footer reads: > > load_orderinfo() = > > When it has been created it reads: > > load_orderinfo() = Object; > > On the complete_order.php page where I call the clear_orderinfo() function > it goes back to: > > load_orderinfo() = > > but it on any subsequent page the output returns to: > > load_orderinfo() = Object; > > But after calling the clear_orderinfo() function surely the > $_SESSION["orderinfo"] should have been destroyed. I hope this makes sense! > > Thanks for your help Hi, remove the global $_SESSION; lines in your functions - they are uneccessary. Have you tried resetting $_SESSION instead of unset()?: $_SESSION = array(); Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image Width Error
"Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all! > > I am trying to do something really simple, but my error is outside of my > expertise (hopefully not for long!). > > Code: > - > $this->lVertical = "images/box/".$template."_lVertical.gif"; > $borderWidth = imagesx($this->lVertical); > - > Error: > - > Fatal error: Call to undefined function imagesx() in > c:\web\www\php\classes\Box.class on line 65 > --- > > Am I missing something in the PHP config? What should I be looking for. Oh! > I am on PHP5.0 - that should help. > > Thanks in advance! Read the manual: http://de.php.net/manual/en/function.imagesx.php You need an image resource to get the file size. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: delimiter question?
"Steve Buehler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can I make the following work on an apache 2.0.46/php 4.3.2 installation? > > /dist/gogo.php/order-inventory-form.php > > Right now, unless it is a question mark after the gogo.php script, it will > not run. > > Thank You > Steve Hi Steve, try setting the file permissions of gogo.php to 705. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I open Save As Dialog Box?
"Php Junkie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ave, > > I'm facing a little problem. > I have created a File Manager Application for my company which has a place > where authorized users can download the stored files. The files are of > various MIME Types.. Mainly PDF, TXT & DOC. > What I want to do is basically... When the user clicks on the Download > Button... The Save As Dialog Box should appear... > What is happening right now is that the file opens in it's related software > (Word, Acrobat, Notepad etcetera). I don't want the file to open in it's > native software. > > I know I need to use the > header ("Content-type: application/octet-stream"); > But I don't know how. > > Can anyone help? > > Thanks. Take a look at PEAR's HTTP_Download: http://pear.php.net/package/HTTP_Download This package is exactly what you are looking for. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Clear HTTP POST value
"Nicklas Bondesson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi! > > Is there a smooth way to clear a posted value on a page? I have tried the > following without sucess. > > unset($_POST["var"]); > unset($HTTP_POST_VARS["var"]); > > Nicke Hi Nicke, unset($_POST['var']) *should* work - it works for me (PHP 4.3.8). You could also do $_POST = array() to reset all values. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Is this the right way to increase the amount of time session variables are dropped
"Boot" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Currently session variables are dropped in a shorter time period than I > would like when a user sits with a page open but idle. > > My PHP.INI has session_gc_maxlifetime set to 1440. > > If I want variables kept for two hours, is setting session_gc_maxlifetime > the correct setting to change (to 7200) ? > > > Thanks! If you cannot edit your php.ini put this line at the top of all your scripts: ini_set('session.gc_maxlifetime', 7200); You can also set this environment variable with a .htaccess file. Search the archives to find out how the exact syntax is. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: WAHT is my error???
"Andre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Inside of one ARRAY can I make one WHILE > > function tabelas($tabela_tipo){ > $sql = mysql_query("SELECT * FROM ".$tabela_tipo."_credito ORDER BY > ".$tabela_tipo."_ordenar"); > $return = "\n"; > $tabela_array = array("". >while($registo = mysql_fetch_array($sql)){ >array ("".$registo[0]."", > "".$registo[0]." ".$registo[0].""); > }."" >foreach($tabela_array as $subarray) >list($num, $text) = $subarray; >$return .= " selected>$text\n"; >} >$return .= "\n"; >return $return; > } > > I guess your loop should look like this: while ($registo = mysql_fetch_array($sql)) { echo '' . $registo[1] . ''; } You can use mysql_fetch_assoc() and then access the values by their column name: $registo['column1'], $registo['column2'] etc. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] arrays() current() next() who to use
"Vern" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Problem with that is it sorts according the results of the recordset range. > > For instance: > > It will show the user 1 trhough 10 sorted by miles then 20 - 30 sorted by > miles, however, in 1 through 10 could have a range of 0 to 1000 miles and > the next set will have 5 to 200 miles. What I need is to sort them all by > miles first. The only way I know to do that is to do the way I set it up. So > if I create an array, sort that array by the miles then use that array. > However the array is different that the recordset and thus does not use > LIMIT. What about this: SELECT * FROM table ORDER BY miles LIMIT 0, 10 Then pass the offset to your query function and exchange it with 0: SELECT * FROM table ORDER BY miles LIMIT $offset, 10 Of course you have to properly validate that $offset is an integer before using it in the query. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: download file question...
"Bruce" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi... > > i can allow files to be uploaded to my app. are there corresponding > scripts/code to allow files to be downloaded to the user via the browser?? > > just occurred to me that i'll want to do this... > > nothing jumps out at me searching google/php.net for this... > > thanks What about pointing a link to the file?!?: link If the file is outside of the webroot root or in a protected directory you can use PEAR's HTTP_Download: http://pear.php.net/package/HTTP_Download Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OO Theory Question
"Ricardo Cezar" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Probably its a dumb question, but Im new to OO Programming, so... > > How can I store the instance of the class in the session > > Thanks, > Rics That's no different to storing any other variable into the session: $_SESSION['object'] =& $object; (You don't need the ampersand in PHP5.) Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I need unique max number
"Ni Shurong" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi all > > > > I have data in one field in a database, all is numbers that can be > > duplicated. > > > > 200, 200, 100, 50, 30. > > > > i need to get all data from this field, terminate the duplicates and get the > > max nuber that is not a duplicate, in the numbers above that would be 100. > > > > I had a look at array_unique, but i'm not sure if this is the right function > > for this. > > > > Thanks in advance. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > use array_unique will get 200, 100, 50, 30. > > you shoule write a custom function :) Hi Ni, he needs to ignore duplicate values so array_unique() won't help. Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: I need unique max number
"Pieter From Sa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all > > I have data in one field in a database, all is numbers that can be > duplicated. > > 200, 200, 100, 50, 30. > > i need to get all data from this field, terminate the duplicates and get the > max nuber that is not a duplicate, in the numbers above that would be 100. > > I had a look at array_unique, but i'm not sure if this is the right function > for this. > > Thanks in advance. Hi, setup your array starting with the highest values: $array = array(200, 200, 100, 50, 30); Then use array_count_values($array). This will give you an associative array where the key is the former value and the value is the number of the occurrences. In your case this would be: array(200 => 2, 100 => 1, 50 => 1, 30 => 1); Then loop through the array with foreach() and check each element for the value 1. When you have found the first array element with a value of 1 exit from the loop with break. Hope this works for you. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php question
"Michael Crane" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hello, > I have a webpage which includes a frame containing a table made of 24 > tds which in turn contain little images. When the mouse clicks on a > little image the appropriate larger image is loaded into an adjacent frame. > Can somebody point me in the direction to do this in php without frames > please ? > > I've been looking most of the day but I can't see it. > > regards > > mick Hi Mick, you have to append the file name of the bigger version to your links as a parameter: big picture 1 big picture 2 big picture 3 Exchange name_of_the_big_file1/2/3 with the file names of the big image versions. Then at the point where you want to show the big image include this code: '; } ?> Of course you may have to alter the src attribute if your pictures are not in the same directory. Hope this helps, regards. Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] The_'_character_and_Hidden_(POST)_form_fields...
"Sean O'Donnell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > the ’ character... > > *damn outlook rewrote it in my email. =/ > > SEAN O'DONNELL > PROGRAMMER/ANALYST Hi Sean, generally apply htmlentities() to all data to output. Use double quotes for your HTML attributes so single quotes in your strings won't be a problem. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PEAR
"Mag" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > some newbie questions about PEAR: > > 1. How do I know if its already installed? (via > phpinfo() ? ) > > 2. Can I install it myself if its not already > installed or do I have to contact my host? > > Thanks, > Mag You will find answers to your questions on http://pear.php.net. Or post your questions to the pear-general list. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with sessions!!AAH
"Angelo Zanetti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi Matt, > > The session_id() is correct on both pages. Some info I forgot to add is > this: > > on my first page: > > session_write_close(); > header("Location: franchise_menu.php?".SID); > exit(); > > however on my franchise_menu.php page, no SID is displayed in the > browser address. could that be a reason? Or have i misconfigured > something? Hi Angelo, your code looks right but you should see the session id in the address bar after the redirect. Does echo SID produce any output? By the way, I don't think you need to call session_write_close(). Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problems with sessions!!AAH
"Angelo Zanetti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > ok I thought the problem was fixed but its not. The session variable > gets registered correctly however when I go to the next page and too see > if its still registered using the isset() function its not registered > anymore. I do have session_start(); at the top of the new page. > > I cant think why its not working?!?! Are you using cookies? What are your session configuration values? Regards, Torsten > > TIA > > >>> "Jay Blanchard" <[EMAIL PROTECTED]> 8/16/2004 > 4:46:16 PM >>> > [snip] > Ok here is what I do: > > $_SESSION['login']="true"; > > if (session_is_registered($_SESSION['login'])) > echo("seesion is reg"); > else > echo("seesion not reg"); > > I have not used the session_register function as the manual says the > following: > [/snip] > > Have you set session_start? http://www.php.net/session_start > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > Disclaimer > This e-mail transmission contains confidential information, > which is the property of the sender. > The information in this e-mail or attachments thereto is > intended for the attention and use only of the addressee. > Should you have received this e-mail in error, please delete > and destroy it and any attachments thereto immediately. > Under no circumstances will the Cape Technikon or the sender > of this e-mail be liable to any party for any direct, indirect, > special or other consequential damages for any use of this e-mail. > For the detailed e-mail disclaimer please refer to > http://www.ctech.ac.za/polic or call +27 (0)21 460 3911 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Cache
"Octavian Rasnita" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > I want to create an html cache of a page, like when that page is saved to > the disk and let the visitors download that static page and not a dynamic > one. > Of course, a dynamic PHP program will load that static page and display it, > but without need to connect to databases, to make calculations, etc. > > The problem is that I don't know how to automaticly decide when it is the > right moment to update the cache and this is very important. > I get some data from a database and the PHP program doesn't know when the > database gets updated by another program, so it cannot create the cache for > that page immediately. > If I let the program check the database each time it is ran, this takes some > times, and it is like I would not use the cache at all. > > Is it possible to use that kind of cache I want? (meaning... a kind of > static page saved). > > Thank you. > > Teddy Hi Teddy, take a look at PEAR's Cache_Lite: http://pear.php.net/package/Cache_Lite With this package you define a "lifetime" for each page. When this time has passed a new cached file will automatically be created. Cache_Lite is managing this for you. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: [PHP-DB] Re: Basic MySQL Query Question
> [reply] > Please try if those changes solve your problem. Whenever one of > your values > will contain a single quote you will get an SQL error - so use > addslashes() > or (better) mysql_real_escape_string() on all insert values. > [/reply] > > > That is my whole point though, is that it does not happen every > time. I get > no error when the user registers (inserting "O'Neal" into the table), but > when I insert the same name into the tickets table, it fails. Chad, please always answer to the list. Echo out your queries and compare them, there must be a difference. Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: problems with sessions!!AAH
"Angelo Zanetti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > Im running a win2k with apache and PHP 4.3.4 and I have gone through > the installation readme for PHP. I have copied the necessary files to > the correct directories. I have also set register_globals= Off (default) > I have set my session path (it exists). > > Now my problem is that I cant get my sessions to work at all. I have > tried everything and no luck. > Ok here is what I do: > > $_SESSION['login']="true"; > > if (session_is_registered($_SESSION['login'])) > echo("seesion is reg"); > else > echo("seesion not reg"); > Hi Angelo, where's your session_start()? Also you can use isset() instead of session_is_registered(): if (isset($_SESSION['login'])) Regards, Torsten Roehr > I have not used the session_register function as the manual says the > following: > > If you want your script to work regardless of register_globals, you > need to instead use the $_SESSION array as $_SESSION entries are > automatically registered. > > I seriously dont know what else to try or do. If you think I've missed > something then please help. > > Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to determine if date/time is with DST or not ?
"-{ Rene Brehmer }-" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi gang > > I'm trying to find a simple way to determine if a given date/time is with > DST for a given locale at any point in time ... the point is basically to > convert date strings into accurate GMT timestamps for storage in the > database... > > Like I've got date strings looking like: > > Thursday, July 22, 2004 8:50:01 PM > July 22, 2004 6:42 PM > > the strings are submitted through a form, together with a variable > determining the time zone these times are in. I just want to figure out if > the dates are with or without dst for that locale, at that given time, so > that I can properly convert them to GMT times ... but I have no clue how to > do that ... haven't been able to find anything useful in the manual or the > PHP Cookbook ... the time zone is submitted negative of the actual value ... > so a time offset of -0700 is submitted as +7 and +0200 as -2 ... this is > simply to make the time conversion simpler... > > these are extracts of the current time calculation codes, including some > debugging code for the time conversion: > >$date = $_POST['date']; > $tzone = $_POST['tzone']; > > $timestamp = strtotime($date); > > if ($tzone != 'none') { > $tdif = $tzone.' hours'; > $timestamp = strtotime($tdif,$timestamp); > } > ?> > > /* the following part is an extra of a larger table ... the formatting of > the time zone is merely for displaying purposes atm. The goal is to create > RFC2822 dates to be stored in the database alongside messages... > */ > > Workdate: > Time difference: if ($tzone > 0) { > $format = '-'; > } else { > $format = '+'; > } > if (abs($tzone) > 9) { > $format .= '%u00'; > } else { > $format .= '0%u00'; > } > printf($format,abs($tzone)); ?> > Unix timestamp: > GMT date: > > > if anyone has any ideas for determining whether DST is on or off, I'd > appreciate it. right now I have no clue how to do this the easiest... > > TIA > > Rene > -- > Rene Brehmer > aka Metalbunny > > If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile? > > http://metalbunny.net/ > References, tools, and other useful stuff... > Check out the new Metalbunny forums at http://forums.metalbunny.net/ Hi Rene, I'm not totally sure but I loosely remember this topic being discussed here some weeks ago. Try your look by searching the mailing list archives. Best regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with submit form if type is image
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dear all, > > Can you please help me with the following? > > I have written the following script: If i have a input type image; the script doesn't go to the prospect2.php. If i have a input type=submit everything works super! Can someone help me? > > Frank > _ > $_POST["submit"]=isset($_POST["submit"])?$_POST["submit"]:""; > if($_POST['submit']!="") > { > file://$printresse=$_POST['printresse']; > session_start(); > $_SESSION["printresse"] = $_POST['printresse']; > header("Location: prospect2.php"); > exit; > } > ?> > > > > > > Value1 > Value2 > > ?> > echo""; > ?> > Hi, if you use the input type 'image' you have to check for name_x or name_y, so in your case: $_POST['submit'] = isset($_POST['submit']) ? $_POST['submit_x'] : ''; Whenever you have problems like this do a print_r($_POST) at the top of the second page. This will show you all submitted values. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Problem PHP version 4.3.8
Hi Andre, hi James, please see below "Andre Dubuc" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Friday 13 August 2004 11:19 am, you wrote: > > On Friday 13 August 2004 11:14 am, Andre Dubuc wrote: > > > Hi James, > [snip] > > .for thatt matter, have you 'saved' it using session_write_close(); > > > > From the Manual: > > Session data is usually stored after your script terminated without the > > need to call session_write_close(), > > > [snip] > > > Well, for my money James, that's where your problem lies. Notice the "usually" > in the Manual quote. In my experience, it never saves unless I write to it. Then something is wrong with your server. You DO NOT need to explicitly call session_write_close(). > But, with your config, with session.auto_start=1, if I read that correctly, > it will do nothing other than start the session automatically, but not save a > change to a session variable. Hence, it reloads with a 'not-set' condition in > that code. And by the way, it is hitting that if condition - hence your reset > session. James, have you tried with manually calling session_start() and setting auto_start = 0? If not, please try this. Haven't followed your previous thread so please forgive me if I'm asking something you already wrote. Are you using cookies? If so, have you tried without them by appending the session id manually to the links? Try these settings: session.auto_start= 0 session.use_cookies = 0 session.use_trans_sid = 0 Put session_start() at the top of ALL your pages and write your links this way: to page 2 Hope it helps, Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Changing MySQL Date Format
"Harlequin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using a hell of a lot of dates in my databases and wondered if it was > possible to change the date format in my databases from -00-00 to: > 00-00-...? This would make ordering by date impossible - do you really want this? You should put formatting issues into your application and rely on the ISO format in your database. Regardsm Torsten Roehr > > Has anyone else managed to do this or use any workarounds I could use > perhaps...? > > I'm just getting a little hacked of having to explode the damn things every > time I use them. > > -- > - > Michael Mason > Arras People > www.arraspeople.co.uk > - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Load data and Insert
"Torsten Roehr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Juan Pablo Herrera" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hi! > > i need do two querys in one. > > First query is a load data and the second query is insert into. > > My idea is to concatenate with "and", but i'not know. > > Is it possible? > > > > Regards, > > Juan > > Please specify a bit more clearly *what* data you want to load *from where* > and insert into *what*. Then we may be able to help you. > > Regards, Torsten Roehr If you refer to MySQL you can use the INSERT ... SELECT syntax to do this in one query. See here: http://dev.mysql.com/doc/mysql/en/INSERT_SELECT.html Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Load data and Insert
"Juan Pablo Herrera" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi! > i need do two querys in one. > First query is a load data and the second query is insert into. > My idea is to concatenate with "and", but i'not know. > Is it possible? > > Regards, > Juan Please specify a bit more clearly *what* data you want to load *from where* and insert into *what*. Then we may be able to help you. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Image and variable
"Henri marc" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I would like to use a variable instead of an image > file name in a html page with this instruction: > > echo ''; > ?> > > I tried but the image doesn't show up. Is it > impossible or do I do something wrong? > My goal is to have a random image print in the page, > that's why I want to use a variable. > > Thank you for your good advices. Variables in single-quoted strings are not evaluated. Either user double quotes or concatination: echo ""; or echo ''; Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Local version works - production breaks
> Robby, > > I just enabled log_errors locally. No errors (as I thought). > > Since I am hacking a previously written site, the problem seems to arise most > when accessing his pre-built functions across pages. For instance, he uses a > 'cards.php' to store all display functions -- showleft() -- showcentre() , as > well as the connect() function. Hi Andre, make sure to use require_once for all includes. This will make sure to only include each file once and will trigger a fatal error if the file cannot be found because of a wrong path or whatever. Hope this helps, Torsten Roehr > Since its a persistent connection -- he opens > the db once, then performs various queries in it. However, since 'cards.php' > has already been called once by a page that might require both showleft() and > showcentre() -- it barfs and says that it cannot 'redeclare' the showleft() > function that has already been declared?? That is really some weird -- > particularly when it works so well (as expected) locally - and also since I'm > not 'redeclaring' but calling it for use! > > I cannot fathom why the production site would give this error. Perhaps I need > to do absolute paths for all headers? But it doesn't make sense that a > function cannot be called many times -- declaring it once, yes, but calling > its use?? If that were the case, then one might as well write it out longhand > for each use, and forget the concept of 'functions'. > > I think I should look at the error logs for the site -- maybe they will clue > me in where I should look. > > Thanks, > Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function Mail
"Juan Pablo Herrera" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi everybody, > I have a cuestion about the features on function mail. I think that it > send the email one to one address. Is it ok?. > Regards, > Juan Pablo Hi Juan Pablo, the manual says: "mail() automatically mails the message specified in message to the receiver specified in to . Multiple recipients can be specified by putting a comma between each address in to." This should answer your question. Otherwise take a look at the manual page: http://de2.php.net/manual/en/function.mail.php Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: regex help and file question
"Php Gen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I am just starting out with regex (and classes) so am > not sure how to do this... > > I am seeing if a HTML file exists, if yes, I am using > file_get_contents to get the entire HTML file into a > string. > > In the HTML file I already have this: > > > > > whatever you want comes here > > > How do I use a regex to span these multiple lines and > simply cut everything (including the start..end > part)from to > > Second question: > I am using file_get_contents, is it better to use this > than file() or fread() ? > > Thanks, > Mag Hi, I can't answer your regexp question but some thoughts on file() etc.: - file() returns the contents line by line as an array, so this makes only sense if you need the contents in this form, e.g. for looping through each line and applying a function or whatever - fread() requires a file handle that you have to create with fopen(), so file_get_contents() is kind of a shortcut for fopen()/fread() Hope this helps. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] looking for a solid/good basic registration/loginapp/script
"Robby Russell" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Sat, 2004-08-07 at 10:43, bruce wrote: > > hi... > > > > i'm looking for a good/solid login/registration script that's in the open > > source domain. > > > > it can have it's own db/table structure. i can always rearchitect... > > > > i'd like it to have an admin function, and the ability to verify users via > > email, etc... > > > > anybody have a favorite/good app that they've used/implemented. > > > > i've look through lots of scripts, and decided to check here for additional > > input. > > > > thanks > > > > -bruce > > There is Pear::Auth. I've had good experiences working with it. > > http://pear.php.net/package/Auth > > -Robby LiveUser is also worth a look: http://pear.php.net/package/LiveUser Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session problems under heavy load???
"Ed Lazor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I ran into this last month. It was a problem with the ISP's server. They > were load balancing between different machines and PHP / Apache was having > trouble accessing session files. Storing the session data in a database might solve this problem. Regards, Torsten Roehr > > > -Original Message- > > From: BOOT [mailto:[EMAIL PROTECTED] > > Sent: Friday, August 06, 2004 1:26 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] Session problems under heavy load??? > > > > My server was under a heavy load (rebuilding software raid 1 array) and my > > PHP+MySQL site seemed to be all "messed up." From what I can makeout > > session > > variables were being lost. I would expect simply degraded performance but > > not the loss of variables. Is this normal? LOL the array is still > > rebuilding > > right now and the alternative problem means something happened to my code > > (yes I have backups :)) > > > > Thanks for any comments! > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need Some Direction
"Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do you recomend the same for downloading of a file. I have a few zip files > that need to be protected too. Do I have to open the file using fopen and > then write it to the users machine using fwrite? > > Thanks, > > Aaron You can do this for any type of file. Set the aprropriate headers and then use readfile(): http://de2.php.net/manual/en/function.readfile.php Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need Some Direction
"Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I hate to sound ignorant, but how do I get a file out of a .htaccess > protected directory without logging in again? You cant use the normal > syntax of http://username:[EMAIL PROTECTED] anymore. Microsoft "fixed" that > "bug". > > Thanks, > > Aaron Hi Aaron, because you are accessing a file via PHP from your *local* file system it doesn't matter if the directory is protected or outside of the webroot. PHP has access to the file (if read privilege is set). The protection is just to deny public access. Take a look here: http://pear.php.net/manual/en/package.http.http-download.intro.php Hope this helps, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Getting data from table as a tree
"Pt2002" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > Sometimes, some clients just want a few scripts. sometimes to fix or to add > some features in sites or apps already in production and that need to be > something easy to install. kind of upload and go. They don't want a bundle > of scripts with dependencies, they don't want configuring paths, etc, etc. > > Greetings OK, I see. Hmm, usually it works fine once everything is setup - the only thing you have to adapt from server to server is set the correct include path. But if this is already too much for your client... ;) Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need Some Direction
"Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > So far I have made this work. But now I have to ask...what about a pdf > file? I cant add php code to it so what do I do. I need to be able to > restrict the pdf so a user can only get to it during a current session. > > Thanks again for all the previous posts. You all directed me to a good > place. My pdf files sliped my mind when I posted. I should have added this > problem before. > > I hope it can still be done. > > Thanks, > > Aaron Hi Aaron, put your pdf file outside of the webroot our in a .htaccess protected directory. Then read in the file contents, set the appropriate headers and output the file contents to the browser - this should prompt a download window. PEAR's HTTP_Download is excellent for this job: http://pear.php.net/package/HTTP_Download Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Getting data from table as a tree
"Pt2002" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thank you for your suggestion. > I've had already browse pear classes but didn't want to use them. > I've found some tips and now I can show the tree but I also need to have all > the data in an array and that's the problem now. > > Greetings > pt2002 Out of curiosity, why don't you want to use the PEAR classes? Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Need Some Direction
"Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I am trying to build up a members only site, but I need some direction. So > far I have written a page that will let a user register for access. That > script emails me their info so I can validate it, sends them a "thankyou" > email and then sends the data to a temporary MySQL database table. In the > email that I get I created two links. One will send the user an acceptance > email and put their info in a final database table. The other will send the > user a Deny email and will delete their info from the temporary database > table. > > I have also created a login script that will ask for a username and password > and verify it with the database. If its all correct then it will redirect > you to a restricted page. > > The direction I need is how do I go about restricting access to the members > only pages? I have been reading up on sessions, which I think will be a > cool addition to this site, but I still havent found much on restrictin > access without a username and password. Currently my login and registration > pages are located in the root of the domain. The all the members only pages > are in a directory called /members/. > > Can anyone give me some direction on how I should go about all this. > > Thanks, > > Aaron Hi Aaron, you might want to take a look at PEAR's LiveUser: http://pear.php.net/package/LiveUser Takes a bit of time to set up but should be exactly what you are looking for. It handles user authentication (login), session timeout and user rights. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Getting data from table as a tree
"Pt2002" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > > I have a table like this > id, pid, name. When a item has no parent, pid = 0. There is no limit in > depth. > 1, 0, Test 1 > 2, 1, Test 1.1 > 3, 1, Test 1.2 > 4, 2, Test 1.1.1 > 5, 1, Test 1.3 > 6, 3, Test 1.2.1 > > I need to read this table and return an array that represents the tree. > Maybe using a recursive function but had no success. > > I just need someone to point in the right direction. > TIA > > Greets > pt2002 Hi, those two PEAR packages might help you: http://pear.php.net/package/DB_NestedSet http://pear.php.net/package/Tree Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: is_numeric questions
"Jeff Oien" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Does is_numeric include commas decimals and dollar signs? > > How do I use this to error check form data? I'm having a hard time > figuring out what the correct syntax is for that application. Thanks. > Jeff It surely will not allow a dollar sign. Otherwise just test it with various values! You might take a look at PEAR::Validate for checking *true* numeric values: http://pear.php.net/package/Validate Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with PEAR DB & MySQLi
"Rodolfo Gonzalez Gonzalez" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I'm trying to use PEAR's DB class with the new PHP 5 MySQLi support on > MySQL 4.1.3, using this example from the PEAR's docs (with my parameters > of course). I'm getting "DB unknown error" messages after the query. The > same query from the mysql client works fine, there are no connection > problems... anyone has tried PEAR with mysqli?. Hi, you should ask this on the PEAR general mailing list. Regards, Torsten Roehr > > // Create a valid DB object named $db > // at the beginning of your program... > require_once 'DB.php'; > > $db =& DB::connect('mysqli://prueba:[EMAIL PROTECTED]:3306/mibase'); > if (DB::isError($db)) { > die($db->getMessage()); > } > > // Proceed with a query... > $res =& $db->query('SELECT * FROM users'); > > // Always check that result is not an error > if (DB::isError($res)) { > die($res->getMessage()); > } > ?> > > result: > > DB Error: unknown error > > > Regards, > Rodolfo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Usng Session Vaiable in WHERE Statement
"Harlequin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Could someone please help me with my syntax here...? > > $MembersDataQry = "SELECT * FROM MembersData > WHERE UserID='$_SESSION['logname']'"; > > I get an error on line 2 but can't seem to figure out what I've missed. > > The variable echoes fine so I know there's a string in there. > To use array values within double quotes you have to put curly braces around them: $MembersDataQry = "SELECT * FROM MembersData WHERE UserID='{$_SESSION['logname']}'"; Or concatenate the string: $MembersDataQry = "SELECT * FROM MembersData WHERE UserID='" . $_SESSION['logname'] . "'"; Remember to apply mysql_real_escape_string() on any values used within a query. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Embedding JavaScript into a PHP generated web page
"Robert Frame" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi There, > > I have a web page with a form that is generated by PHP, and part of my > design utilizes JavaScript to provide some error checking within the objects > in the form. I have written the javascript in an html document, but I am > having trouble blending the two together. > > I have tried sending the javascript within an echo statement, as well as > using straight HTML/JavaScript code, but nothing seems to work. > > Can anyone offer some help or direct me to a solution? > > Thanks, > Rob Hi Rob, usually it works by just putting plain JS/HTML into the page outside of the php code sections. But without seeing any code we cannot help you. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: JavaScript in PHP or PHP in JavaScript
"Robb Kerr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Let me preface this by saying that I don't know JavaScript. I've got a page > that is built by a long complicated JavaScript that I was able to hack just > enough to function the way I wanted. There are some lines of code -- those > that define div positioning -- that need to be different depending upon > what it obtained from my database. I could build a simple PHP if/then > statement and embed the entire JavaScript with the lines changed. Or, I > could build a simple PHP if/then statement with only the lines of > JavaScript that need to be changed and embed it within the JavaScript. > which would be better? > > JavaScript in PHP > >if (conditional) { > ?> > several lines of JavaScript > } > ?> > > > PHP in JavaScript > > > several lines of JavaScript > <?php > if (conditional) { > echo 'lines of JavaScript'; > } else { > echo 'other lines of JavaScript'; > } > ?> > several lines of JavaScript > > > > Thanx, > Robb Hi Rob, maybe you can use the ternary operator syntax for the affected lines: echo (conditional) ? 'lines of JavaScript' : 'other lines of JavaScript'; Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php and images
"Roman Duriancik" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have problem with jpg pictures in php pages. Path and picture is > correct but when i want see picture in php script picture don't show. > I use PHP4.3.4 on apache server 2.0.44 on Windopws 2000 Server. > > Thanks for help. Check if your JPEGs are in CMYK color mode - must be RGB. Does your browser display the image when you open it with "File / Open..."? Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: good PHP to PDF libary?
"Louie Miranda" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Im looking for some good and complete and advanced PHP to PDF libarary. > > So far, i have seen pdflib and r&os pdf class. But i really would like > to hear from you guys what is best? > > my only main goal for this is to create a low - res pdf and a hi - res > business card pdf template. > > thanks PDFlib is very good, but costs quite an amount of money. But there is a free trial version available so that you can test anything beforehand and if it works you can buy the license. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: background="#"
"Tobias Brasier" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all-- > > I subscribed to this list because I have an interest in PHP, but am more of > a dabbler than an actual programmer; in other words, I never thought I > would be posting a question to the list. So, the following is a problem I > send on behalf of one of the programmers in my group, who is relatively new > to PHP. > > = > I have recently noticed a problem with our code or our webserver (Apache) > when I execute a .php file. I have taken all php code out, but within an > html tag, I use background="#", which is used for older browsers such > as Netscape 4.7 if you have a background color or image in a table (the > background # completes it throughout the td). This isn't the case for IE > or NS 6+, though. > > The problem is that when I run the page, the log files show that the page > was accessed twice. This is only the case if the file has a php > extension. This does not occur if the file is an html file, > though. Please don't respond by saying change it to an html file and don't > worry about it. This needs to be a php file that connects to a database, > but I first noticed the problem, because I had code that emailed me > twice. After narrowing it down, it has nothing to do with the code, only > the fact that its a php file and background="#" is in a tag. > = > > Many thanks. > = >Tobias Brasier Hi Tobias, I remember that some weeks ago someone had a similar problem with an img tag where the page reloaded several times. Search the mailing list archives and you might find the thread: http://marc.theaimsgroup.com/?l=php-general Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: searching through 2 text files
"Alantodd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have 2 text files > > > > One has arp list > > > > IP Address MAC Address Type > > -- -- > > 165.166.182.204 00:0a:04:98:b5:d3 dynamic > > > > > > One file has a mac list > > > > Modem MAC Address IP Address CPE IP Address CPE MAC > Address CPE Source > > - --- > - --- > > 00:00:39:46:88:57 10.21.2.236 165.166.182.204 > 00:0a:04:98:b5:d3Learned > > > > > > > > Just an example - there are about 5000 entries in each file (more in the mac > list) > > > > What I am trying to do is match the mac address from the arp file to a cpe > Mac address in the Mac file and return modem Mac and ip address from Mac > list. > > > > I can open the arp and set what I want to an array. But matching up is where > I hit a wall.. > > > > Thanks for any help or at least a point in some direction > > > > Alan Hi Alan, I guess you'd have to read the second file into an array as well (line by line) and then *for each* entry from the arp list loop through all entries of the mac list and compare the values. Have you considered putting the data into two MySQL tables? This would make dealing with it much more comfortable. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php