[PHP] IE corrupts JPEG at HTML upload, imagecreatefromjpeg() doesn't work after upload
Hi there, I am experiencing a strange problem with IE 5.0 while uploading a JPEG file. Somehow IE changes/corrupts the file so that imagecreatefromjpeg() doesn't work after the upload and triggers an error. If I upload the picture with Opera 7.22 or Mozilla everything is fine. Client is Windows (98SE, 2000) and server is Linux/Apache 1.3. Any help appreciated! Big thanks in advance! Best 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: 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: 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: 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: 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: 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: 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] > 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
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] > 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] > 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
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] 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] 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
[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
[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
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: 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
[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: 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: 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
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: 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
[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: 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: [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: 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
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
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
[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] 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: 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
[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
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
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
[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] 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: 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
[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: 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
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: 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
[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
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: 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] 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
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
[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] 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: 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] 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: 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
[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
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
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
[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
[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: 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
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: $_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
[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: 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: 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: 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: 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: 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: 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: !!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: 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: 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: 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: 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
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: 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
[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: 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: 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: 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: 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: 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: 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
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: 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
[PHP] Re: http header
"Gabe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is the following code the best way to redirect someone to a different > page using PHP? > > header("Location: http://www.yahoo.com";); > ?> >From personal experience I can recommend putting "exit;" behind a header() redirect to absolutely make sure that no code is executed afterwards in the script: header("Location: http://www.yahoo.com";); exit; Without "exit;" the header redirect soemtimes didn't work for me. Regards, Torsten Roehr > > I looked for a "redirect" function of some kind and didn't come up with > anything. Just curious what the consensus is... > > Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Why are Session Variables carried over into a brand new browser window?
"Bob Bruce - Programmer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This is my first posting to this group, so I am not familiar > with any special etiquette for it, please bear with me. . . > > I maintain the PHP code for the website for the murals of Winnipeg and > have found a situation where I have a session open with the state of > the user's search results saved in the session and link to a location > with the following link: > > href="http://www.themuralsofwinnipeg.com/Mpages/index.php?action=gotomural&m > uralid=179"> > > so this opens a new browser window, but it is inheriting the session values > from the browser window that called it and is causing problems in the new > window. When I open a new browser window shouldn't it start a whole new > session and not get anything from the previous browser. You can solve this problem by not working with cookies and instead forwarding the sessionID with the URL: http://www.themuralsofwinnipeg.com/Mpages/index.php?&action=gotomural&muralid=179"> So if you open a new page WITHOUT forwarding the sessionID a new session will be started. See the part named "Passing the Session ID" on the following manual page to see how to do it: http://de2.php.net/session Regards, Torsten Roehr > > Thanks in advance for your help, > > Bob Bruce, > Winnipeg, Manitoba > Canada -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Array Sorting Headaches
"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Greetings everyone : > >Having a hard time with this one. I have a multi-dim array > $foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample data : > > Array > ( > > [$x] => Array > ( > [0] => Array > ( > [invoiceid] => 11842 > [product] => myproduct > [domain] => foo.net > [expires] => February 28, 2004 > ) > > [1] => Array > ( > [invoiceid] => 10295 > [product] => myotherproduct > [domain] => foo.net > [expires] => December 9, 2003 > ) > > [2] => Array > ( > [invoiceid] => 10202 > [product] => product1 > [domain] => foo.bar > [expires] => January 19, 2003 > ) > > [3] => Array > ( > [invoiceid] => 10005 > [product] => product2 > [domain] => foo.bar > [expires] => December 11, 2002 > ) > > ) > ) > > I need to filter the results so that I get the latest expiry date for > each product. The expires field actually contains a timestamp. So for > the sample array above, the resultant array would have only keys 0 and > 2, filtering out all the rest. There are around 180+ main entries, with > any number of sub entries, but each sub entry has the same four keys. > > Any ideas? Getting a rather large headache mulling over this. Hi, as your structure is always the same you could just loop through all elements and subelements and use unset() to remove the unwanted array elements: foreach ($foo as $key => $value) { foreach ($value as $subkey => $subvalue) { // put your check logic here if ($foo[$key][$subkey]['expires'] == '') { unset($foo[$key][$subkey]); } } } What do you think? Regards, Torsten Roehr > > Thanks again, > Burhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Array Sorting Headaches
"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Torsten Roehr wrote: > > > "Burhan Khalid" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>Greetings everyone : > >> > >> Having a hard time with this one. I have a multi-dim array > >>$foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample data > > > [ snipped ] > > >>I need to filter the results so that I get the latest expiry date for > >>each product. The expires field actually contains a timestamp. So for > >>the sample array above, the resultant array would have only keys 0 and > >>2, filtering out all the rest. There are around 180+ main entries, with > >>any number of sub entries, but each sub entry has the same four keys. > >> > >>Any ideas? Getting a rather large headache mulling over this. > > > > > > Hi, > > > > as your structure is always the same you could just loop through all > > elements and subelements and use unset() to remove the unwanted array > > elements: > > > > foreach ($foo as $key => $value) { > > > > foreach ($value as $subkey => $subvalue) { > > > > // put your check logic here > > if ($foo[$key][$subkey]['expires'] == '') { > > > >unset($foo[$key][$subkey]); > > } > > } > > } > > > > What do you think? > > Well this is what I have right now, but the problem is the logic which > checks to see for each domain which is the last expired date. I have > three nested for loops right now, and not getting anywhere :( Maybe it works if you put the expires value in a seperate array, sort it and then you can get the key of the first one and use unset(): foreach ($foo as $key => $value) { $tempArray = array(); foreach ($value as $subkey => $subvalue) { // add expires value only to the temporary array for sorting $tempArray[$subkey] = $foo[$key][$subkey]['expires']; } // sort array by value descending arsort($tempArray); // get first (and therefore highest timestamp) key/value pair $firstEntry = each($tempArray); $notneededSubkey = $firstEntry['key']; // now unset the array value with the not needed subkey unset($foo[$key][$notneededSubkey]); } Have not tried it but may work. Hope you see my point. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Array Sorting Headaches
> Well, it does some sorting, but not quite what I'm after :( > > I've managed to get the list so that all the (sub) entries are sorted in > the correct order. Now its just a matter of finding the highest expire > date for /each/ domain, and delete the other entries for that domain. > So, in the end, all that's left is one entry per domain, with its latest > expire date. > > Hopefully this makes it a bit clearer. OK, so it's just the other way round - I see. Instead of deleting the entry with the highest expiry date we delete all the others: foreach ($foo as $key => $value) { $tempArray = array(); foreach ($value as $subkey => $subvalue) { // add expires value only to the temporary array for sorting $tempArray[$subkey] = $foo[$key][$subkey]['expires']; } // sort array by value descending arsort($tempArray); /* new stuff starts here */ // remove the entry with the latest expiry (the first array element) array_push($tempArray); // now unset all remaining/not needed entries foreach ($tempArray as $tempKey => $tempValue) { unset($foo[$key][$tempKey]); } } By the way, isn't there a way to filter this stuff BEFORE or WHILE the whole array is created? Regards, Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Array Sorting Headaches
> > OK, so it's just the other way round - I see. Instead of deleting the entry > > with the highest expiry date we delete all the others: > > > > foreach ($foo as $key => $value) { > > > > $tempArray = array(); > > > > foreach ($value as $subkey => $subvalue) { > > > > // add expires value only to the temporary array for > > sorting > > $tempArray[$subkey] = $foo[$key][$subkey]['expires']; > > } > > > > // sort array by value descending > > arsort($tempArray); > > > > /* new stuff starts here */ > > // remove the entry with the latest expiry (the first array > > element) > > array_push($tempArray); > > > > // now unset all remaining/not needed entries > > foreach ($tempArray as $tempKey => $tempValue) { > > > > unset($foo[$key][$tempKey]); > > } > > } > > > > By the way, isn't there a way to filter this stuff BEFORE or WHILE the whole > > array is created? > > Thanks for the help. I'll give that snippet a try and see what comes out. > > The array is a result of a rather nasty SQL statement running against a > database (which I didn't design). Unfortunately, the way the database is > designed, its very difficult to extract the domain information. > > I am in the process of rewriting the entire thing as a Java application, > hopefully that will make things a bit clearer, since I'll also be > refactoring the database schema. Please let me know if it works. I'm sure there's a more elegant way to do it. > Many thanks, > Burhan You're welcome ;) Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Best practice for creating mysql database structure for menus navigation
"Dr. Zoidberg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > What will be the best database structure for creating web site > navigation, menus with submenus (unlimited levels). I'd suggest 2 id columns: CREATE TABLE menu ( menuItemID int(11) NOT NULL auto_increment, parentMenuItemID int(11) NOT NULL default '0', label varchar(255) NOT NULL default '', PRIMARY KEY (menuItemID), INDEX parentMenuItemID (parentMenuItemID) ) TYPE=myISAM; At the top level parentMenuItemID is 0, otherwise it's the value of its parent menuItem. Then you recursively load the menu structure. I think there are some good PEAR classes to do this. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: oo question
>so although the second class has a lot more code in it, it also allows >me to change what happens behinds the scenes (i.e. variable names) more >easily. for example the customer will always have a "first_name" but i >may not always want to use $fname to represent it within the class. >this revised class, in my limited experience, seems to be much more oo >than my current class. >seeing as how this email turned out longer than i had planned i will >only be asking one question at this time. in fact i can't even remember >what my second question was anyway. :) >any and all comments are appreciated! >thanks, >chris. Hi Chris, the second approach is definitely much, much better and the right way to go. But what exactly is your QUESTION? One personal suggestion: you could directly put the code from initialize_customer() into the constructor. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: oo question
>"Chris W. Parker" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Torsten Roehr <mailto:[EMAIL PROTECTED]> on Monday, April 19, 2004 10:46 AM said: >> the second approach is definitely much, much better and the right way >> to go. But what exactly is your QUESTION? >oh yeah.. umm... i guess at this point it would be "which is better?"... >as i was writing the email it sort of went in a different direction than >i had originally planned... >> One personal suggestion: you could directly put the code from >> initialize_customer() into the constructor. >but i'm thinking that i might, at some point, want to use that method >after the object has been instantiated. i can't think of a specific >case, but i'm only imagining that it's possible. OK, though I've not needed this anywhere else in my classes yet. But another suggestion. You can save a lot of code by generalizing/abstracting the assignment of your DB result to the class attributes. I'm doing this: class Base { /** * Sets properties based on supplied SQL result array with associative indices * * @param array $dbResult */ function initFromResultSet($dbResult = array()) { // if a non-empty SQL result set is supplied if (is_array($dbResult) && count($dbResult) > 0) { // get class properties as array $classProperties = array_keys(get_class_vars(get_class($this))); // array keys become object properties with respective value foreach ($dbResult as $key => $value) { // only set values for properties that exist in the class if (in_array($key, $classProperties)) { $this->$key = $value; } } } } } Then my 'real' class inherits from Base and calls the initFromResultSet() method: class Person extends Base() { function Person($personID) { // if a valid personID is supplied, get data from DB if (Validate::number($personID, array('min' => 1))) { // get person data from DB $query= 'SELECT * FROM ' . TABLE_PERSONS . ' WHERE personID = ' . $personID; $DB_result=& $db->query($query); // if person with given ID exists, set attributes if (is_a($DB_result, 'DB_result') && $DB_result->numRows() == 1) { $this->initFromResultSet($DB_result->fetchRow()); } // else set error and show list again else{ // handle error } } } } Of course the DB result must be an associative array with the column names being equal to your class attributes. This saves a lot of code and can be used in any class. Regards, Torsten >chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP and HTTP requests
"Aleksei Ivanov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I realize it's a stupid question but I need a simple solution.. I'd like to get contence from script-generated webpage >(I send a regquest via get or post method to a page and it generates a response page - how do get that page as a string? > Get the source of the page). It's obvious that it cannot be shown with file functions. Only solution I was mentioned vas > CURL package but I'd like to solve this with standard functions. Is it possible? Hi Aleksei, it might be possible to realize with PHP's output buffering functions. You could store the output of the dynamic page you would like to get in the buffer and then pull it into a variable. I don't have any experience with it but take a look here: http://de3.php.net/manual/en/function.ob-start.php Maybe the user comments help. Just an idea. Regards, Torsten Roehr > > Thanks in advance > Aleksei > > - > Hot Mobiil - helinad, logod ja piltsõnumid! > http://portal.hot.ee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Pear Layout question
>"Chris" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I asked this on the pear list and haven't received an answer. Hopefully >someone here can help. >I want to move to pear for some of my development/consulting needs. I >have only been exposed to pear for a script that I myself purchased, so >I am not that familiar with it. I know that pear is already installed on >my server, but I cannot speak for future clients. I would like to be >able to give my customers a zip file with my script and all the needed >pear modules. I've looked over the documentation and I did not see >anything touching on this. >What is an effective directory setup for this? Does this seem acceptable? >PEAR >--DB >--HTTP >--SOAP >--NET >--etc >Thanks >Chris Hi Chris, look at the require_once statements in the PEAR classes to see which directories are expected by the packages. But your draft looks OK. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file upload via email
"Yury B ." <"[EMAIL PROTECTED]"@ctb-mesg6.saix.net> wrote in message news:[EMAIL PROTECTED] > Hi, > > I believe there is possibility to upload html and other types of > files to the site location via email. Using Cron I can make script to > retreave POP3 email messages with sertain content/attachments which > would be translated to the form of files and site update can be done > this way. The question is - does anybody know actual script for doing > that? I'm not really advanced PHP developer so any help or suggestion > would be appreciated. > > Yury For accessing the POP3 mail server you could use PEAR's Net_POP3 class: http://pear.php.net/package/Net_POP3 Haven't tried it myself yet, though. Regards, Torsten Roehr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mathematical expression calculation function?
Take a look at eval(): http://de2.php.net/manual/en/function.eval.php Regards, Torsten "Enfors Christer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi. I need a function that takes a mathematical expression in the form of a string, and calculates the result. PHP itself doesn't seem to provide one. I need something which can handle strings like: 10*73.2+3-(4*358.2874)/352 ... and so on. If it handles functions (like cos(), pow(), exp()) too, then that would be great. I'd appreciate any help. Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: self documenting php
"Edward Peloke" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > What is a good tool to use for documenting php? I am looking for something > like javadoc. I think there is phpdoc, just not sure if it's any good or if > I should try to create my own. Hi Eddie, try PHPDocumentor which is part of PEAR: http://pear.php.net/package/PhpDocumentor Regards, Torsten > > Thanks, > Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional Functions
Maybe you could group them by purpose and put them into different include files. Then you just include the file containing the functions you need at this point in the script. Regards, Torsten Roehr "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] I was wondering if using conditional functions would save resources. The thing is that there's many functions in the code I'm using, but most aren't used in each case. I was thinking that maybe, even if the functions are in the included files, I could not define them making them conditional. Would this benefit the script? How? TIA. [/snip] It might, have you experimented with any code? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: What's wrong with this IF statement?
"Robert Sossomon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > My IF statement should be picking up on the numbers, and if the number > matches not be displaying out the information, however I look at the > outputted page and the information is still there, what have I got wrong > on the code? > > > file://Show categories first > $get_cats = "select id_num, id_name, description, cat_code from > categories order by id_name"; > $get_cats_res = mysql_query($get_cats) or die(mysql_error()); > > if (mysql_num_rows($get_cats_res) < 1) > { > $display_block = "Sorry, no categories to browse."; > } > else > { > while ($cats = mysql_fetch_array($get_cats_res)) > { > $cat_id = $cats[id_num]; > if ($cat_id != "53" || $cat_id != "54" || $cat_id != "55" || $cat_id > != "117" || $cat_id != "118" || $cat_id != "74") First of all remove the double quotes because you are dealing with integers. Regards, Torsten > { > $cat_title = strtoupper(stripslashes($cats[id_name])); > $cat_desc = stripslashes($cats[description]); > $display_block .= " href=$_SERVER[PHP_SELF]?cat_id=$cat_id>$cat_title > $cat_desc\n"; > while ($items = mysql_fetch_array($get_items_res)) >{ > $item_id = $items[id]; > $item_num = $items[item_num]; > $item_desc = stripslashes($items[description]); > if ($item_num != "ABC-R37" || $item_num != "ABC-R42" || $item_num > != "HB-99100" || $item_num != "RO-PUMPS" || $item_num != "ML-HDGALJUG" > || $item_num != "PFS-CAC21" || $item_num != "PFS-CO2") > { > $item_num = ltrim($item_num); > $item_num = rtrim($item_num); > $display_block .= " href=\"catalog/$item_id.html\">$item_num - > $item_desc\n"; > } >} > > > My assumption is that BOTH IF statements are not working correctly since > the logic is that if they are built the same they would react the same. > HELP! > > TIA! > Robert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php