Re: [PHP] mysql_num_rows
Hi, 39| $result=mysql_query(slecet * from site_members where User_Name='$username'); 40| $num_row=mysql_num_rows($result); 41| if($num_row0) echo(error 46); There is an typo-error in the word slecet which shoud look like select :-) -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Subtracting Money
Hi Stephen, I'm having a problem. I need to subtract money, but if they type in an ammount such as $2.30 and I subtract $0.20, instead of returning $2.10 like it should, it returns $2.1. How can I fix this keeping in mind that other variable could be $2.40 or $100.30 and so on...? This is because, 2.1 is equal to 2.10 :-) You need to format the numbers in the way you want them. have a look at: http://www.php.net/manual/en/function.number-format.php and/or http://www.php.net/manual/en/function.sprintf.php both of them should do that job. sprintf's Example 6: $money1 = 68.75; $money2 = 54.35; $money = $money1 + $money2; // echo $money will output 123.1; $formatted = sprintf(%01.2f, $money); // echo $formatted will output 123.10 -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION question
Simply put - you can't. You need a way to transmit the session identifier, and AFAIK there's nothing except either cookies or SID. Using SID for security relevant issues presents a problem - users can send links with a SID to friends by mail or else, so this is not really a secure solution. However there are numerous application parts where no security is involved, and sessions are just used to construct a site - it's unnecessary IMHO to avoid SID use here. On our server we have disabled session cookies in general, as a courtesy to our users. However when logged in we require a user to accept a cookie. The value of this cookie is randomly generated (something like md5(rand())), and changes with every click. This value (we call it a login token is also stored in session data to verify the cookie against the session. If no user token, or a wrong token, is transmitted, we assume a hijacked session and automatically logout the user. (there's more to it, but basically you get the idea) This sounds like a pretty good idea to work around that problem :-) Does this system work, if the user decides to split one session accross multiple Browser-Windows, i.e. the uses the Open in new window-Function of most browsers? -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION question
Hi Jochen, How can I process $_SESSION variables if the user disables cookies and session.use_trans_sid = 0 ? You could use a combination of outputbuffering and a self-written session-handler. So you could build a trans_sid-alike system, that would do more checks (i.e. compare IP-Addresses) to validate, if a session is really the one it is claiming. (Of course this would be slower as trans_sid's and ain't that easy to do) -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.ini
The easiest way to find out where PHP expects your php.ini to be is to create a page that calls phpinfo() - the configuration file location is near the top of the output. Just to mention this: phpinfo() outputs the exact file name, if it loaded a php.ini - and outputs the path, where it thought the php.ini should have been, if it was not found. -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Am I blind? simple 15 line code producing error
require_once (config.inc); require_once classes/HtmlTemplate.class; The error is: Warning: Cannot add header information - headers already sent by (output started by.. ..line 6) ...on line 12 Line 6 is the line with if ($HTTP_SESSION_VARS[user_id]) Line 12 is the line starting with header You should check, if these include files contain anything after their closing ?. -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Am I blind? simple 15 line code producing error
Yes, I use those in other pages with no problem..it just this page causes some problems.. Do you use Header('Location:...') in those other scripts? I can't see any reason inside the script you posted, that could produce this behaviour. Can you try it without the two require's, just to be sure? btw: $HTTP_SESSION_VARS[user_id] should really be $HTTP_SESSION_VARS['user_id'] -Sascha -Original Message- From: Sascha Cunz [mailto:Sascha;GaNoAn.org] Sent: Sunday, November 03, 2002 1:03 PM To: Paul; [EMAIL PROTECTED] Subject: Re: [PHP] Am I blind? simple 15 line code producing error require_once (config.inc); require_once classes/HtmlTemplate.class; The error is: Warning: Cannot add header information - headers already sent by (output started by.. ..line 6) ...on line 12 Line 6 is the line with if ($HTTP_SESSION_VARS[user_id]) Line 12 is the line starting with header You should check, if these include files contain anything after their closing ?. -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable over url
Ops, of course. Sascha Am Donnerstag, 31. Oktober 2002 04:07 schrieb Chris Shiflett: I think you mean turn on register_globals. :-) Sascha Cunz wrote: try ?php echo $_GET['tmp']; ? or turn off register_globals in your php.ini file. Am Mittwoch, 30. Oktober 2002 20:49 schrieb Manuel Jenne: My Script: Test.php ? echo $tmp; ? My URL: www.some.domain/test.php?tmp=5 My result: NOTHING !!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Saving form input fields to MySQL br clicking on a button
Hi, Hi, I have a form where the user enters some information. For a particular section of the form, I'd like the user to be able to save what he/she entered so that the next time they feel out the form, they can recall without the need to retype. This is not for the entire form but only for a few input text fields. I created a button called Memorize but how do I have the page save the values to my MySQL database when the user clicks on the button. I understand that I can only use JavaScript to trap the OnClick() function and not PHP but I cannot use JavaScript to write to a MySQL table. I do not want to submit as that would reload the form and the user would lose other changes to other fields. Any idea? Don As you say it yourself, you can't use mySQL with JavaScript. Do a submit to a php-script, and restore the original page in that php-script. -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variable over url
Hi, try ?php echo $_GET['tmp']; ? or turn off register_globals in your php.ini file. - Sascha Am Mittwoch, 30. Oktober 2002 20:49 schrieb Manuel Jenne: Hi, I've just installed php 4.2.3 and wonder why I can't submit an variable over url. Example: My Script: Test.php ? echo $tmp; ? My URL: www.some.domain/test.php?tmp=5 My result: NOTHING !!! Where is the error? P.S. phpmyadmin run ok. Thanx Manuel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST-ing or GET-ing an array
Hi, first of all, i would prefer to do this task in a session-variable (less traffic, less security holes). But, if you're sure you need to pass the array via an URL, try: A HREF=test.php?ary[]=1ary[]=2 which will result in test.php called with $_GET['ary'] containing: [0] = '1' [1] = '2' If the array contains strings (as databases usualy do), you should url-encode them. If there is a better way to do this task, please let me know too. - Sascha Am Dienstag, 29. Oktober 2002 18:40 schrieb Petre Agenbag: Hi I KNOW I'm gonna get flamed, but I can't find this anywhere in my books or in the manual, yet I know I've read it somewhere. I created an array in a loop as such: $sql = select stuff from my_table; $result = mysql_query($sql); $count = 0; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow[id]; $my_array[$count] = $id; } Now, I want to send that array to another page with a normal: a href=next_page.php?array=$my_arrayNext/a BUT, that obviously doesn't work... Please just help me out, I'm suffering... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST-ing or GET-ing an array
Hey, I think you should be able to serialize and urlencode the array and then pass that via get/post.post would be a lot better as get is limited to so many chars. Something like: $sql = select stuff from my_table; $result = mysql_query($sql); while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow[id]; $my_array[] = $id; } echo 'a href=next_page.php?array='. urlencode(serialize($my_array)) .'Next/a'; You'll need to unserialize+urldecode the array at the other end. This is way nicer :-) Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: POST-ing or GET-ing an array
Hi, I disagree that serialize/unserialize is the way to go, unless you're absolutely completely sure that there will only be a relatively small number of things in the array. As somebody mentioned briefly, the get request is limited to a certain number of bytes, and the string representing your serialized array could easily get too large to send on a get request. imho the best option is to use the session, which somebody already mentioned but didn't really elaborate... $_SESSION['my_array'] = $my_array; Exactly. But just to mention it at this point: if you have script-output (echo, print, print_r etc.) before any operation on $_SESSION, you should call start_session() at the start of the script. (I don't know if recent versions of PHP still _need_ this) and on next_page (or any other page), you'd just use $_SESSION['my_array'] where you need. I would suggest, unsetting the array in the next_page (or whatever) after you don't need it anymore: unset($_SESSION['my_array']); Another option would be to send the request as a post, and serialize the array into a hidden variable in your form; that way you won't have to worry (as much) about size constraints. (a post request is also limited in size, but it's so large that you probably would never approach the limit.) /nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $HTTP_GET_VARS within a function ??
http://localhost/test.php?var=5 results in (global scope) $var = 5; // Register globals on $HTTP_GET_VARS['var'] = 5; // Always (?) $_GET['var'] = 5; // With newer versions of PHP To access this from a function: function x() { global $var; globsl $HTTP_GET_VARS; echo $var.'BR'; echo $HTTP_GET_VARS['var'].'BR'; echo $_GET['var'].'BR'; } Note, that there is no global $_GET; - $_GET is a superglobal. That means, you can always access it. Sascha Am Montag, 14. Oktober 2002 09:50 schrieb John Negretti: Jason, What is the difference? Jason Wong [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... On Monday 14 October 2002 08:36, John Negretti wrote: Marco, I was reading that there were some security risks with register-globals. Is this the same thing as global. No, they're totally different things. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Never promise more than you can perform. -- Publilius Syrus */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global AND Register Globals with PHP 4.0.6 ??
Am Montag, 14. Oktober 2002 16:51 schrieb Negretti, John (CCI-San Diego): Hello, I need to access the $HTTP_GET_VARS and $HTTP_COOKIE_VARS arrays within a function. In order to do this I have to pass $HTTP_GET_VARS as a parameter of the function. How can I access these built-in arrays without passing it as a function parameter. Should I define them as a global variable. I read that register globals has some security issues. Are these the same, or is setting a variable as global and register globals different? NOTE: I am using PHP 4.0.6. Thanks for any assistance. :-) John Negretti Web Applications Developer Cox Communications www.cox.com Just declare them as a global in your function. The register globals settings is some different thing. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload Problem
Hi, as far as i can follow you, you want to: 1. copy a file from position a to position b. 2. read it from position b. 3. and delete it at position b. Why not read it directly from position a? So what about: $content = implode(br, file($userfile)); Anyway: You should initialize $i in any way, best with zero - $i=0; before the while loop. You check if 0.tab 1.tab 2.tab; if 2.tab exists, you create 3tab (A dot seems to be missing) $destfile .= '.tab'; instead of $destfile .= tab; Is this script executed on unix? That would clearify why it could not find C:\\My Documents\\lyrics\\C_DTBS\\SLIME.TXT :-) --Sascha Am Sonntag, 13. Oktober 2002 12:15 schrieb [EMAIL PROTECTED]: I posted User Upload and with no advice I attempted to use the sources i could find and came up with the following: while (file_exists($i.tab)) { $i ++; } $destfile = $i; $destfile .= tab; stripslashes($userfile); copy($userfile, /uploads/ . $destfile); chdir(/uploads); $lines = file($destfile); $content = implode(br, $lines); unlink($destfile); echo($userfile_name); It doesnt work (surprise, surprise), what im trying to do is upload the file to my /uploads/ directory then read it and store it on the $content variable, then the content variable inserts a row into db (allready done), then I delete the file the while loop is to make sure I dont overwrite the file and make an error in my database. The errors PHP returns are: Warning: Unable to open 'C:\\My Documents\\lyrics\\C_DTBS\\SLIME.TXT' for reading: No such file or directory in /home/tabzilla/public_html/doadd.php on line 89 Warning: ChDir: No such file or directory (errno 2) in /home/tabzilla/public_html/doadd.php on line 90 Warning: file(tab) - No such file or directory in /home/tabzilla/public_html/doadd.php on line 91 Warning: Bad arguments to implode() in /home/tabzilla/public_html/doadd.php on line 92 Warning: unlink() failed (No such file or directory) in /home/tabzilla/public_html/doadd.php on line 93 ANY HELP? ANYONE??? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Predefined variables not set?
Am Sonntag, 13. Oktober 2002 10:04 schrieb Miles: When trying to get $_SERVER[QUERY_STRING] I am getting 'Undefined index QUERY_STRING' error If there is a query string, e.g. www.site.com/index.php?hello_world then it IS defined. So it seems that PHP is complaining about undefined variables, rather than just outputting nothing. How can I fix this? I've had no problems until i reinstalled php today... I think on your prior installation, error reporting level was set lower than on your new installation. The better way is to fix the script, that this condition doesn't occur at all -- if (isset($_SERVER['QUERY_STRING'])) { ... } Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST and GET variables don't work
Am Sonntag, 13. Oktober 2002 02:11 schrieb Andres Olarte: Thanks to Oscar and Jennifer, it's working now. I did a bit of reading, and it seems it's not recommend to enable register_globlas, why is that? For security... Imagine, you register a session variable to contain the user's ID. Anyone could login using that ID in a GET or POST variable with register_globals to on. -Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fatal error: Maximum execution time of 30 seconds exceeded
Yet another very fine way to do this job, is to set up a mailinglist manager (ezmlm i.e.), whom you subscribe all your recipients - And then send just one mail to the mailinglist manager. Of course, works only if you got control to the server. --Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple HTML-Form Question
register_globals defaults now to off. Use the superglobals instead. ? if (isset($_GET['name'])) { echo Hallo .$GET['name']; } else { echo FORM action='test.php' method=get input type=text name=name input type=submit name=action value=sendit; } ? Sascha Am Sonntag, 13. Oktober 2002 23:40 schrieb Lars H. Korte: Hi, I've updated to PHP 4.2.3 and wrote this simple Script: ? if (isset($name)) { echo Hallo $name; } else { echo FORM action='test.php' method=get input type=text name=name input type=submit name=action value=sendit; } ? I would expect the following: The site starts with the form, then I enter my name (Lars) and click the send-button. Then the script says Hello Lars. The actual output is: The site starts with the form, I enter my name and click the button, then the form keeps being there, no Hello-message. Has there changed something in PHP-Coding since I've learned it a few years before? There seems to be a diffrence between clicking the send button and pressing Enter. Has this always been so? regards Lars -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple HTML-Form Question
This beautifies it (even makes it a bit more secure), but one doesn't need it really; should have worked without these changes, too. (Of course, it's better to include these changes) Sascha The value of name for the submit button is wrong - it should be the same as the value you gave the isset statement, in this case it should be input type=submit name=name value=sendit Better yet is to use isset($submit) and the value for the submit statement is also name=submit - input type=submit name=submit value=sendit of course value is optional. So you end up with this - ? if (isset($_GET['submit'])) { echo Hallo .$GET['name']; } else { echo FORM action='test.php' method=get input type='text' name='name' input type='submit' name='submit' value='sendit'; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling PHP (cgi) from a perl script and passsing parameters
What you're referring is CLI, not CGI Version of PHP. Anyway, i assume, you're using a PHP version 4.2 or higher. Have a look at the $_SERVER['argc'] and $_SERVER['argv']. Sascha Am Donnerstag, 10. Oktober 2002 23:57 schrieb Jim Carey: Hi, have been having problems passing parameters to a PHP script from a Perl script . I call the PHP script using (as an example): $a=`/home/ozbcoz/http/testphp.php fred=testing`; print $a; then I have a PHP script showing: #!/usr/local/php/bin/php -q ? print count=$argcbr; print 0=$argv[0]br; print 1=$argv[1]br; print 2=$argv[2]br; phpinfo(); ? the outout comes out as: count=0 0= 1= 2= plus the phpinfo bumpf - which shows argc as 0 and an empty array for argv sny clues anyone ? Jim Carey www.OZbcoz.com discount domain registration -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP_USER_AGENT - list of possibilities
Hi, Hey everyone... do you know where I can find a list of the common returns of the $_SERVER[HTTP_USER_AGENT] variable? For example: I.E. 5.0 = Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 1.0.3705) Netscape 4.08 = Mozilla/4.08 [en] (WinNT; U ;Nav) On one side - i've never seen such a list. (I'd suggest to record them by yourself) - on the other side: wouldn't it be a bit better to have regular expressions (or at least some rules), that map the Useragent text into the individual data it contents: 1. Browser Manufacturer 2. Browser Version 3. Browser Language 4. OS 5. Buildtime 6. other propritary information some companies supply in Useragent text. ... Consider: The last value of your first example can be anything. .NET CLR indicates that the version of Microsoft's Common Language Runtime will follow. Meanwhile i had about 20 of them installed on my windows machine. Even, if I never changed the browser, on ever CLR Update Mircosoft's UserAgent-String had changed. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php.net bug system
sure, it is :-) Try: http://cvs.php.net/cvs.php/php-bugs-web?login=2 or go to: http://www.php.net/anoncvs.php and check out php-bugs-web Happy Hacking (I'd personally prefer bugzilla... You won't need to adjust as much) Sascha Am Mittwoch, 9. Oktober 2002 02:52 schrieb Jason Morehouse: Anyone know if the source is available for the bug system use on php.net? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can it be Done?
Hi, i don't think you can do this all on Server-side. I once made things like that work with usual frames. I used Javascript in each page of the frameset to find out if the parent exists - and if not, redirect to the frameset which itself was a PHP script whom i told to load the current page in correct frames. I don't know if that's also posibile with iframes. Anyway, you need to do two steps: 1. You must be able to view the outer page with a parameter, which tells it what Site is to be viewed inside the iframe. 2. Some sort of JavaScript wich redirects to the outer page. Tha JavaScript must live inside each site that might show up inside the iframe. Regards Sascha Am Sonntag, 6. Oktober 2002 18:29 schrieb Stephen: Hello, I was wondering if what I want to do is possible. I have a website that uses iframes and sometimes the search engines pick up the file that's displayed in the iframe. That file jsut plain looks really bad but in the site itself and displayed in the iframe it looks a whole lot better. What I want to be able to do is this. If the file is being displayed just plain, not in the iframe, it forwards to the main site and then displays the file in the iframe. But then, if the file is already being displayed in the iframe, it doesn't do anything. Can this be done and how? Thanks, Stephen Craton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can it be Done?
To produce such a JavaScript: define('_DOMBASE', 'http://yourdomain.com'); echo 'SCRIPT language=JavaScript type=text/javascript'.\n .'if (document.location == top.location)'.\n .' top.location='._DOMBASE.'/index.php?goto=' .base64_encode($_SERVER[REQUEST_URI]).';'.\n .'/SCRIPT'; where the index.php works like: ? if (!isset($_GET['goto'])) $goto = home.php; else $goto = base64_decode($_GET['goto']); ? FRAMESET someframes FRAME src=http://yourdomain.com/? echo $goto; ? /FRAMESET As Stephen reported me recently, this also works with iframes. Sascha Am Sonntag, 6. Oktober 2002 21:37 schrieb Adriano: Hi people, Edwin wrore: 'Not really sure, but perhaps, with Javascript. But I'd rather recommend you to give up iframes... ;) Can you post an example of Javascript code checking for _parent frame? By the way, what's wrong with iframes? bye, Adr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can it be Done?
should be interchangeable. When i wrote this, i didn't want to show the real url up in browser, so i used base64 encoding. Sascha Am Sonntag, 6. Oktober 2002 23:52 schrieb Adriano: I understand and thank you Sascha. Curiosity: why do you use the 'base64_encode' function to send querystring arguments? I'd rather used urlencode... Sascha Cunz [EMAIL PROTECTED] ha scritto nel messaggio [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... To produce such a JavaScript: define('_DOMBASE', 'http://yourdomain.com'); echo 'SCRIPT language=JavaScript type=text/javascript'.\n .'if (document.location == top.location)'.\n .' top.location='._DOMBASE.'/index.php?goto=' .base64_encode($_SERVER[REQUEST_URI]).';'.\n .'/SCRIPT'; where the index.php works like: ? if (!isset($_GET['goto'])) $goto = home.php; else $goto = base64_decode($_GET['goto']); ? FRAMESET someframes FRAME src=http://yourdomain.com/? echo $goto; ? /FRAMESET As Stephen reported me recently, this also works with iframes. Sascha Am Sonntag, 6. Oktober 2002 21:37 schrieb Adriano: Hi people, @ Edwin wrore: 'Not really sure, but perhaps, with Javascript. But I'd rather recommend you to give up iframes... ;) Can you post an example of Javascript code checking for _parent frame? By the way, what's wrong with iframes? bye, Adr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help for a where clause
A solution on that depends strongly on how much values A.Afn would take. For 3, it's still okay. But i wouldn't do more. Against what shall the B.Bfn* be checked? What Data do you want to be returned from the query? try: SELECT ### FROM A, B WHERE ((A.Afn=1) AND (B.Bfn1 = ...)) OR ((A.Afn=2) AND (B.Bfn2 = ...)) OR ((A.Afn=3) AND (B.Bfn3 = ...)) where you should replace ### with things you want to select and ... with the things you want to check. On more than 3 different values for A.Afn, you should use a more normalized version of B. i.e.: B contains only one Bfn field and a Reference to A.Afn. - SELECT ### FROM A, B WHERE B.AfnRef = A.Afn AND B.Bfn = ... Sascha Am Montag, 7. Oktober 2002 00:33 schrieb Alex Shi: Hi, I need a where clause in following situation: Say I want to query two tables: A and B. In table A there is field Afn, while in table B there are 3 fields: Bfn1, Bfn2 and Bfn3. I want to do a query, in which the where clause must do these things: if A.Afn=1, then check value of B.Bfn1; if A.Afn=2, then check value of B.Bfn2; if A.Afn=3, then check value of B.Bfn3. So how can I create such a where clause to do this? Thanks in advance! Alex Shi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IIS 5 - ASP PHP dev enviorment
You can run both of them without problems. Since ASP is a default on IIS, any IIS server set up to run PHP is running them both... I haven't heard of any problems caused just by having the two running at once. ---John Holmes... I got this configuration times ago... Works without any problems I am still using one machine, which needs IIS and PHP. There is really no big deal about that. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getimagesize or loop pblm
You can calculate the image size when adding the image (rather than when displaying it) and store the information in a file or a database. This file or database you could use for posting the right sizes for popup windows. Sascha Am Montag, 7. Oktober 2002 03:22 schrieb arnaud gonzales: So my code is clean ? There isn't a problem of infiny loop? My server is free.fr. How do u suggest i can cach the data? -Message d'origine- De : Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] Envoye : lundi 7 octobre 2002 03:07 A : arnaud gonzales Cc : Php-General Objet : Re: [PHP] getimagesize or loop pblm It could take a while. Depends how fast your server's disk sub-system is. Going to disk to stat and open an image and then parse through the initial headers to get the sizing data can take some time. I'd suggest caching this data somewhere if you are going to need it on every request. -Rasmus On Mon, 7 Oct 2002, arnaud gonzales wrote: Hi all, Does anybody can tell me why i have this error :Fatal error: Maximum execution time of 5 seconds exceeded in photos2.php on line 28 whith this $tab_img = array(); $tab_img_size = array(); for($i=0;$i=56;$i++){ $tab_img[$i] = images/tof/real_size/techp02_.$i..jpg; $tab_img_size = array( /* line 28 */ $i = getimagesize($tab_img[$i])); } Is the getimagesize function too long for making it 56 times?? What do u think ? In fact i want to get all the image size to make a popup link on the thumnail at the real size of the image.Because images don't have the same size and i want to have a clean window whith the popup. I've ever tried this before : $tab_img = array(); $tab_img_size = array(); for($i=0;$i=56;$i++){ $tab_img[$i] = images/tof/real_size/techp02_.$i..jpg; $tab_img_size[$i] = getimagesize($tab_img[$i]); } Hope you understand. TIA. zeg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More On: Good Practice: Variables, Error Reporting and Security
Am Samstag, 5. Oktober 2002 20:44 schrieb Adam Royle: I very much appreciate the suggestions made by the people on this list, although for me, when developing, the less typing I have to do, the less errors I am bound to come across, and therefore the less debugging I must do. (Now, doesn't this seem sensible?) Well, have you ever read a perl script? :-) The shortest source is not the best in all cases. Consider, that there will be times, you must read the source again - well, the easier it is written (and structured), the easier you will see again how it works... --Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] More Detailed Gettext() article?
Try the GNU Documentation on gettext: http://www.gnu.org/manual/gettext/index.html Regards Sascha Am Sonntag, 6. Oktober 2002 01:51 schrieb Wee Keat [Amorphosium]: Hi everyone.. Sorry for bothering u guys for such trivial matter... But where can I get a good article on how to use the gettext() function in PHP? I am building a website that supports multilingual capability and I've tried searching for it (Google, Yahoo, etc) the best that I could find is from O' Reilly but it was too brief to let me start on anything... Please help. Thanks a million... as usual! Yours, Wee Keat Chin -- If you cannot win, make the one ahead of you break the record. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Wanting to better understand
Anyway... cool way to use switch Obviously i've been working too much with C, that i never thought of a way, you could use the conditional-expression in the case, not in the switch ;) Sascha switch (TRUE) { case ($days 45): $days = strongfont color='ff00ff' . $days . /font/strong; break; case ($days 30): $days = strongfont color='ff' . $days . /font/strong; break; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] backwards compat for newly developed scripts ($_GET / $HTTP_GET_VARS)
Hey gang, I've been wondering about developing scripts that the end-user might run on php 4.1.0. I've heard allot of ways except for one that I recently thought of. How about using: - if(!isset($_GET)) { global $HTTP_GET_VARS; $_GET = $HTTP_GET_VARS; } - ? That allows you to use $_GET as if you were using the new versions and it only requires one lineand doesn't depend on the new versions to have $HTTP_*_VARS. It also works for the other vars(POST, SESSION, etc). If any script shall be executeable on such an old PHP release, this method sounds really good. But, for security reasons i would prefer to ship this in an extra script, which the user has explicitly to include (Maybe just paranoia)... Hmm, anyway it would be better to force those old versions to be updated - since 1) there was a lot of security changes/updates and other bug fixes 2) new functions have been developed in more recent versions. i.e. executing stored procedures on MSSQL. I think, this will force people much more to update. Wouldn't it be better to force them now, than provide backward compatibility for _new_ scripts? Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] backwards compat for newly developed scripts ($_GET / $HTTP_GET_VARS)
ummyou'd have to include that line at the top of every function that uses get(or any of the other) vars(scoping reasons) or somehow pass it via a reference to the function. I've always added the line at the top. At the top of each _function_? Urgs. Sounds like a hell of a lot of work. Would be enough at the beginning of the script - or even better, creating a dummy include for that or it might even be posibile to run it via an .htaccess (how is this option named php_prepend or such?). ... Thats if the user has the option to upgrade - some system admin don't like to do their job...I know of quite a few isps still running 4.0.6:( If they can't update the PHP Version they should update the ISP :-) Well, 4.0.6 might be a famous release (as you can find this very often), but it's about 1 year old now... If ISPs don't updated, they make their own machines vulnerable - the only conclusion (to make them learn their lesson) can be, that customers keep on running away, ain't it? Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined constant error
There seems to be a print-error in this book. It's missing a '$' This line: if (compteur == 1) { should be: if ($compteur == 1) { Sascha Am Montag, 30. September 2002 01:52 schrieb Voisine: Hello, I'm learning PHP from a book PHP for newbie writen in French and I have an error on one of the exemple. Undifined constant 'compteur' on line 15 which is : if (compteur == 1) { What I'm doing wrong? This is the script ?php include(config.inc.php); $query = SELECT * FROM Type ORDER BY animalType; $result = mysql_query($query) or die (Exécution de la sélection impossible); echo h1 align='center'Catalogue/h1ph3Quel type d'animal cherchez-vous ?/h3\n; echo form action='montre_animaux.php' method='post'\n; echo table cellpadding='5' border='1'; $compteur = 1; while ($ligne = mysql_fetch_array($result)) { extract($ligne); echo trtd valign='top' width='15%'; echo input type='radio' name='interet' value='$animalType'; if (compteur == 1) { echo checked; } echo font size='+1'b$animalType/b/font/tdtd$typeDescription/td/tr; $compteur++; } echo /table; echo pinput type='submit' name='submit' value='Faites votre choix'/form; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined constant error
make sure you have register_globals on in php.ini or your next question will be 'why isn't $compteur set to the value posted?' Better would be to change the line to the new magic globals, and learn the right way from scratch: I agree with you as far, as to learn the right way from scratch - but this is no POST-Var here. echo input type='radio' name='interet' value='$animalType'; if ($_POST['compteur'] == 1) { echo checked; } echo ; This is another bug in the script. Considering that, it would be correctly: (Note the space between '' and 'checked') echo input type='radio' name='interet' value='$animalType'; if ($compteur == 1) { echo checked; } echo ; or shorter: echo input type='radio' name='interet' value='$animalType'. ($compteur == 1 ? ' checked' : '') . ; Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Thanks
Thank you Sascha and Matt you got it ! Everything is working fine now. There is a lot of printing error in this book :( Sadly that's a property of most IT-Books :-( I've hardly ever seen another kind of books with more printing errors than IT books used to have... Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Hi John, Sorry about the ambiguity. What I'm trying to accomplish is close to what you describe. However, before anything goes into the db (ie html chars, bad commands, or anything from Mr.Hacker), I verify it. Someone suggested, way back when I first started with textarea, to use 'htmlentities' to strip the bad items out. You should always save it in the database exactly how the user typed it. So far, so good. But, if I follow what you suggest (and it's eminently reasonable!) I could have some 'bad stuff' becoming 'resident' in my db. Perhaps I am paranoid, but that seems like a-bad-thing-to-do. Save it with newlines and don't add any HTML code to it. Ahh . . . if I save as the user typed it, assuming Mr. Hacker has added some little extras, what then?? I use a Preview mode for viewing what thgey've entered, and they must go back to the textarea box if they need to edit (which has exactly what they typed.) Oh, this all did sense to me a while ago, but I am tired, and it's beginning to sound like gibberish . Thanks again. Andre Things will be alright, if you follow two rules: 1. before Output, use htmlentities() to make sure, your text isn't confused with HTML (This way noone can insert HTML-Tags into your Text). 2. before saving to database, either use addslashes() or turn on magic_qoutes in php.ini. (This will ensure, that noone drops your database on the fly. e.g. Enters something like '; drop database;' into a textarea.) as i remember magic_qoutes should be turned on by default. Don't do anything else with data that goes to your database, or you'll lose posibility to edit it later on. Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
?php /* db access using postgresql - each row is displayed */ ... trtd{$myrow['request']}/td/tr ... ? Now unless I can do something like: trtd'nl2br({$myrow['request']}'/td/tr Try something like echo 'trtd'.nl2br($myrow['request'].'/td/tr'; Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Yeah, good catch on the addslash/magic_quote. Also, FYI: PHP will only allow you to do one query per mysql_query(). So you can't try to end a quote and then send another query. Don't know if this is the case for all database functions, or what... Does PHP this? Such behaviour would be pretty new and pretty strange to me. And if, there must be any source in the source that does this, of which i can't remember... Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Htmlentities and Newlines?
Does PHP do what? By default the MySQL query function can only take one query at a time. There is nothing strange about this. The command-line mysql tool can take multiple queries separated by semi-colons, but that is something that is implemented in that command-line tool. It is not done in the underlying API function which is what PHP is talking to. -Rasmus Oops. I just tried it myself, you're right in this. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Not Saving?
function check_valid() { global $valid_user; if (session_is_registered(valid_user)) { echo font size='2'Welcome $valid_user!/font; } else { echo You are not logged in.; exit; } } try it like this: function check_valid() { global $valid_user; if (isset($_SESSION['valid_user'])) { ... Regards Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Posting a value to one form to another
I think your linux plattform has a version of PHP older than 4.2.0 and your Windows machine has a newer Version. In this old Versions, Register_Globals was turned on. Try to access $hid by using: ?php echo $_GET['hid']; ? Regards Sascha Hello , a href=Delay.php?hid=?php echo $hid+1; ?img src=Gif/nextque.gif border=0/a While clicking this link the $hid value get incremented and fetch the value from the database according to that..the same thing is working in linux platform and it is not working for the windows platform..the value is not getting increment..Can anyone please tell me how to go about with this..?? Regards, Uma -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Posting a value to one form to another
Oops, of course you must add one to it, too. like: ?php echo $_GET['hid']+1; ? Regards, Sascha Hello, On Sun, 29 Sep 2002, Sascha Cunz wrote: SCI think your linux plattform has a version of PHP older than 4.2.0 and your SCWindows machine has a newer Version. In this old Versions, Register_Globals SCwas turned on. SCTry to access $hid by using: ?php echo $_GET['hid']; ? SC I have tried like the code you have mentioned above..it is not fetching..Actually it is displaying in the url bar correctly with the incremented $hid value..but displaying the result correspond to the $hid initial value..Can anyone please tell me how to go about with this..?? Regards, Uma -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirection
And also avoid including scripts that contain a linebreak or a space after any '?'. When I did this first time, it took me ages to find out what was wrong... :-) Sascha Am Montag, 23. September 2002 02:07 schrieb Justin French: Validate the input BEFORE outputting anything to the browser... this way you have control over such problems. ? // validate // code // here if($valid) { header(...); exit; } ? HTML ? if(!$valid) { echo error on form; } ? /HTML The code below exit; will only be executed if the input was NOT valid Regards, Justin on 23/09/02 9:42 AM, Sascha Braun ([EMAIL PROTECTED]) wrote: Hi, I want to post a form and after parsing i want to redirect the user to the home page. header() doesn't work in this circumstance, what can I do else? Greetings Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Running a PHP script automatically?
On the Linux box compile PHP as CGI (i.e. don't configure it as an apache mod). Then you can just run your script from the the command-line. This is called CLI (Command Line Interface), not CGI (Common Gateway Interface). The CGI is called from an WebServer; CLI get's called from a shell-(script) or any thing. Anyway, this is the most likely way to do this. The PHP Binaries for Windows already ship with a CLI-Version of PHP which lives in the root of your PHP folder. Most Linux Distribution have also one (I'm not using Red Hat), which would usually live in /usr/bin/php ( to find out, type: whereis php). The CLI can fine be scheduled either by a Vixie-Crontab or by a windows scheduler task. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] checking if an array is empty
There are many different states, in which an array would be empty. Can you post the output of a var_dump($array); in that special case you want to check? In general: 1. the variable may not have been set: if (!isset($myarray)) echo 'error'; 2. the variable is set, but ain't an array: if (!isarray($myarray) echo 'error'; 3. the variable is set and is an array, but contains no data: if (array_count($myarray) == 0) echo 'error'; I think the 3rd case could apply to your problem, but only a print_r or var_dump of the $_POST['myarray'] can show this. Sascha Am Samstag, 21. September 2002 17:13 schrieb electroteque: how can i check if an array is currently empty , for instance i have a file input field with an array name for multiple images, i need to check if there was no file uploaded in that field name and ignore it in the loop -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Editor
Newest gvim for windows acts in most cases just like any other editor, too. You can mark text with the mouse, scroll over with the scrollbars etc. etc. It even got a nice menu. This is the best you can get - and it does everything. I even switched from VC++'s IDE to gvim, now ;-) Am Samstag, 21. September 2002 16:16 schrieb Todd Pasley: You can get vi/vim for windows, without a doubt the best editor of all time if you can be bothered learning the commands. Todd. -Original Message- From: Bryan McLemore [mailto:[EMAIL PROTECTED]] Sent: Saturday, 21 September 2002 11:16 PM To: PHP GEN LIST Subject: [PHP] Editor Hi guys, just wondering if anyone could recomend a good editor that is based on windows. Thanks, Bryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] accessing session variables
Just use the session_start() in the second page and they will be magically there where you've put them in the first page. Sascha Am Samstag, 21. September 2002 17:01 schrieb Murat Ö.: hi, page1.php creates a session and its variables in it in successfully. the variables and values are created like $_SESSION['x']='abc' page1.php sends the SID information to page2.php via GET method. how can i access the those variables with SID information in page2.php? thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML 2 TEXT
what he really needs is to completely remove script.../script, plus many many other examples. completely removing everything outside the body would be another option, perhaps saving the contents of title.../title since a script might also occur inside the body, this would not really work out as meant. Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: java in php4 on debian testing distribution?
I sincerely believe that the problem lies in my php installation, not in my java installation, which is why I'm asking whether the debian php4 package in the testing distribution, which is more specifically PHP/4.1.2 according to X-Powered-By in phpinfo(), has java support compiled in, whether I need a particular extension library file (.so), etc. You need the extension either compiled in _OR_ the library. ?php phpinfo(); ? will tell you also, if the extension is loaded. (There must be a 2 column box saying java support and enabled in it's head). Sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Time
You have to add (or subtract) 28800 seconds to/from current time and use this as the 2nd input to date. echo date(Y-m-j, strtotime(now) + 28800); Sascha Hi,, my server is located in the US and i live in Sweden, so when i try to run the following command i get a 8hour diffrence,, anyone got any idea of how to solve this? date(Y-m-j) regards Patrick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SELECT dropdown from a db query?
Change SELECT name=rapped to SELECT name=rapped size=1 Sascha Am Donnerstag, 19. September 2002 03:34 schrieb Andre Dubuc: I'm trying to generate a dropdown SELECT list from a database query. So far, all I've managed to create is multiple one-item dropdowns for each database entry spread across the page. Bad -- very bad! I'd like normal drop-down SELECT behavior, but somehow the code escapes me. I've tried a bunch of permutations, but I either end up with an empty dropdown or multiple single entry messes. Is there anyway to iterate through this and achieve what I want? I would greatly appreciate any hints what I'm missing here or doing wrong. Code follows. Tia, Andre Code (using PostgreSQL): ?php . . . $query = SELECT * FROM rap WHERE rsponsor = '{$_SESSION['sid']}'; $result = pg_exec($db, $query); if (!$result) {exit;} $numrows = pg_numrows($result); if ($numrows == 0) {echo h2Sorry!brbr'{$_POST['sid']}' is not in the our database.brbr Click 'Back' on your browser to enter another search.brbr/h2; exit;} $row = 0; do { $myrow = pg_fetch_array($result,$row); if ($myrow['rupload'] != ) { print SELECT name=rappedoption{$myrow['rfname']} {$myrow['rsname']}/select; } $row++; } while ($row $numrows); pg_close($db); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Friend of function??
Just as Kevin Stone said, you can either use one of these constructions: function func1() { global $myarray; array_push($myarray,1); } # _or_ function func2() { array_push($GLOBALS['myarray'],1); } In fact, there is no performance decrease, because PHP will internally use the same mechanism to access the array - as it would if you were not in a function. Another way would be to pass the array as a reference: function func3($myarray) { array_push($myarray, 1); } but this might decrease performace (in compare to the other ways, you will not really notice it). Sascha Am Mittwoch, 18. September 2002 23:54 schrieb Anup: I want to use arrays (that are outside of a function) to be visible to a function. I understand that I must you global. But I was wondering is it possible to make it visible to only certain functions, similar to the 'friend' keyword in C (or C++ ?) ? The reason, is that I don't feel comfortable having globals, (I was brought up that way). Also, if you actually declare something global are there any disadvantages such as performance hits? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php