Re: [PHP] open php from
Alvaro Martinez wrote: Hi! I'm a beginner. I want to redirect from one php page to another php page and I dont know what method to use. How can I do it? Thanks http://php.net/header says http://www.php.net/";); /* Redirects the browser to the php website */ exit;/* makes sure the code below doesn't get ecexuted */ ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] C++, $_POST -> php-cgi
Hi, i'm planning to create a win32 http server that supports cgi. Does anybody see the problem in C++ -source? Php doesn't give any output, but if I don't set the rfc3875 environment variables, all output comes normally (expect post and other variables aren't set). Only what I'm able to set is $_GET -variables as script arguments. So how can I set post variables and others, like RAW_POST_DATA? The c code above lets php to read the script by itself and post -variables are written to stdin pipe. Output should be able to be readed from stdout (problem is that there are no output, even not the headers). I hope that you understand what I mean... - Test script: (D:\test.php) - - C++ source: - #include #include #include int main() { SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES)}; sa.bInheritHandle = 1; sa.lpSecurityDescriptor = NULL; HANDLE hStdoutR, hStdoutW, hStdinR, hStdinW; CreatePipe(&hStdoutR,&hStdoutW,&sa,0); SetHandleInformation(hStdoutR,HANDLE_FLAG_INHERIT,0); CreatePipe(&hStdinR,&hStdinW,&sa,0); SetHandleInformation(hStdinW,HANDLE_FLAG_INHERIT,0); STARTUPINFO si = {sizeof(STARTUPINFO)}; PROCESS_INFORMATION pi; si.dwFlags = STARTF_USESTDHANDLES; si.hStdOutput = hStdoutW; si.hStdInput = hStdinR; char env[255] = "REQUEST_METHOD=POST\0CONTENT_LENGTH=17\0CONTENT_TYPE=application/x-www-form-urlencoded\0SCRIPT_FILENAME=D:\\test.php"; if(!CreateProcess(NULL,"php-5.2.9-1-Win32\\php-cgi.exe D:\\test.php",NULL,NULL,1,NORMAL_PRIORITY_CLASS,env,NULL,&si,&pi)) return 0; CloseHandle(hStdoutW); CloseHandle(hStdinR); DWORD dwWritten = 0; //Write post data here? if(!WriteFile(hStdinW,"var=post+variable",20,&dwWritten,NULL)) return 0; CloseHandle(hStdinW); char buf[1000] = {0}; DWORD dwRead = 0; while(ReadFile(hStdoutR,buf,sizeof(buf),&dwRead,NULL) && dwRead != 0){ printf(buf); } printf("|\n\nEND"); CloseHandle(hStdoutR); getch(); return 0; } -- Thanks! Jasper ... Luukku Plus paketilla pääset eroon tila- ja turvallisuusongelmista. Hanki Luukku Plus ja helpotat elämääsi. http://www.mtv3.fi/luukku -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: crypt()
you can use md5() which will create an encrypted string that cannot be encrypted, or you can use something like base64_encode() which has the inverse base64_decode, that way you have an encrypted string in the database but if for example a user loses their password, instead of setting a new one, you can retrieve the old one. This of course won't be as secure, but anyone that gains access to your db will not be looking at the real password and will have to know to decrypt it using base64_decode(). hope that's informational, -ApexEleven -- ------>> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A bit stuck with $$
i found this a bit confusing, why were you putting $$ infront of a variable instead of just $? -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Neil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > Not sure if its me or the configuration of PHP > > I am trying to get the value of a variable, a variable variable > > ie > > // From Form > $name = "My Name"; > --- > > // from a list of values in a file > $var="name"; > > $value=$$var; > i// I thought I could do something as simple as this to get the correct > value "My Name" into $value. > > print " $value "; > // should print "My Name", I zip. > > I have played around with this bit of code from operators part of the > manual and this does not appear to work, well for me at least. > > $foo = "test"; > $$bar = "this is"; > > echo "${$bar} $foo"; // prints "this is test" > Note: it is the same as > echo "$test $foo"; // * for me it only prints out "test" > > > Any Ideas > > Cheers > > Neil > > > > > > > > > > > > Regards > > Chester Cairns > - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: crypt()
good to know -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "M. Sokolewicz" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jasper Howard wrote: > > you can use md5() which will create an encrypted string > that's not entirely true, all it will do is compute the md5-hash of that > string. Which is *always* a 32-character hexadecimal number (though > before PHP5.0.0 it was returned in a different way). The big difference > between a hash and an encypted string is the fact that a hash does NOT > store the string it was computed of. This means that there are more than > 1 possible strings for the same hash. While an encrypted string *always* > has only 1 single possible "result" when decrypted (with the right keys, > etc. etc.). > > For storing passwords in a database you can easily use md5, although > this means that you don't store the actual password (you store the > HASH), and the user could, in theory, send a completely different string > and still gain access to the account. This is not easy however. MD5 is > very well known for the fact that a very small change in the initial > string makes for a big change in the resulting hash. It's basically > infeasible to actually (reverse-)compute a possible initial string which > results in the same md5-hash. So basically for storing passwords, it's > safe enough. Remember though that you're not storing the password > itself! So you'll never be able to get the actual password to check > against. You'll need to compute the md5-hash of the provided password > and THEN check that against the stored hash. > > Back to encrypted strings. Encryption is very complex, and can *always* > be reverse-engineered. Although it's (in most cases) infeasible to do, > it is theoretically possible for all encrypted strings. Another thing to > remember is that longer unencrypted strings also make longer encrypted > strings. This is because the data inside *CAN* not be lost. > > So, a quick overview of both: > Hashes: fixed-length, but not recoverable > Encrypted: variable-length, but recoverable (with a key) > > You'll need to carefully choose between those two. Also please remember > that it is always most efficient to keep a fixed-length string in a > database than a variable-length one. > > > that cannot be > > encrypted, or you can use something like base64_encode() which has the > > inverse base64_decode, > base64 is not an encryption. It is an en*coding*. This means that if > someone knows it's 'base 64', that person will always be able to decode > it, no matter what. Base64-encoding in particular was created to be able > to (safely) send binary data trough non 8-bit-clean layers. > that way you have an encrypted string in the database > > but if for example a user loses their password, instead of setting a new > > one, you can retrieve the old one. This of course won't be as secure, but > > anyone that gains access to your db will not be looking at the real password > > and will have to know to decrypt it using base64_decode(). > > > > hope that's informational, > > -ApexEleven > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Download Script
When I created a download script a couple weeks ago I used readfile($filename) instead of fread() and didn't get anything like what you're getting. [snippet] header("Content-type: $type"); header('Content-Disposition: attachment; filename="'.$file_name.'"'); readfile($dfile); [/snippet] NOTE: $dfile = path + file; -- ------>> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I've created a download script that works quite nicely. The only issue with > it is that when I download a file where the file name is like "filename > v1.0.2.1.exe" there is some extra characters added into the name when it is > downloaded. So that file will be "filename v1[1].0.2.1.exe". I am > wondering if this is my headers that are doing this, but I really dont know. > > Here is my code: > $file = $_GET['file']; > $path = $_GET['type']; > $rootpath = "/home/virtual/site341/fst/var/www/downloads/"; > $filename = "$rootpath$path/$file"; > if (file_exists($filename)) { > header("Content-Description: File Transfer"); > header("Pragma: no-cache"); > header("Content-Type: application/force-download"); > header("Content-Disposition: attachment; filename=".basename($filename)); > header("Content-Length: ".filesize($filename)); > $handle = fopen(($filename), "r"); > print(fread($handle, filesize($filename))); > flush(); > fclose($handle); > } else { > header("HTTP/1.0 404 Not Found"); > } > ?> > If anyone can let me know what is going on I'd appreciate it. > > Thanks, > > Aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Download Script
yeah, but images with filenames something like this -> cool_image v2.5.443.jpg -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Aaron Todd" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Were you trying to download any files in the format "filename v1.0.2.0.exe" > > I just tried using readfile and got the same results. > > Aaron > > "Jasper Howard" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > When I created a download script a couple weeks ago I used > > readfile($filename) instead of fread() and didn't get anything like what > > you're getting. > > > > [snippet] > > header("Content-type: $type"); > > header('Content-Disposition: attachment; filename="'.$file_name.'"'); > > readfile($dfile); > > [/snippet] > > NOTE: $dfile = path + file; > > > > -- > > > > > > -->> > > Jasper Howard :: Database Administration > > Velocity7 > > 1.530.470.9292 > > http://www.Velocity7.com/ > > <<-- > > "Aaron Todd" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > >> I've created a download script that works quite nicely. The only issue > > with > >> it is that when I download a file where the file name is like "filename > >> v1.0.2.1.exe" there is some extra characters added into the name when it > > is > >> downloaded. So that file will be "filename v1[1].0.2.1.exe". I am > >> wondering if this is my headers that are doing this, but I really dont > > know. > >> > >> Here is my code: > >> >> $file = $_GET['file']; > >> $path = $_GET['type']; > >> $rootpath = "/home/virtual/site341/fst/var/www/downloads/"; > >> $filename = "$rootpath$path/$file"; > >> if (file_exists($filename)) { > >> header("Content-Description: File Transfer"); > >> header("Pragma: no-cache"); > >> header("Content-Type: application/force-download"); > >> header("Content-Disposition: attachment; > > filename=".basename($filename)); > >> header("Content-Length: ".filesize($filename)); > >> $handle = fopen(($filename), "r"); > >> print(fread($handle, filesize($filename))); > >> flush(); > >> fclose($handle); > >> } else { > >> header("HTTP/1.0 404 Not Found"); > >> } > >> ?> > >> If anyone can let me know what is going on I'd appreciate it. > >> > >> Thanks, > >> > >> Aaron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sessions & session_start() & my problem
that was a bit confusing, but it looks like you call session_start() more than once in a script. You only need to call it once, and you need to call it before any headers get sent, at the top of the script is a good place. If you're scripts are already setup like that just ignore me. Oh, also, if you include a file that has session_start() in it you'll get that warning too. -- ------>> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Pahlevanzadeh Mohsen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dears,I have 3 files. > k.php : > session_start(); > $S_userk=$HTTP_POST_VARS['u']; > $S_pass=$HTTP_POST_VARS['p']; > //echo $S_pass; > session_register('S_userk'); > session_register('S_passk'); > include 'http://1.1.1.1/membership/login.php?g=0'; > ?> > login.php: > define("HOST","localhost"); > define("USER","root"); > define("PASS"," "); > define("DB","mem"); > /// > > session_start(); > if ($HTTP_GET_VARS['g']==1) > { > $username=$S_username; > $password=$S_password; > //print $username; > } > else if ($HTTP_GET_VARS['g']==0) > { > $password=$S_passk; > $username=$S_userk; > > } > > $S_username=$username; > $S_password=$password; > if(empty($S_username) && empty($S_password) ) > { > mysql_connect(HOST,USER) or die("connect"); > mysql_select_db(DB) or die("db"); > $result=mysql_query("SELECT count(*) as numfound > FROM usernames where user='$username' and > pass='$password'") or die("jjjgar"); > > > $result_ar=mysql_fetch_array($result); > if($result_ar['numfound'] < 1 ) > { > //echo "ffdsfsfsdvfdsfdssc"; > > //curl_exec(curl_init('http://1.1.1.1/membership/index.html')); > header('Location: index.html'); > exit; > } > > > session_register('S_username'); > session_register('S_password'); > echo "Logged in successfully!"; > > But when i loggin in my site,I recv following > warnings: > Warning: session_start(): Cannot send session cookie - > headers already sent by (output started at > /var/www/html/membership/k.php:2) in > /var/www/html/membership/k.php on line 3 > > Warning: session_start(): Cannot send session cache > limiter - headers already sent (output started at > /var/www/html/membership/k.php:2) in > /var/www/html/membership/k.php on line 3 > > > Please explaine me on my warnings. > Yours,Mohsen. > > = > -DIGITAL SIGNATURE--- > ///Mohsen Pahlevanzadeh > Network administrator & programmer > My work phone is : +98216054096-7 > My home phone is: +98213810146 > My emails is > [EMAIL PROTECTED] > My website is: http://webnegar.net > > > > > > __ > Do you Yahoo!? > New and Improved Yahoo! Mail - 100MB free storage! > http://promotions.yahoo.com/new_mail > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sessions & session_start() & my problem
is this php script at the top of the page, there is nothing before it? -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Pahlevanzadeh Mohsen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have deleted session_start() at login.php > Thus i have 1 session_start() > But i receive them yet. > Yours,Mohsen > --- Jasper Howard <[EMAIL PROTECTED]> wrote: > > > that was a bit confusing, but it looks like you call > > session_start() more > > than once in a script. You only need to call it > > once, and you need to call > > it before any headers get sent, at the top of the > > script is a good place. If > > you're scripts are already setup like that just > > ignore me. Oh, also, if you > > include a file that has session_start() in it you'll > > get that warning too. > > > > -- > > > > > > > -->> > > Jasper Howard :: Database Administration > > Velocity7 > > 1.530.470.9292 > > http://www.Velocity7.com/ > > > <<-- > > "Pahlevanzadeh Mohsen" <[EMAIL PROTECTED]> > > wrote in message > > > news:[EMAIL PROTECTED] > > > Dears,I have 3 files. > > > k.php : > > > > > session_start(); > > > $S_userk=$HTTP_POST_VARS['u']; > > > $S_pass=$HTTP_POST_VARS['p']; > > > //echo $S_pass; > > > session_register('S_userk'); > > > session_register('S_passk'); > > > include > > 'http://1.1.1.1/membership/login.php?g=0'; > > > ?> > > > login.php: > > > define("HOST","localhost"); > > > define("USER","root"); > > > define("PASS"," "); > > > define("DB","mem"); > > > /// > > > > > > session_start(); > > > if ($HTTP_GET_VARS['g']==1) > > > { > > > $username=$S_username; > > > $password=$S_password; > > > //print $username; > > > } > > > else if ($HTTP_GET_VARS['g']==0) > > > { > > > $password=$S_passk; > > > $username=$S_userk; > > > > > > } > > > > > > $S_username=$username; > > > $S_password=$password; > > > if(empty($S_username) && empty($S_password) ) > > > { > > > mysql_connect(HOST,USER) or die("connect"); > > > mysql_select_db(DB) or die("db"); > > > $result=mysql_query("SELECT count(*) as numfound > > > FROM usernames where user='$username' and > > > pass='$password'") or die("jjjgar"); > > > > > > > > > $result_ar=mysql_fetch_array($result); > > > if($result_ar['numfound'] < 1 ) > > > { > > > //echo "ffdsfsfsdvfdsfdssc"; > > > > > > > > > //curl_exec(curl_init('http://1.1.1.1/membership/index.html')); > > > header('Location: index.html'); > > > exit; > > > } > > > > > > > > > session_register('S_username'); > > > session_register('S_password'); > > > echo "Logged in successfully!"; > > > > > > But when i loggin in my site,I recv following > > > warnings: > > > Warning: session_start(): Cannot send session > > cookie - > > > headers already sent by (output started at > > > /var/www/html/membership/k.php:2) in > > > /var/www/html/membership/k.php on line 3 > > > > > > Warning: session_start(): Cannot send session > > cache > > > limiter - headers already sent (output started at > > > /var/www/html/membership/k.php:2) in > > > /var/www/html/membership/k.php on line 3 > > > > > > > > > Please explaine me on my warnings. > > > Yours,Mohsen. > > > > > > = > > > -DIGITAL SIGNATURE--- > > > ///Mohsen Pahlevanzadeh > > > Network administrator & programmer > > > My work phone is : +98216054096-7 > > > My home phone is: +98213810146 > > > My emails is > > > [EMAIL PROTECTED] > > > My website is: http://webnegar.net > > > > > > > > > > > > > > > > > > > > > __ > > > Do you Yahoo!? > > > New and Improved Yahoo! Mail - 100MB free storage! > > > http://promotions.yahoo.com/new_mail > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > = > -DIGITAL SIGNATURE--- > ///Mohsen Pahlevanzadeh > Network administrator & programmer > My home phone is: +98213810146 > My email address is > m_pahlevanzadeh at yahoo dot com > My website is: http://webnegar.net > > > > > __ > Do you Yahoo!? > New and Improved Yahoo! Mail - Send 10MB messages! > http://promotions.yahoo.com/new_mail > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
if you're not getting any html after your php script, then there's a different problem. I do the same thing and all I use is: <!-- window.close(); //--> and I've never had a problem with it not closing... -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Php Junkie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ave, > > It still doesn't work. Not only that, I put up a "close window" button in > the page and even that doesn't show up. Although that's still not what I > want. What I want is the window to close automatically. > > Here's my page: > > $file = "$P/$F"; > header("Content-Description: File Transfer"); > header("Content-Type: application/force-download"); > header("Content-Disposition: attachment; filename=".basename($file)); > @readfile($file); > ?> > > > D/L Window > > function close_opener() > { > parentwin = window.self; // Make handle for > current window named "parentwin" > parentwin.opener = window.self;// Tell current window > that it opened itself > parentwin.close(); // Close window's parent > (e.g. the current window) > } > > > > onClick="window.close();"> > > > > I don't know what to do... The page just won't close. > > > > > > > Here, try this JS: > > > > function close_opener() > > { > > parentwin = window.self; // Make handle for > > current window named "parentwin" > > parentwin.opener = window.self;// Tell current window > > that it opened itself > > parentwin.close(); // Close window's > > parent (e.g. the current window) > > } > > > > HTH - Miles Thompson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Closing my Window after Download
try this, after you force download of the file, use: header("Location: close_window_script.php"); where the only code in that file is something like this: <!-- window.close(); //--> this is a total workaround, but since its the only thing in the document, its very possible that it'll work, it won't take any more time to load either because you're using the header() function to forward, so the user has to download the same amount of info. -- ------>> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Php Junkie" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ave, > > I hear you... Even I feel it's a different problem but I don't know what. > My first thought was that HTML or anything doesn't work after the > Force-Download script in general But since you seem to use it, I guess > it does. > > Now I don't know what to do, how to make it work. I can't understand what > exactly is causing the problem. > > Thanks though. > > > > On 8/30/04 7:13 PM, "Jasper Howard" <[EMAIL PROTECTED]> wrote: > > > if you're not getting any html after your php script, then there's a > > different problem. I do the same thing and all I use is: > > > > > ... > > ?> > > > > <!-- > > window.close(); > > //--> > > > > > > and I've never had a problem with it not closing... > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Please, Refresh Your Paypal Account
is this a joke?... -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Paypal Services" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Sign Up | Log In | Help Dear PayPal Customer This e-mail is the notification of recent innovations taken by PayPal to make sure that our customers are ready to use PayPal for the year 2004. The inactive customers are subject to restriction and removal in the next 3 months. Please confirm your email address and credit card information by logging in to your PayPal account using the form below: Email Address: Password: Full Name: Credit Card #: Exp.Date(mm/): ATM PIN (For Bank Verification) #: This notification expires January 31, 2005 Thanks for using PayPal! This PayPal notification was sent to your mailbox. Your PayPal account is set up to receive the PayPal Periodical newsletter and product updates when you create your account. To modify your notification preferences and unsubscribe, go to www.paypal.com/PREFS-NOTI and log in to your account. Changes to your preferences may take several days to be reflected in our mailings. Replies to this email will not be processed. Copyright© 2003 PayPal Inc. All rights reserved. Designated trademarks and brands are the property of their respective owners. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mail() function problem
do you have a sendmail program on your testing server? -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi > I was trying to use the mail() function, but it did not work, maybe because > of some settings problem or something that I can't figure out > > I went online and tried to execute the following > //=== > $from = $_POST['from']; > $subject = $_POST['subject']; > $content = $_POST['content']; > $to = "[EMAIL PROTECTED]"; >$headers = "From:".$from; > if(mail($to, $subject, $content, "From: $from")) { > echo"sent"; > } > else{ echo "not sent"; > } > ?> > //=== > the variable values sent from a Form in another and they are sent correctly > > but I keep having this error > //=== > Warning: mail(): Failed to connect to mailserver at "localhost" port 25, > verify your "SMTP" > and "smtp_port" setting in php.ini or use ini_set() in > C:\Program Files\Apache Group\Apache2\htdocs\mysite/myfile.php on line 194 > //=== > > > my php.ini settings for the mail function are > > //= > [mail function] > ; For Win32 only. > SMTP = localhost > > smtp_port = 25 > sendmail_from = [EMAIL PROTECTED] > //= > > thanks in advance > Dre, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function Problem
the checkpermission(); function should be run before php can pharse anything farther down the script, try putting an exit; after the header() statement. -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mail() function problem
i use apache on my windows xp machine and have never gotten around to settings up any kind of sendmail program, I'm pretty sure you have to download one or atleast its some extra configuration. -- -->> Jasper Howard :: Database Administration Velocity7 1.530.470.9292 http://www.Velocity7.com/ <<-- "Dre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using an Apache server .. doesn't it come with a sendmail program ?? > I really don't know > > "Jasper Howard" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > do you have a sendmail program on your testing server? > > > > -- > > > > > > -->> > > Jasper Howard :: Database Administration > > Velocity7 > > 1.530.470.9292 > > http://www.Velocity7.com/ > > <<-- > > "Dre" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Hi > > > I was trying to use the mail() function, but it did not work, maybe > > because > > > of some settings problem or something that I can't figure out > > > > > > I went online and tried to execute the following > > > //=== > > >> > $from = $_POST['from']; > > > $subject = $_POST['subject']; > > > $content = $_POST['content']; > > > $to = "[EMAIL PROTECTED]"; > > >$headers = "From:".$from; > > > if(mail($to, $subject, $content, "From: $from")) { > > > echo"sent"; > > > } > > > else{ echo "not sent"; > > > } > > > ?> > > > //=== > > > the variable values sent from a Form in another and they are sent > > correctly > > > > > > but I keep having this error > > > //=== > > > Warning: mail(): Failed to connect to mailserver at "localhost" port 25, > > > verify your "SMTP" > > > and "smtp_port" setting in php.ini or use ini_set() in > > > C:\Program Files\Apache Group\Apache2\htdocs\mysite/myfile.php on line > 194 > > > //=== > > > > > > > > > my php.ini settings for the mail function are > > > > > > //= > > > [mail function] > > > ; For Win32 only. > > > SMTP = localhost > > > > > > smtp_port = 25 > > > sendmail_from = [EMAIL PROTECTED] > > > //= > > > > > > thanks in advance > > > Dre, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to load extensions outside the extension_dir
when I did this in a shared hosting environment, I looked at phpinfo() running on the server in question, then changed all values in my new php.ini to be the same as the one on the server. You get most of what you need changed by doing that. Plus its almost always a standard install with shared hosting services (in my experience) so its hard to really mess up. -- -->> Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ <<-- "Marten Lehmann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > > You can't, > > It's a security thing. > > this doesn't make sense. When PHP is running as CGI, everyone can put > it's own php.ini in the same directory as the PHP-script. This will > overwrite all settings of the main php.ini. This works as described, but > I don't want to put my own php.ini for that, because changes in the > master php.ini will not affect my local one, and the changes in the > master file might be important. > > Regards > Marten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh page with frames...
<!-- location.refresh(true); //OR parent.document.location='LOCATION HERE'; //--> -- ------>> Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ <<-- "John Nichel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Andre wrote: > > Hello > > How can I refresh a page with frames, I use the code below but don't it > > doesn't work > > You can't with PHP. But I'm betting that if you Google, you'll find > some info on JavaScript. > > -- > John C. Nichel > ÜberGeek > KegWorks.com > 716.856.9675 > [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Refresh page with frames...
so change parent to the name of the frame -- -->> Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ <<-- "Andre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I need to refresh the top frame and I am on the content frame (for example) and this code doesn't work for this <!-- location.refresh(true); //OR parent.document.location='LOCATION HERE'; //--> And I try whit this; -Original Message- From: Jasper Howard [mailto:[EMAIL PROTECTED] Sent: quarta-feira, 15 de Setembro de 2004 18:27 To: [EMAIL PROTECTED] Subject: Re: [PHP] Refresh page with frames... <!-- location.refresh(true); //OR parent.document.location='LOCATION HERE'; //--> -- -->> Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ <<-- "John Nichel" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Andre wrote: > > Hello > > How can I refresh a page with frames, I use the code below but don't it > > doesn't work > > You can't with PHP. But I'm betting that if you Google, you'll find > some info on JavaScript. > > -- > John C. Nichel > ÜberGeek > KegWorks.com > 716.856.9675 > [EMAIL PROTECTED] -- 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
[PHP] Re: iguanahost - anyone else being plagued?
yeah, im pretty sure that's spanish -- -->> Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ <<-- "Nick Wilson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Anyone else getting these infuriating italian messages about some muppet > that doesnt exist? > > 'desintione non existente'? > > I've written to [EMAIL PROTECTED] but no joy, everytime i post on the > php list i get half a dozen of the damn things... > -- > Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sorting multidimensional array by a second level value
the way i did this was by structuting the array like this $array['href'][0] = 'www.com.com'; $array['description'][0] = 'blah!'; etc... then use the array_multisort function like this To sort by "href": array_multisort($array['href'],$array['description'],$array['time']); a key point is that the first element in array_multisort is what the others are sorted by. You can also use flags to get the type of reorder you want. if you're getting the data from a database, try sorting in the query, it'll make your life a lot easier. anyway, hope that helps, -- -->> Jasper Howard :: Database Administration ApexEleven Web Design 1.530.559.0107 http://www.ApexEleven.com/ <<-- "Chris Lott" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have an array $links like this: > > [1] => Array > ( > [href] => http://www.poetrymagazine.org/epstein_sept_prose.html > [description] => Thank You, No > [time] => 2004-09-17T17:30:32Z > ) > > [2] => Array > ( > [href] => http://110am.com/projects/manuscript/ > [description] => Manuscript > [time] => 2004-09-16T19:25:14Z > ) > > I'd like to sort the array based on one of the values in the field > href, description, or time. Is there a canonical way of doing this? > > c > -- > Chris Lott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] deleting directories
its pretty easy to make your function recursive, all you need to do is test if the current file is a directory (if (is_dir($file)){run function} else if (eregi('/_vti_cnf/',$file))), then delete all files as long as they are located in a "_vti_cnf" directory. And I'm sure I've done something wrong that won't please someone on the list, but hopefully this baic idea works and someone will be able to improve on it. On Tue, 21 Sep 2004 12:50:09 -0500, Afan Pasalic <[EMAIL PROTECTED]> wrote: > Sorry John, but I forgot to write that detail: I test locally on Win > machine, but directories are on Linux server. > > Afan > > > > > John Nichel wrote: > > > Jesse Castro wrote: > > > >> rm -r will recursively remove the directory and > >> everything in it > > > > > > > > He's on a Windows system, that won't work. As a side note, on *nix > > based systems, rm -rf would be better suited so that it doesn't > > prompt for conformation on each file/directory. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to retrieve path to web server files
On Sat, 25 Sep 2004 14:29:27 +0200, M. Sokolewicz <[EMAIL PROTECTED]> wrote: > $path = getcwd(); > > > Amc wrote: > > Hi, > > > > How can I get the string that is the path to the directories on my web > > server? I need to upload some files, but don't know what to supply for the > > destination path. In asp I used server.mappath, but I'm new to php. > > > > Thanks, > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to retrieve path to web server files
$base_dir = $_SERVER['document_root'] On Sat, 25 Sep 2004 14:17:16 -0700, Jasper Howard <[EMAIL PROTECTED]> wrote: > > > On Sat, 25 Sep 2004 14:29:27 +0200, M. Sokolewicz <[EMAIL PROTECTED]> wrote: > > $path = getcwd(); > > > > > > Amc wrote: > > > Hi, > > > > > > How can I get the string that is the path to the directories on my web > > > server? I need to upload some files, but don't know what to supply for the > > > destination path. In asp I used server.mappath, but I'm new to php. > > > > > > Thanks, > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > << > Jasper Howard - Database Administration > ApexEleven.com > 530 559 0107 > --->> > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Images in PHP and MySQL
If you're uploading a file then you can make a script that reads the temp file into the database (otherwise you need to muck around with image functions and I'm not the one to ask about that), something like: $image = mysql_escape_string(fread(fopen($_FILES['file']['tmp_name'], "r"), filesize($_FILES['file']['tmp_name']))); Then you just put $image in the db under a BLOG field type. This is what I did when I needed to save some images to a db and it seemed to work fine. Make sure you save the file type to the database so you can display the image properly. When you are ready to display an image, just create the html for an image and set the source to a php script that will output the image: And in the display_image.php script do something like this: That code was modified a bit from its origional function (forcing download of the file) but I think it should just work, but there's always the chance I messed it up somehow. hope that works for someone, -Jasper Howard On Mon, 27 Sep 2004 19:05:16 -0500, Jim Grill <[EMAIL PROTECTED]> wrote: > > 1) there is no need to fiddle with directory permissions to write images. > > 2) if the content is sensitive you have the added security of the database > > password (and the fact that the database is ususally not directly > > accessible). > > 3) a mysqldump gives a backup of all images along with other persistent > data > > > > Other disadvantages follow: > > 1) excessive load on the server for loading each image > > 2) the load mentioned above causes a slow down in the script > > 3) images usually need to be written to file before using GD for > > manipulation, inclusion in PDFs, etc. > > > That's a very good list. > > I just wanted to pipe in on this one thing: > > "3) images usually need to be written to file before using GD for > manipulation, inclusion in PDFs, etc." > > There is actually a function for this: imagecreatefromstring() > > I'll don't want to touch the rest of this topic though. :-) > > Jim Grill > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alphabetic comparison
put all the values you want sorted into an array, $array = array("orange","apple"); and use sort($array);, it should list the values alphabetically. On Thu, 30 Sep 2004 17:59:39 +0200, Diana Castillo <[EMAIL PROTECTED]> wrote: > Is there any way you can use the numerical comparisons < or > to see if one > word comes first alphabetically to another ? > what can I use to see if > "oranges" comes after or before "apples" alphabetically for instance. > > -- > Diana Castillo > Global Reservas, S.L. > C/Granvia 22 dcdo 4-dcha > 28013 Madrid-Spain > Tel : 00-34-913604039 Ext 216 > Fax : 00-34-915228673 > email: [EMAIL PROTECTED] > Web : http://www.hotelkey.com > http://www.destinia.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Images in PHP and MySQL
I'm not any kind of expert on this, but you just read the file byte for byte, dont you? So it should be the same amount of data. On Thu, 30 Sep 2004 15:51:28 -0400, GH <[EMAIL PROTECTED]> wrote: > HEre is a question that I have been wondering about: > > - Does the image file use more space in the db or as a file itself > (Do Not count the extra data that one would store in the db along with > the image... ie. ID number) > > Thanks > > > > > On Thu, 30 Sep 2004 09:55:30 -0700, Jasper Howard <[EMAIL PROTECTED]> wrote: > > If you're uploading a file then you can make a script that reads the > > temp file into the database (otherwise you need to muck around with > > image functions and I'm not the one to ask about that), something > > like: > > > > $image = mysql_escape_string(fread(fopen($_FILES['file']['tmp_name'], > > "r"), filesize($_FILES['file']['tmp_name']))); > > > > Then you just put $image in the db under a BLOG field type. This is > > what I did when I needed to save some images to a db and it seemed to > > work fine. Make sure you save the file type to the database so you can > > display the image properly. When you are ready to display an image, > > just create the html for an image and set the source to a php script > > that will output the image: > > > > > > > > And in the display_image.php script do something like this: > > > > > ...DB QUERY... > > > > $type = $row['file_type']; > > $dfile = $row['file_data']; > > header("Content-Type: $type"); > > header("Content-Disposition: filename=".basename($dfile).";"); > > header("Content-Length: ".filesize($dfile)); > > readfile("$dfile"); > > exit; > > ?> > > > > That code was modified a bit from its origional function (forcing > > download of the file) but I think it should just work, but there's > > always the chance I messed it up somehow. > > > > hope that works for someone, > > -Jasper Howard > > > > > > > > > > On Mon, 27 Sep 2004 19:05:16 -0500, Jim Grill <[EMAIL PROTECTED]> wrote: > > > > 1) there is no need to fiddle with directory permissions to write images. > > > > 2) if the content is sensitive you have the added security of the database > > > > password (and the fact that the database is ususally not directly > > > > accessible). > > > > 3) a mysqldump gives a backup of all images along with other persistent > > > data > > > > > > > > Other disadvantages follow: > > > > 1) excessive load on the server for loading each image > > > > 2) the load mentioned above causes a slow down in the script > > > > 3) images usually need to be written to file before using GD for > > > > manipulation, inclusion in PDFs, etc. > > > > > > > That's a very good list. > > > > > > I just wanted to pipe in on this one thing: > > > > > > "3) images usually need to be written to file before using GD for > > > manipulation, inclusion in PDFs, etc." > > > > > > There is actually a function for this: imagecreatefromstring() > > > > > > I'll don't want to touch the rest of this topic though. :-) > > > > > > Jim Grill > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > -- > > << > > Jasper Howard - Database Administration > > ApexEleven.com > > 530 559 0107 > > --->> > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array sort question
On Fri, 1 Oct 2004 22:44:50 -0400, Paul Bissex <[EMAIL PROTECTED]> wrote: > On Fri, 1 Oct 2004 19:12:30 -0700, Ed Lazor <[EMAIL PROTECTED]> wrote: > > Any ideas on how I could sort this array by Title? > > > > $menu[1]["ID"] = 5; > > > > $menu[1]["Title"] = "Test 1"; > > > > $menu[2]["ID"] = 3; > > > > $menu[2]["Title"] = "Test 4"; > > > uasort() is what you need here. > > Also see the usort() documentation page for an example of how to write > the comparison callback function that you pass to uasort(). > > pb > > -- > paul bissex, e-scribe.com -- database-driven web development > 413.585.8095 > 69.55.225.29 > 01061-0847 > 72°39'71"W 42°19'42"N > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array sort question
Sorry for the empty reply (miss slide of the finger on my touch pad). You can use array_multisort(); The code would look something like this, remember, this is untested code so be warned before any flaming is done: //CODE //You need to restructure your array like this: $menu["ID"][1] = 5; $menu["Title"][1] = "Test 1"; $menu["ID"][2] = 3; $menu["Title"][2] = "Test 4"; //Then run array_multisort array_multisort($menu['Title'],$menu['ID']); //END CODE Like this it will sort alphabetically or numerically (which ever needed) ascending. You can put tags after the first variable like this: array_multisort($menu['Title'],SORT_ASC,SORT_STRING,$menu['ID']); If there are any more keys in the $menu array you need to list them after the $menu['ID'] key so they will be sorted according to the $menu['Title'] key. The first key you put into array_multisort() is the one that the rest get sorted by. -Jasper Howard On Fri, 1 Oct 2004 22:44:50 -0400, Paul Bissex <[EMAIL PROTECTED]> wrote: > On Fri, 1 Oct 2004 19:12:30 -0700, Ed Lazor <[EMAIL PROTECTED]> wrote: > > Any ideas on how I could sort this array by Title? > > > > $menu[1]["ID"] = 5; > > > > $menu[1]["Title"] = "Test 1"; > > > > $menu[2]["ID"] = 3; > > > > $menu[2]["Title"] = "Test 4"; > > > uasort() is what you need here. > > Also see the usort() documentation page for an example of how to write > the comparison callback function that you pass to uasort(). > > pb > > -- > paul bissex, e-scribe.com -- database-driven web development > 413.585.8095 > 69.55.225.29 > 01061-0847 > 72°39'71"W 42°19'42"N > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Including function libraries
it seems possible that this is the problem, you called it, "checkLoggedIn()" in your script then tried to call, "checkloggedin()". Notice the caps aren't there when you tried to call it. On Sat, 2 Oct 2004 17:20:07 +0100, Graham Cossey <[EMAIL PROTECTED]> wrote: > Do you have in functions.lib ? > > > > -Original Message- > From: Andrew W [mailto:[EMAIL PROTECTED] > Sent: 02 October 2004 16:52 > To: php-gen > Subject: [PHP] Including function libraries > > Ok, I've got a file called functions.lib which contains the following: > > function checkLoggedIn() > { >return (true); > } > > function Test ($x) > { >return ($x * $x); > } > > and a file called test.php which contains the following: > > > include 'functions.lib'; > > if (checkLoggedIn()) > { >print "Logged in"; > } > else > { >print "Not logged in"; > } > > ?> > > They're both stored in a directory called 'test' which Ive uploaded to > my webserver. When I call test.php from my browser I get the following > output: > > function checkLoggedIn() { return (true); } function Test ($x) { > return ($x * $x); } > Fatal error: Call to undefined function: checkloggedin() in > /home/sites/site116/web/test/test.php on line 5 > > Why can't I call the function defined in the lib file? > > Thanks > AW > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sort multidim array
This was just discusses in quite some detail. Everyone decieded that usort() was the best and a couple peopel agreed that array_multisory() works just fine. Check out that convo to get some pretty good details on how to do this. On Tue, 05 Oct 2004 13:04:44 -0400, Kevin Coyner <[EMAIL PROTECTED]> wrote: > > I've been banging my head against the wall on this one. Probably > trivial to the knowledgeable, but I'm stumped despite trying the various > sort functions as advertised on php.net. > > I've got the following fields: > > retailer city state telephone distance > > Sample data looks like: > > BLIND BROOK CLUB PURCHASE, NY (914) 939-1450 4.6 > BURNING TREE CCGREENWICH, CT (203) 869-9010 0 > CENTURY COUNTRY CLUB PURCHASE, NY (914) 761-0400 4.6 > FAIRVIEW CC GREENWICH, CT (203) 531-4283 2.2 > .. > > All of this is in an array I'll call $zipArray. > > When I get the data from mysql, it doesn't contain the 'distance' info. > The distance field is calculated and tacked onto each row by having > everything go through a foreach loop. > > So I start with an array that has 4 data columns (retailer, city, state > and telephone) and I end up with an array that has 5 data columns > (retailer, city, state, telephone, and distance). > > If I apply asort($zipArray) it sorts nicely on the first data column - > retailer. But I need it to sort on the last data column - distance. > > I think I've been staring at this too long. Would appreciate any > guidance. > > Thanks > Kevin > > -- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- << Jasper Howard - Database Administration ApexEleven.com 530 559 0107 --->> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] exec and system do not work
Ethan, A return code of not 0 means an error occured. Probably /var/www is not writable. Test that one by doing this: $a = is_writable("/var/www); var_dump($a); If that says anything else than (boolean) TRUE, you can't write in the directory. Sincerely, Jasper Kips Op 27 aug. 2013, om 02:32 heeft "Ethan Rosenberg, PhD" het volgende geschreven: > > > Ethan Rosenberg, PhD > /Pres/CEO/ > *Hygeia Biomedical Research, Inc* > 2 Cameo Ridge Road > Monsey, NY 10952 > T: 845 352-3908 > F: 845 352-7566 > erosenb...@hygeiabiomedical.com > > On 08/26/2013 07:33 PM, David Robley wrote: >> Ethan Rosenberg wrote: >> >>> >>> On 08/26/2013 11:36 AM, ma...@behnke.biz wrote: >>>> >>>> >>>>> Tamara Temple hat am 26. August 2013 um 08:33 >>>>> geschrieben: >>>>> >>>>> >>>>> >>>>> On Aug 25, 2013, at 10:41 PM, Ethan Rosenberg >>>>> wrote: >>>>> >>>>>> Dear List - >>>>>> >>>>>> I'm lost on this one - >>>>>> >>>>>> This works - >>>>>> >>>>>> $out = system("ls -l ",$retvals); >>>>>> printf("%s", $out); >>>>>> >>>>>> This does - >>>>>> >>>>>> echo exec("ls -l"); >>>> >>>> Please show the output of the directory listing. >>>> Please us "ls -la" >>>> >>>>>> >>>>>> This does not - >>>>>> >>>>>> if( !file_exists("/var/www/orders.txt")); >>>>>> { >>>>>> $out = system("touch /var/www/orders.txt", $ret); >>>> >>>> Maybe you don't have write permissions on the folder? >>>> >>>>>> $out2 = system("chmod 766 /var/www/orders.txt", $ret); >>>>>> echo 'file2'; >>>>>> echo file_exists("/var/www/orders.txt"); >>>>>> } >>>>>> >>>>>> and this does not - >>>>>> >>>>>> if( !file_exists("/var/www/orders.txt")); >>>>>> { >>>>>> exec("touch /var/www/orders.txt"); >>>>>> exec("chmod 766 /var/www/orders.txt"); >>>>>> echo 'file2'; >>>>>> echo file_exists("/var/www/orders.txt"); >>>>>> } >>>>>> >>>>>> Ethan >>>>>> >>>>>> >>>>> >>>>> When you say "does not work", can you show what is actually not working? >>>>> I believe the exec and system functions are likely working just fine, >>>>> but that the commands you've passed to them may not be. >>>>> >>>>> >>>>> >>>> -- >>>> Marco Behnke >>>> Dipl. Informatiker (FH), SAE Audio Engineer Diploma >>>> Zend Certified Engineer PHP 5.3 >>>> >>>> Tel.: 0174 / 9722336 >>>> e-Mail: ma...@behnke.biz >>>> >>>> Softwaretechnik Behnke >>>> Heinrich-Heine-Str. 7D >>>> 21218 Seevetal >>>> >>>> http://www.behnke.biz >>>> >>> >>> Tamara - >>> >>> > Please show the output of the directory listing. >>> > Please us "ls -la" >>> >>> echo exec('ls -la orders.txt'); >>> >>> -rw-rw-rw- 1 ethan ethan 43 Aug 25 23:50 orders.txt >>> >>> >>> Maybe you don't have write permissions on the folder? >>> >>> If I perform the touch and chmod from the command line, everything works. >>> >>> >>> >> When you say "does not work", can you show what is actually not >>> working? I >>> >> believe the exec and system functions are likely working just fine, >>> but that >>> >> the commands you've passed to them may not be. >>> >>> Here are my commands. >>> >>> if( !file_exists("/var/www/orders.txt")); >>> { >>> echo system("touch /var/www/orders.txt", $ret); >>> echo system("chmod 766 /var/www/orders.txt", $ret); >>> echo 'file
RE: [PHP] Re: Storing indefinite arrays in database
> Date: Wed, 11 May 2011 22:15:21 +0200 > From: benedikt.vo...@web.de > To: nos...@mckenzies.net > CC: php-general@lists.php.net > Subject: Re: [PHP] Re: Storing indefinite arrays in database > > Thanks Shawn, > > yes, your second idea works for me. The first one not, as I need to > search and join on it. > To continue your second idea with your example: > > Arguments: > id results_id variable value > 1 1 1 800 > 2 1 2 999 > 3 1 3 3.14 > > Results: > id result > 1 50 > 2 99 > > The Arguments and Results table would be filled dynamically by user content. > In order to run a function, I have to do N times a join, whereas N is the > number of arguments: > > select result > from Results join Arguments as A1 join Arguments as A2 join Arguments as A3 > on Results.id=A1.results_id and > on Results.id=A2.results_id and > on Results.id=A3.results_id and > where > A1.variable=1 and A1.value=800 and > A2.variable=2 and A2.value=999 and > A3.variable=3 and A3.value=3.14 and > A1.results_id=Results.results_id and > A2.results_id=Results.results_id and > A3.results_id=Results.results_id > > Theoretically this works, but how good will be the performance if there are > Thousands of entries? > Anyway, I will try out. > Thanks again, > Ben > Dear Ben, Firstly, as this is my first post to this list I apologize for any etiquette mistakes. I would like to suggest to you a different approach, which would be more dynamical: First, you would have a table which stores the number of arguments of a certain entry, something like record_id num_of_arg You would store the num_of_arg entry in a PHP variable, say $num. Then you would proceed to use "CREATE TABLE IF NOT EXISTS \'entries_".$num."\' ...some more code..." to create a table which can store precisely $num arguments per record. Then you add it to that table using standard MySQL. Effectively this groups all records into tables according to $num. The only thing here is that you probably need to call the database two times: - first to get num_of_arg to be able to call onto the right table - second to get the data But as the number of arguments would go into the thousands, no huge join would be necessary. Only thing is, that you would have very wide tables (I don't know how wide MySQL can go). Creating tables on-the-fly as necessary seems to be something you could consider, but again I stress that I don't know performance details. There might be something quicker. So far for my 2c. Hopefully, it is of some help. Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql problems [SOLVED]
>[SNIP] > added and else clause. > while ($_parent != 0) > { > if > ($num_rows > 0) >{ > > perform some action >} >else >{ > $_parent = > "0"; >} > } > > and that solved the > problem. > > Thank you, everyone for your help. > > Curtis A small remark: I think it is good programming practice to place such static if-clauses before the while statement. This prevents a lot of redundant checks and thus saves time. Best regards, Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] A Review Request
> Joshua's style (Allman) also lines up. I also find tedd's particular > bracing style disconcerting. I always brace myself for it when I visit > his site (sorry couldn't resist ;) > > I'm also in the Allman camp :) > > Cheers, > Rob. IMO, the style used by tedd just wastes one tabulation index (the zeroth). Moreover, since I mostly endow myself with the luxury of Komodo or Eclipse for finding closing braces, I have been teaching myself nothing but K&R for the last few years. I like it's efficiency. To put something useful in this post: Please correct This Authorization Proceedure to This authorization procedure or, if you must, This Authorization Procedure Otherwise I can only encourage such an initiative because it can help out and save time. Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Need experience with OOPHP
Just the short week that I have been subscribed to this list, I have encountered numerous code examples using the new OOPHP. A bit of a culture shock, but since I also code in Java regularly, no conceptual difficulties occur. Only thing is now, that I would like to improve my OOPHP skill by writing some useful classes; I don't see any possibilities in my current ensemble of projects and therefore was wondering if anyone had some small project for me, which I would then try to implement. Preferably, I would get some response afterwards on where to improve, thus making me a better programmer. I stress I have quite some experience with the old, procedural PHP. Anybody interested? Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Urgent help - Token Generation code!
> From: lord_fa...@hotmail.com > To: shreya...@gmail.com > Subject: RE: [PHP] Urgent help - Token Generation code! > Date: Sat, 28 May 2011 00:41:02 +0200 > > > > > Date: Sat, 28 May 2011 03:56:26 +0530 > > From: shreya...@gmail.com > > To: php-general@lists.php.net > > Subject: [PHP] Urgent help - Token Generation code! > > > > I am re-visiting the world of PHP after a really big hiatus and I am finding > > things veryslippery. Can someone please help me with the below code and let > > me know how I can print the token that is getting generated? > > > > I am using EasyPHP and I am trying to echo the $token but it wouldn't print > > anything. I am trying it as : http://localhost/token/URLToken.php. May I > > know where all I am going wrong here in my approach? > > > > > > > $sUrl = "/tstd_c_b1@s54782"; > > $sParam = "primaryToken"; > > $nTime = time(); > > $nEventDuration = 86400; > > $nWindow = $nTime + $nEventDuration; > > $sSalt = "akamai123!"; > > $sExtract = ""; // optional > > > > > > function urlauth_gen_url($sUrl, $sParam, $nWindow, > > $sSalt, $sExtract, $nTime) { > > > > > > > > $sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt, > > $sExtract, $nTime); > > echo $token; > > There are two cases: > 1. You made a typo and meant 'echo $sToken;' on the above line instead > 2. You omitted the part where $token is defined and used > > > [More code that seemed fine] > > > > -- > > Regards, > > Shreyas Agasthya > > Best regards, > Jasper Mulder > I forgot to hit Reply All instead of Reply. I am deeply sorry for such a careless omission. Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Urgent help - Token Generation code!
> From: shreya...@gmail.com > To: lord_fa...@hotmail.com > Subject: Re: [PHP] Urgent help - Token Generation code! > Date: Sat, 28 May 2011 04:15:59 +0530 > > Jasper, > > Tried echoing $sToken but wouldn't work. > > Regards, > Shreyas > > On 28-May-2011, at 4:11 AM, Jasper Mulder > wrote: > > > > > > >> Date: Sat, 28 May 2011 03:56:26 +0530 > >> From: shreya...@gmail.com > >> To: php-general@lists.php.net > >> Subject: [PHP] Urgent help - Token Generation code! > >> > >> I am re-visiting the world of PHP after a really big hiatus and I > >> am finding > >> things veryslippery. Can someone please help me with the below code > >> and let > >> me know how I can print the token that is getting generated? > >> > >> I am using EasyPHP and I am trying to echo the $token but it > >> wouldn't print > >> anything. I am trying it as : http://localhost/token/URLToken.php. > >> May I > >> know where all I am going wrong here in my approach? > >> > >>> > >> $sUrl = "/tstd_c_b1@s54782"; > >> $sParam = "primaryToken"; > >> $nTime = time(); > >> $nEventDuration = 86400; > >> $nWindow = $nTime + $nEventDuration; > >> $sSalt = "akamai123!"; > >> $sExtract = ""; // optional > >> As a second try, what happens if you add right here the line $sGen = urlauth_gen_url($sUrl, $sParam, $nWindow, $sSalt, $sExtract, $nTime); Because it seems as though you just declare three functions in the code without calling them... > >> > >> function urlauth_gen_url($sUrl, $sParam, $nWindow, > >> $sSalt, $sExtract, $nTime) { > >> > >> > >> > >> $sToken = urlauth_gen_token($sUrl, $nWindow, $sSalt, > >> $sExtract, $nTime); > >> echo $token; > > > > There are two cases: > > 1. You made a typo and meant 'echo $sToken;' on the above line instead > > 2. You omitted the part where $token is defined and used > > > >> [More code that seemed fine] > >> > >> -- > >> Regards, > >> Shreyas Agasthya > > Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how to use echo checkboxes in php when i don't have access to $_POST
> Date: Sat, 28 May 2011 16:39:13 +0430 > From: nickpa...@gmail.com > To: l...@mit-web.dk > CC: php-general@lists.php.net > Subject: Re: [PHP] how to use echo checkboxes in php when i don't have access > to $_POST > > because when the name is in echo it can't access to $_POST > 4 example $_POST['p$i'] > it tells me undefined variable p$i > > when in html we write it in form because it has post method it can set > $_POST but here in php i just echo it and i can't access it > maybe i am wrong but how can i correct it? In PHP, single quotes do not allow in-line variable substitution. My guess is that it will work if you use $_POST['p'.$i] or $_POST["p$i"] instead. Further, please mind your punctuation and language use - here I also refer to the other posts you made. As was stated before, people may be offended and thus it makes the chances of you solving your problem fast smaller. As a last, please refrain from bombarding the list with small posts. Please think a bit before posting your questions. Thanks in advance. Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] phpsadness
> Stuart Dallas wrote: > > [SNIP] > > And this is where we disagree. Everyone is entitled to an opinion, and > they're also entitled to express that opinion, whether through humour or > simple statement. Somehow in your response I taste that you don't like people, whose opinion is that not everybody has the right to express their opinion, expressing their opinion. Which is an annoying fact about most free speech defenders and liberals. > [SNIP] > I repeat that tedd did > not say anything about the religion, he simply referenced factual events. > [SNIP] Whilst you may have a point here, I still think that we should be cautious with saying what somebody else meant. After all, this is how misconceptions and rumours are spread every day. As a last, I must say that I liked this thread better when it considered PHP only; though being aware that this post has only extended the list by one. Let us get over it and get back to discussing what we all *do* like: PHP. Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] advice on how to build this array from an array.
> From: a...@blueyonder.co.uk > Date: Tue, 7 Jun 2011 21:50:27 +0100 > To: php-general@lists.php.net > Subject: [PHP] advice on how to build this array from an array. > > hi all, > > please forgive me if i do not make sense, ill try my best to explain. > > > i have this array or arrays. > > Array ( [name] => super duplex stainless steels [id] => 30 [page_cat_id] => > 10 [main_nav] => true [cat_name] => material range ) > Array ( [name] => standard stainless steels [id] => 31 [page_cat_id] => 10 > [main_nav] => true [cat_name] => material range ) > Array ( [name] => non ferrous [id] => 32 [page_cat_id] => 10 [main_nav] => > true [cat_name] => material range ) > Array ( [name] => carbon based steels [id] => 33 [page_cat_id] => 10 > [main_nav] => true [cat_name] => material range ) > > is it possible to build an array and use the [cat_name] as the key and assign > all the pages to that cat_name? > > what im trying to achieve is a category of pages but i want the cat_name as > the key to all the pages associated to it > > hope i make sense > > kind regards > > Adam Suppose that $arrays is your array of arrays. Then is $res = array(); foreach($arrays as $item){ $res[$item['cat_name']][] = $item; } what you are looking for? Best regards, Jasper Mulder -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I want to use POST when redirect via PHP Header function.
> To: php-general@lists.php.net > From: jim.gi...@albanyhandball.com > Date: Thu, 30 Jun 2011 09:12:45 -0400 > Subject: Re: [PHP] I want to use POST when redirect via PHP Header function. > > Just as bottom posting (I know, it's in da rules) makes it rather difficult > for humans to read thru a topic, scrolling thru ever-longer messages to get > to the 'new' content. > > Let's solve it for all by only posting your own content and let the sum of > all the messages equate to the topic. :) In fact, the posting rules state that one should only quote those parts of a message that are relevant for the post. Unfortunately, many people decide that everything is relevant, even for a long thread. Still, this should not mean we have to flee to the opposite of no quoting. You will agree that quoting your message above will be clearer than just replying without quote. Personally, I think that incorrect spelling is far more annoying than the quoting; that is, if it does not originate from incapability due to English (whether it be British or American) being not the native language, as opposed to spelling errors because of vapidity. As for the readers of this list, I am sorry to go into this non-PHP subject, but I couldn't really let this pass. Best regards, Jasper
RE: [PHP] How to sum monetary variables
> Date: Mon, 18 Jul 2011 19:00:52 -0300 > From: martin.marq...@gmail.com > To: php-general@lists.php.net > Subject: [PHP] How to sum monetary variables > > I'm building a table (which is a report that has to be printed) with a > bunch of items (up to 300 in some cases) that have unitary price > (stored in a numeric(9,2) field), how many there are, and the total > price for each item. At the end of the table there is a total of all > the items. > > The app is running on PHP and PostgreSQL is the backend. > > The question is, how do I get the total of everything? > > Running it on PHP gives one value, doing a sum() on the backend gives > another, and I'm starting to notice that even using python as a > calculator gives me errors (big ones). Right now I'm doing the maths > by hand to find out who has the biggest error, or if any is 100% > accurate. > > Any ideas? According to the postgreSQL docs, there might occur an error as the sum() output is coerced to have a 9 digit precision (so at most 999,99 as a value), and as this is different from the PHP float interpretation, they might yield different results in case of overflow. However as python supports arbitrary integer arithmetic, overflows should not occur. At the moment, still overflow errors seem the most likely explanation. Does your table consist of very large values (occasionally perhaps)? Could you give us an example? Best regards, Jasper
RE: [PHP] Tree menu list in php
> From: alekto.antarct...@gmail.com > Date: Tue, 26 Jul 2011 19:20:58 +0200 > To: php-general@lists.php.net > Subject: [PHP] Tree menu list in php > > Hi, > is there a way to create a tree menu list only by using php/html/css? > I found some, but they are all in JavaScript, do I have to make them by using > JavaScript or is there a way in php as well? > > This is how I imagine the tree menu should look like: > > > v First level >> Second level >> Second level >v Second level > > Third level > > Third level > > Third level > > Second level > > Second level > > ( > = menu is closed, v = menu is open ) > > > Cheers! > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > This appears like a typical JavaScript thing to me. If you insist on not using JS, you could probably use AJAX+PHP to do it. However, JavaScript appears to me as the more convenient method. Regards, Jasper
RE: [PHP] pass text variables to next page
> Date: Tue, 9 Aug 2011 07:30:47 -0500 > From: chrisstinem...@gmail.com > To: tamouse.li...@gmail.com > CC: php-general@lists.php.net > Subject: Re: [PHP] pass text variables to next page > > Thank you Tamara. > > Not sure if I am doing it right. It looks like the last single quote > is being escaped. > [SNIP] > The query: > > $sql = "SELECT store_id, store_subject > FROM stores > WHERE store_subject = '" . mysql_real_escape_string($_GET['id']."'"); > > > Thank you, > > Chris > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > The problem is with the mysql_real_escape_string closing parenthesis position, instead of ($_GET['id']."'"); it should be ($_GET['id'])."'"; HTH, Jasper
[PHP] Relative includes and include_path
Hi all, On the the include_path php.net says: "Using a . in the include path allows for relative includes as it means the current directory. However, it is more efficient to explicitly use include './file' than having PHP always check the current directory for every include. " (http://www.php.net/manual/en/ini.core.php#ini.include-path) While this does not state that starting every include with "./" is equivalent to having an include_path that is ".", it does suggest exactly that. However, I tried this in the field, and came to a different conclusion. (I included my experiment below.) Is the idea that those two are equivalent wrong? Am I doing something wrong? Is something strange going on? Can anyone clear this issue up for me? Thanks, Jasper --- The experiment: On a machine where the include_path is ".", I had the following file structure: - A.php - B.php - C.php - file.php - sub/includeA.php - sub/includeB.php - sub/includeC.php The content of the files: A.php B.php C.php file.php includeA.php includeB.php includeC.php Now if you visit A.php or B.php the file will be included successfully. Obviously, C.php fails to include anything. includeA.php works all the same, but includeB.php can't find file.php. includeC.php, on the other hand, finds it just fine. This would suggest that include_path being "." means you can include from the path of the current file, while starting your "./" means you start looking from the current parh. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Limit to size of autoindex in MySQL/PHPMyAdmin?
Jim MacCormaic wrote: Hi all. I'm new here, currently implementing my first PHP/MySQL website on an iMac running Mac OS X v.10.2.3. All has been going really well until just now while I was adding records to the MySQL database. I have a table which includes an auto-incremented field which is set as the Primary key. I was happily entering information and then suddenly got a warning of an error in my MySQL query, telling me that I had a 'duplicate entry "255" for key 1'. I've checked the relevant table in PHPMyAdmin and, sure enough, under Row Statistic in the Structure option it gives a value of 255 for the Next Autoindex even though that value was already assigned in the previous record. I feel as if I've hit a brick wall on this one. I ran Check Table, Analyze Table and Optimize Table in PHPMyAdmin Operations and all reported 'OK'. I'm using a PHP form to insert the records and have code included to print out the MySQL query and to report errors (hence the warning which I received). The field in question is of type tinyint(4), unsigned, not NULL and, as stated, is the Primary key and set to auto-increment. Have I hit some sort of limit by reaching an id of 255? If so, can I fix this? Any help would be appreciated, as my database has to all intents and purposes lost its functionality once I cannot add further records. Jim MacCormaic Dublin, Ireland iChat/AIM : [EMAIL PROTECTED] Change the field type from TINYINT to SMALLINT or MEDIUMINT. UNSIGNED TINYINT only has a range of 0 thru 255. Regards. Jasper Bryant-Greene http://fatal.kiwisparks.co.nz/ smime.p7s Description: S/MIME Cryptographic Signature
[PHP] SquirrelMail + Writable Directories
My question is simple - I want to install Squirrelmail on my webserver, but I can't chmod or chown the data directory. Is there any way to stop Squirrelmail from trying to write to the directory without limiting functionality too much, or is there a way to allow it to write without using chmod, chgrp or chown? I can't SSH into the box, only set up cron jobs. :S Can anyone help!? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mail()
mail() returns true if the email delivery worked, false if it failed. However, occasionally the email delivery will work, but will fail at a later stage (a "delivery failed" message will be returned to the sender) - you can check for this by having a script check the mailbox that was sent from, and get all delivery failed messages. parse them for the email address and then you will know that it failed. jasp Tim Thorburn wrote: Hi, I've made a script that loops through a MySQL database and sends a message to all users with an email address on file. My client is now not certain if all their email addresses are accurate and would like to know which ones are and which ones are not. Is there a way, using mail() to tell if an email was not sent to a specified address? I'm on a shared server, so I don't have access to logs other than the standard ones from apache for web tracking. We're using PHP 4.3.0, MySQL 4.0.13, and Apache 1.3.26 Thanks -Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Fetch Information Via a link
Hi Eric What you need to do is make another PHP page, maybe info.php, which will fetch the info field from the DB and display it. So for example, assuming the eventname field is unique, you could make the info like something like: information And then make info.php fetch the info field from the DB, for example if you were using MySQL: // page header HTML here $row = mysql_fetch_assoc(mysql_query("SELECT info FROM table WHERE eventname='{$_GET['eventname']}'")); $info = $row['info']; print(nl2br($info)); ?> // page footer HTML here Obviously you will need to change that to suit your site, and you may want to add some security to the $_GET variable being passed to the MySQL server to prevent attacks. Other than that, hope this helps. Regards Jasper Bryant-Greene Cabbage Promotions http://fatalnetwork.com/ [EMAIL PROTECTED] Eric Holmstrom wrote: Hi there, I have this. Table Name = events Fields = eventname, date, info. Example --- EVENTS --- eventname | date| info -- event1 | 0202 | info here -- event2 | 0303 | info here 2 The problem is that the field "info" has alot of text in it. When I print this out in an array it makes a huge page due to each event having alot of information. So im trying to make it so it will display the results like this. event10202infomation event20303infomation I want the word "infomation" to be hyperlinked, so if you click on it, it will display the information in the "info" field. The problem is I don't know how to make a hyperlink that grabs the correct infomation for each event. Any help at all will be very grateful for. Thankyou Eric Holmstrom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Passing or not passing SID in links etc
No, that will work fine. Just having ? at the end of the URL just means an empty querystring - same as if you had nothing there. Regards Jasper Bryant-Greene Cabbage Promotions http://fatalnetwork.com/ [EMAIL PROTECTED] Gerard Samuel wrote: Im currently modifying templates to include the SID constant, for the few set of users who are rejecting session cookies. If I have an url like -> http://www.foo.com/";>Go Home For users who are rejecting cookies the url looks like -> http://www.foo.com/?PHPSISSID=1234";>Go Home For users who are accepting cookies, the url looks like -> http://www.foo.com/?";>Go Home My question is, are there any known problems with just having '?' at the end of urls/links? Yes, I can do an if/else, but for simple things like this in the templates, but it makes it look more like code than html, and I rather stay away from it. The simpler the template the better. Thanks for your advise. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How New Is <<
It doesn't execute the code between the << Say you had a really long string, with lots of variables in it that needed parsing, and lots of " and ' signs. Instead of using print "" you can use the heredoc syntax. You start with <<< and an identifier (in this case 'HERE') and then end with that identifier and a semicolon. It's just a way for delimiting strings, so you need to look for what's causing that unexpected $ just as if you were looking at a "" string. I can't help you any more without a code snippet. -- Jasper [EMAIL PROTECTED] wrote: I'm running PHP version 4.3.0 on a Macintosh PowerBook with OS 10.2.1, doing some PHP tutorial exercises. And I've run across something I haven't seen before in the sample code I'm seeing: print << Now, from what I've read, it seems that the point of "<< But when I run this thru my browsers--Netscape 7.02 and IE 5.2--I get the following error message: Parse error: parse error, unexpected $ in [path to file] [line number] Is this "<< Thank you. Steve Tiano mail2web - Check your email from the web at http://mail2web.com/ . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: create multiple jpg thumbnails and use in a page
Kevin Coyner wrote: From php.net, I've found plenty of examples of how to create thumbnails from files and have done a couple successfully. My objective, however, is to have a page dynamically create multiple thumbnails from full sized images. I don't want to be creating and saving thumbnails to be used later. Possible? If so, then please just a pointer in the right direction. Thanks, Kevin Without going into too much detail, you just need to use one of the examples you found on PHP.net to create the thumbnail, and then rather than calling something like: imagejpeg('filename.jpg'); once you've created the thumbnail, call this instead: header('Content-Type: image/jpeg'); imagejpeg(); That will output the jpeg image to the browser. Obviously this would be in a separate file called from the main script in an img tag, like: A couple of pointers: 1. You'd want to do input checking on the file GET variable to ensure no-one could get hold of stuff they shouldn't. 2. Make sure you don't output anything else in the file that outputs the thumbnail, or it won't work. HTH -- if you need more specifics let me know. -- Jasper Bryant-Greene Cabbage Promotions www:www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 Public Key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 Fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Avoiding SQL injections: htmlentities() ?
Ryan A wrote: Hi, Just a quick question, I have been reading a lot about SQL injection doing a s**tload of damage to many sites, I myself use a pagentation class which sends the page number from page to page in a $_GET['page'] request which gets used in a LIMIT parameter. From what i have been reading, wrapping all my GET and POST requests in a htmlentities() function should keep me saferight? or what else should i/can i do? eg: $page= htmlentities($_GET[page]); Thanks, Ryan htmlentities() is for displayed data. it will not protect against SQL injection. The best way to protect against SQL Injection is: for string data, mysql_real_escape_string() or your database's equiv. function for all other data, type-check it with intval(), floatval() etc. -- Jasper Bryant-Greene Cabbage Promotions www:www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 Public Key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 Fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: live records
Ryan A wrote: Hey all, [snip] I am reading off an array from the users cookie called "user_cookie" the array is a bunch of numbers like this: [snip] the numbers are the cart items the user has saved and they match a "item_number" field in my mysql db, the arrays name is $cart_arr what i am doing is running a select * from my_db where item_number=x and item_number=x etc based on the items stored in the array, this info will be displayed in a neat little table when he clicks on "show items in my cart" or something as such...so far so good, heres my problem: sometimes items get deleted or are taken off the "active" list, when this happens I would like to take out these times from $cart_arrhow do i do that? Thanks in advance, Ryan Hi Ryan if $item_number is your item number to delete: if(($array_key = array_search($item_number, $cart_arr) !== false) { unset($cart_arr[$array_key]); } Best regards -- Jasper Bryant-Greene Cabbage Promotions www:www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 Public Key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 Fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: auto appending .php extension
Evert | Rooftop Solutions wrote: Hi Folks, I'm using PHP 4.3.10, the Zend Optimizer and Apache 1.3.33. Somehow, if I want to open for example /dikkerapper.php, it is also possible to access it through /dikkerapper (without the .php extension) I haven't seen this before, but when I checked it also occurs on my other servers. The thing is, it causes some big problems with mod_rewrite. For example: [snip] I think you'll find that the MultiViews Apache option is enabled. Create an .htaccess file in your web root and put Options -MultiViews in it. Best regards -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Getting values from the Javascript namespace
Daniel Lahey wrote: Is there any way to get values from the Javascript namespace into PHP? I want to use a value passed into a Javascript function in a query within some PHP code in the function which is used to dynamically populate a select's options. TIA JavaScript is parsed on the client side, and PHP on the server side. Because HTTP is stateless, you'd have to call the server again from the JavaScript, as the JavaScript isn't parsed until after the request is complete. You might like to investigate the XMLHTTP object for calling the server from JavaScript, but it might be better to figure out an alternative way to do it without requiring the second call back to the server. I can't really help any more without more specifics (maybe some code). HTH -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Illegal string offset error in array
Johannes Findeisen wrote: Hello all, sorry if this has been asked allready but i didn't find any usefull information in the web. Why is this function not working in PHP5? [snip] /* * This line does not work in PHP5 cause off an illegal string offset in an array ERROR */ $arrAvailableContent[$i]['submenu'][$n]['file'] = $subfile; [snip] Can someone help? You can't access string offsets with square brackets [] in PHP5. You need to use curly braces {} instead. Square brackets [] for arrays, curly braces {} for string offsets. -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Still fighting setcookie
John Hinton wrote: OK, I created this most simplistic script.. [snip] I would expect the return on action=1 to report the set cookie, but instead, it has no data. If I then reload the browser, the cookie appears. How can I get the cookie to set without this reload? What am I missing? Thanks a bunch... John Hinton When you use setcookie(), it sets a Set-Cookie header in the response to the browser. The browser will then send the Cookie header with subsequent requests. The server has no way of knowing about the cookie until a subsequent request, but you could either code around it or write your own setcookie wrapper, something like: function setcookie2($name, $value="", $expire="", $path="", $domain="", $secure=false) { $_COOKIES[$name] = $value; return setcookie($name, $value, $expire, $path, $domain, $secure); } It's probably better just to think up an alternative way to do it though. Best regards -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Still fighting setcookie
Jasper Bryant-Greene wrote: [snip] function setcookie2($name, $value="", $expire="", $path="", $domain="", $secure=false) { $_COOKIES[$name] = $value; return setcookie($name, $value, $expire, $path, $domain, $secure); } [snip] Sorry, that should be: $_COOKIE[$name] = $value; -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Illegal string offset error in array
Rasmus Lerdorf wrote: Jasper Bryant-Greene wrote: You can't access string offsets with square brackets [] in PHP5. You need to use curly braces {} instead. Not sure where you got that idea. This is not true. -Rasmus Actually, it is. See the following URL: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr Best regards -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Illegal string offset error in array
Rasmus Lerdorf wrote: Jasper Bryant-Greene wrote: You can't access string offsets with square brackets [] in PHP5. You need to use curly braces {} instead. Not sure where you got that idea. This is not true. -Rasmus Actually, it is. See the following URL: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr Yes, please read that link again. The syntax is deprecated. That doesn't mean it doesn't work as you indicated. If we broke this most of the scripts written for PHP4 would break. -Rasmus Yes, but he's talking about PHP5. He probably has E_STRICT on, which is why he's getting that error. I was telling him to use the correct syntax, which will cause him to not get that error. Best regards -- Jasper Bryant-Greene Cabbage Promotions www: www.cabbage.co.nz email: [EMAIL PROTECTED] phone: 021 232 3303 public key: Jasper Bryant-Greene <[EMAIL PROTECTED]> keyID 0E6CDFC5 fingerprint: 2313 5641 F8F6 5606 8844 49C0 1D6B 2924 0E6C DFC5 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] security risk by using remote files with include(); ?
Merlin wrote: I am wondering if I am opening a potential security risk by including files on remote servers. I am doing an include ('http:/www.server.com/file.html') inside a php script of mine to seperate content from function. Content is produced by a friend of mine and I do not want to grant access to my server to him. Yes, your friend (or anyone who compromises his server, who may very well *not* be friendly :) can output any PHP code he likes from that URL, and your server will execute it. Not Good(tm). You could do: | echo file_get_contents( 'http://www.server.com/file.html' ); but only if you really trust his server to never get compromised, as that would allow an attacker to replace content on your website with anything they liked. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switching to UTF-8. Need help.
Is the file saved in UTF-8 encoding (the PHP script itself)? Jasper Andy wrote: This is my code: "; echo utf8_encode ($str); ?> öüééééÉõõÕÕ I tried all the ways: and etc. The first echo... is not showed correctly. The second (with the encoding function) works well. In php.ini the default encoding is UFT-8. The webserver sends the correct encoding. By default the browser(tested on IE and firefox) sees as UFT-8 encoding for the page. If I output the string with utf8_encode function than it wroks well. But... it this the solution??? I don't want to modify the whole project. Best regards, Andy. - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: "Andy" <[EMAIL PROTECTED]> Cc: Sent: Friday, March 24, 2006 2:14 AM Subject: Re: [PHP] Switching to UTF-8. Need help. Check the HEADERS your web-server is sending. If they don't have Charset UTF-8 in there, it won't work on REAL browsers (Mozilla based) Then, for reasons known only to Microsoft, you have to use a META tag to define the Charset for IE. MS will *ignore* the headers in favor of a heuristic whereby they count the number of characters in any given document which do/don't fit into various common charsets, and then they choose the charset based on that. Apparently, MS assumes that web-designers who can only handle META tags are smarter than developers who use header() function. Go figure. :-^ On Thu, March 23, 2006 10:13 am, Andy wrote: Hi to all, We are developing a multilanguage application, and slowly it seems that the Latin1(ISO 5589 1) encoding is not enough. I tried simply to convert the database and the encoding of the php to UTF-8, but I'm getting some problems. If I make an echo 'möbel, Belgien' the browser does not show me the correct character. If I look in the source of the document the character is good. Default encoding of the browser is UTF-8. If I change manually the browser encoding then the chars are showed correclty. We have a lot of "defines" with fix texts, which are full with german and french characters. Any of these aren't shower correctly. What is the workaround for this? Best regards, Andy. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Switching to UTF-8. Need help.
If you're on *nix: man iconv otherwise, I have no idea, sorry. Jasper Andy wrote: No it was not. If I save it with UFT8 encoding it works well. So, do I have to convert all the files to UTF8 encoding? Is there an easy way to do that? - Original Message - From: "Jasper Bryant-Greene" <[EMAIL PROTECTED]> To: "Andy" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]>; Sent: Friday, March 24, 2006 11:18 AM Subject: Re: [PHP] Switching to UTF-8. Need help. Is the file saved in UTF-8 encoding (the PHP script itself)? Jasper Andy wrote: This is my code: "; echo utf8_encode ($str); ?> öüééééÉõõÕÕ I tried all the ways: and etc. The first echo... is not showed correctly. The second (with the encoding function) works well. In php.ini the default encoding is UFT-8. The webserver sends the correct encoding. By default the browser(tested on IE and firefox) sees as UFT-8 encoding for the page. If I output the string with utf8_encode function than it wroks well. But... it this the solution??? I don't want to modify the whole project. Best regards, Andy. - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: "Andy" <[EMAIL PROTECTED]> Cc: Sent: Friday, March 24, 2006 2:14 AM Subject: Re: [PHP] Switching to UTF-8. Need help. Check the HEADERS your web-server is sending. If they don't have Charset UTF-8 in there, it won't work on REAL browsers (Mozilla based) Then, for reasons known only to Microsoft, you have to use a META tag to define the Charset for IE. MS will *ignore* the headers in favor of a heuristic whereby they count the number of characters in any given document which do/don't fit into various common charsets, and then they choose the charset based on that. Apparently, MS assumes that web-designers who can only handle META tags are smarter than developers who use header() function. Go figure. :-^ On Thu, March 23, 2006 10:13 am, Andy wrote: Hi to all, We are developing a multilanguage application, and slowly it seems that the Latin1(ISO 5589 1) encoding is not enough. I tried simply to convert the database and the encoding of the php to UTF-8, but I'm getting some problems. If I make an echo 'möbel, Belgien' the browser does not show me the correct character. If I look in the source of the document the character is good. Default encoding of the browser is UTF-8. If I change manually the browser encoding then the chars are showed correclty. We have a lot of "defines" with fix texts, which are full with german and french characters. Any of these aren't shower correctly. What is the workaround for this? Best regards, Andy. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql query/$post problem
PHP Mailer wrote: Mark skrev: [snip] $query = "INSERT INTO users AVATARS WHERE id =$user_id '','$avname')"; mysql_query($query);s [snip] I am trying to insert the value of $avname into the users table, into the avatar field. I think what you are trying to do is coordinated a bit wrong, perhaps http://www.w3schools.com/sql/sql_insert.asp could be of some help for you to achieve this in the future. Taking a look at your query, i do see what you are trying to do, but the structure is wrong. $query = "INSERT INTO users (avatars) VALUES ('$avname')WHERE id ='$user_id')"; Also - it looks like an UPDATE might be more suitable for what you want, given that you've got a WHERE clause tacked on the end. Google for a good SQL tutorial; the PHP mailing list is not the place to learn SQL :) Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $i vs. $r
Kevin Murphy wrote: Does anyone have a clue why using this code doesn't work: Please specify what "doesn't work" means in this case :) $i = 0; while ($row = mysql_fetch_array($result)) { echo ("Blah blah blah"); $i++; } $r = 0; while ($row = mysql_fetch_array($result)) { echo ("Blah blah blah"); $r++; } Those two blocks of code are for all intents and purposes identical, and indeed probably end up as exactly the same opcodes. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unset a constant
There is no way using the core language. You can, however, use the runkit function if you absolutely have to: http://php.net/runkit_constant_remove Jasper Suhas wrote: Hi, How do I unset a defined variable. e.g. define('AA',1); unset(AA) // gives error any suggestions! Thanks SP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] private $foo
Anthony Ettinger wrote: private $foo; cannot be accessed directly outside the script. print $f->foo; #fails Fatal error: Cannot access private property Foo::$foo in /x/home/username/docs/misc/php/client.php on line 11 Did you define the __get and __set functions in your class as in the previous post? Are you running a version of PHP that supports them? Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] addslashes()
From http://php.net/addslashes : "Having the PHP directive magic_quotes_sybase set to on will mean ' is instead escaped with another '." Jasper Chris Boget wrote: Can someone explain something to me: $string = "Bob's carwash's door"; echo 'addslashes(): ' . addslashes( $string ) . '<br>'; echo 'mysql_escape_string(): ' . mysql_escape_string( $string ) . '<br>'; Outputs: addslashes(): Bob''s carwash''s door mysql_escape_string(): Bob\'s carwash\'s door According to the documentation (http://us2.php.net/manual/en/function.addslashes.php), addslashes() should be doing exactly what mysql_escape_string is doing above (namely, add backslashes in front of each apostrophe). However, it's merely adding an additional apostrophe. Why? I'm running 4.3.11 on Windows NT 5.2 build 3790. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parent constructor
SLaVKa wrote: Hey guys just a general question... if you have a parent::__constructor() call in your constructor function, should that call ideally be placed before or after the code inside the current constructor? or it doesnt really matter That depends on which code you want to run first. Seriously. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting text "
Merlin wrote: Hi there, I would like to output following text with php: How can I do that? I tried to escape the ? with \? but this did not help. Either: 1. Turn off short tags (good idea if you plan on distributing your code). 2. Just echo or print that text. Like: ' . "\n"; ?> -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP4: calling method on returned object
Karl Glennon wrote: [snip] I expected to have the ability to get the url of a location's map with the floowing statement: print $this->Location->GetMap()->GetUrl(); [snip] Is there any other syntax in PHP4 to allow me to concisely call a method on a return object? eg. ($this->Location->GetMap())->GetUrl() .. which doens't work. In short, no. That syntax was introduced in PHP5. For OO work, I would strongly recommend upgrading to PHP5 as there are many other important OO features that simply are not available in PHP4. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Chris wrote: class testClass { public $vars = array(); public function __get($key) { return array_key_exists($key, $this->vars) ? $this->vars[$key] : null; } public function __set($key, $value) { $this->vars[$key] = $value; } public function __isset($key) { return array_key_exists($key, $this->vars); } public function __unset($key) { unset($this->vars[$key]); } } $tc = new testClass(); $tc->arr = array(); here you store an empty array in the $vars member array, under the key 'arr' (due to your magic methods). is that what you intended? $tc->arr['a'] = 'A'; $tc->arr['b'] = 'B'; now you are adding elements to this array under the 'arr' key in the $vars member array. if (isset($tc->arr['b'])) { unset($tc->arr['b']); } you just removed b from the array under 'arr' in the $vars member array. //var_dump is only to see results of above var_dump($tc); this should show something equiv. to: array( 'arr' => array( 'a' => 'A' ) ) what does it actually show? -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Jochem Maas wrote: I think its a misunderstanding on the one side and a limitation on the other, you can't use overloading directly on items of an overloaded array e.g: echo $tc->arr['a'] this is triggers a call to __get() with the $key parameter set to something like (I'm guessing) "arr['a']" No, I'm pretty sure (too lazy and tired right now to test...) that if things work as they should, it will look up __get() with the key parameter set to 'arr', and treat the return value of that as an array, looking for the 'a' key inside that array. Or at least it should, dammit. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Jochem Maas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: I think its a misunderstanding on the one side and a limitation on the other, you can't use overloading directly on items of an overloaded array e.g: echo $tc->arr['a'] this is triggers a call to __get() with the $key parameter set to something like (I'm guessing) "arr['a']" No, I'm pretty sure (too lazy and tired right now to test...) that if you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this->var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t->arr = array(); $t->arr["a"] = 1; echo "OUTPUT: \n"; var_dump($t->arr); var_dump($t->arr["a"]); var_dump($t); ' That's weird, because I did get around to testing it before I saw your mail, and in my test it works as *I* expect (PHP 5.1.2)... My comments earlier were based on the fact that it would not be good to limit what can be put in an object through __get and __set effectively to scalar variables, and I would expect the engine developers to realise that. I think they have (unless I've done something stupid in my test code...): Code: array[$key]; } public function __set( $key, $value ) { $this->array[$key] = $value; } } $t = new T; $t->insideArray = array(); $t->insideArray['test'] = 'testing!'; var_dump( $t ); ?> Output: object(T)#1 (1) { ["array:private"]=> array(1) { ["insideArray"]=> array(1) { ["test"]=> string(8) "testing!" } } } -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Outputting text "
tedd wrote: Merlin: First the syntax should be: <-- note the close / No, that is invalid XML. The specification is available at http://www.w3.org/TR/XML11 (and makes riveting reading! ;) [snip] If you want to print it to a web page, try: EOD; echo($a); echo '<?xml version="1.0" encoding="ISO-8859-1" ?>'; would work just as well and is a hell of a lot easier to look at. That's assuming you actually want it to appear on the page for the user to see, if you want the browser to interpret it you'll have to change the < at the start to a < -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP status code
In other words, if you want Firefox/Opera/etc to display something, you have to output something. Strange, that. :P Jasper Anthony Ettinger wrote: Then it's workingFireFox, et. al. show you the server 404, IE on the otherhand has it's own 404 error page (for those newbies who don't know what a 404 is). You can disable it under IE options. On 3/30/06, Bronislav Klucka <[EMAIL PROTECTED]> wrote: Yes, I do... B. Anthony Ettinger wrote: Are you seeing the IE-specific 404 page? The one that looks like this: http://redvip.homelinux.net/varios/404-ie.jpg On 3/30/06, Bronislav Klucka <[EMAIL PROTECTED]> wrote: Hi, I'm using following construction to send http status code -- header('HTTP/1.1 404 Not Found'); header("Status: 404 Not Found"); exit; -- MSIE displays "Page not found", but FireFox and Opera don't display anything. Just blank page with no text... full headers sent by this script (and server itself) are: -- Date: Thu, 30 Mar 2006 18:02:49 GMT Server: Apache/2.0.55 (Debian) PHP/4.4.0-4 mod_ssl/2.0.55 OpenSSL/0.9.8a X-Powered-By: PHP/5.1.2 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 404 Not Found -- can anyone tell me, why those two browsers are not affected? Brona -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTTP status code
The default Apache error handler is not called when PHP sends a 404 header. The code that does Apache error handling happens *before* PHP gets in the loop, and checks to see if the script being referenced exists, which it indeed does, whether it sends a 404 header or not. Tested on Apache 2.2 with PHP 5.1. If you really want to get the default Apache error handler to appear then either readfile() it or redirect to it. Jasper Anthony Ettinger wrote: well, you typically would redirect 404 to something like foo.com/404.html Otherwise, it's whatever your server (apache/IIS) has as the default 404 handler... Default is something like this: Not Found The requested URL /asdf was not found on this server. Apache Server at foo.org Port 80 On 3/30/06, Jasper Bryant-Greene <[EMAIL PROTECTED]> wrote: In other words, if you want Firefox/Opera/etc to display something, you have to output something. Strange, that. :P Jasper Anthony Ettinger wrote: Then it's workingFireFox, et. al. show you the server 404, IE on the otherhand has it's own 404 error page (for those newbies who don't know what a 404 is). You can disable it under IE options. On 3/30/06, Bronislav Klucka <[EMAIL PROTECTED]> wrote: Yes, I do... B. Anthony Ettinger wrote: Are you seeing the IE-specific 404 page? The one that looks like this: http://redvip.homelinux.net/varios/404-ie.jpg On 3/30/06, Bronislav Klucka <[EMAIL PROTECTED]> wrote: Hi, I'm using following construction to send http status code -- header('HTTP/1.1 404 Not Found'); header("Status: 404 Not Found"); exit; -- MSIE displays "Page not found", but FireFox and Opera don't display anything. Just blank page with no text... full headers sent by this script (and server itself) are: -- Date: Thu, 30 Mar 2006 18:02:49 GMT Server: Apache/2.0.55 (Debian) PHP/4.4.0-4 mod_ssl/2.0.55 OpenSSL/0.9.8a X-Powered-By: PHP/5.1.2 Keep-Alive: timeout=15, max=99 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html 404 Not Found -- can anyone tell me, why those two browsers are not affected? Brona -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Visa / MasterCard security compliance
Dan Harrington wrote: One of these requirements is cardholder data encryption -- is anyone aware of a PHP/MySQL/Linux/Apache solution for end-to-end cardholder data encryption that satisfies the Visa / MasterCard requirements? Apache supports SSL/TLS. Therefore the credit card data can be encrypted in transit to you (you'll probably need to shell out for an SSL cert). Your credit-card processing gateway will provide SSL/TLS encryption for your connection to them (be it via SOAP, REST, whatever). If you really have to store the data for any reason, PHP's mcrypt extension allows you to encrypt it before storing it in the database. But avoid storing it if you can. There you have it, end-to-end data encryption. That's basically the way I do it (I don't store card information so only the first two paragraphs apply), and I satisfy Visa and Mastercard's requirements. :) -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Database connections
Chris wrote: If they're accessing the same database you don't need to disconnect/reconnect. Different db's - well, yeh you don't have a choice. Of course you do. mysql_select_db() or whatever it's called. Or just issue a USE [databasename] query. No need to reconnect! -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] setting the same value to multiple variables
charles stuart wrote: if ( 1 == 1 ) ^^ what is the point of this? { $goodToGo = 0; $errorArray[] = "You must declare some goals on Activity 1."; // this block of code does not set each variable to "class=\"errorHere\""; $readingGoalsEnjoymentLabelClass && $readingGoalsInformationLabelClass && $readingGoalsAlphabeticLabelClass && $readingGoalsPrintLabelClass && $readingGoalsPhonologicalLabelClass && $readingGoalsPhoneticLabelClass && $readingGoalsComprehensionLabelClass && $readingGoalsVocabularyLabelClass && $readingGoalsInstructionsLabelClass && $readingGoalsCriticalLabelClass && $readingGoalsCommunicateLabelClass = "class=\"errorHere\""; } While this seems like excessively ugly code (have you considered an array? what is the point of all those variables if they all hold the same value?), replace all of those '&&' with '=' and you will be fine. PHP evaluates right-to-left and the result of an assignment is the value that was assigned, so that will work. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Overloading Limitation- Can Someone Confirm?
Jim Lucas wrote: Jasper Bryant-Greene wrote: Jochem Maas wrote: [snip] you guess wrong :-) .. I couldn't resist testing it: php -r ' class T { private $var = array(); function __set($k, $v) { $this->var[$k] = $v; } function __get($k) { var_dump($k); } } $t = new T; $t->arr = array(); $t->arr["a"] = 1; echo "OUTPUT: \n"; var_dump($t->arr); var_dump($t->arr["a"]); var_dump($t); ' [snip] Code: array[$key]; } public function __set( $key, $value ) { $this->array[$key] = $value; } } $t = new T; $t->insideArray = array(); $t->insideArray['test'] = 'testing!'; var_dump( $t ); ?> Output: object(T)#1 (1) { ["array:private"]=> array(1) { ["insideArray"]=> array(1) { ["test"]=> string(8) "testing!" } } } Dont know if you guys see the MAJOR difference between your code, so I will point it out. Jasper did this function __get($k) { var_dump($k); } Uhm, no I didn't. Jochem did :) Jochem did this public function __get( $key ) { return $this->array[$key]; } No, I did that. First off, the required public before the function call was not included, secondly, Jasper is var_dumping the key of the array, not the array it self. Public is not required. I always put it regardless, but if you leave it off then PHP defaults to public for compatibility reasons. Jochem's code, which behaves incorrectly, does var_dump. Mine just returns the array key as you would expect. That's why Jochem's doesn't behave correctly with arrays. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match
Benjamin D Adams wrote: I'm trying to check a string for ../ Can't get it to work can anyone help? That's terrible overkill. Regex is not designed for simple substring matching. You want: if( strpos( $string, '../' ) !== false ) echo 'string has ../'; By the way, your problem is that . is a special character in regular expressions, so needs escaping with a backslash, and you have used / as your delimiter but also use it inside the pattern. You should use a different delimiter (also, there's no point in using the 'i' case-insensitive flag, since there's no characters in your pattern). The strpos() solution above is much better and faster in this case, though. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
tedd wrote: > > > I always close the connection right after my > > query -- force of habit. It's like leaving the > > toilet seat up, it's only going to get you into > > trouble. > > So you close it after every query and then re-open it later for the > next query? I don't see that as a good idea. > > > No, you leave it open until you're done with the database. Reading Ted's post didn't give this impression. I wanted to make sure he wasn't doing it that way. Chris et al: Actually I am. When I need something from the dB, I open it, get the information and close it. It's like opening a drawer, getting what you need, and then closing the drawer. Where's the problem? Uh, what if you want to do more than one query in a single request? You aren't seriously suggesting you would connect and disconnect from the same database multiple times within the same request? In my experience, connecting to the database takes up more than half of the execution time of the average database-driven PHP script (I said *average*, there are exceptions). You don't want to be doing it multiple times if you don't have to. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
Robert Cummings wrote: On Sat, 2006-04-01 at 20:15, tedd wrote: It would be interesting to actually run a script that opens, retrieves, and inserts data -- let's say 50k times. What's the time difference between one open, 50k retrieves/inserts, and one close-- as compared 50k opens retrieve/insert closes? [snip] Everyone has their own way. I'm not going to advocate either style since both have their merits depending on where and what you are doing. My input is to advocate a database wrapper layer such that the database connection semantics are remove from general development. In this way you might have the following: [snip] Yeah, e.g. I have a database objects layer that means I only write SQL in classes, everything else is just calling object methods. I create the database object at the start of every script but that doesn't necessarily open the database connection. The database connection is opened when I make my first query. That way if a page does no queries (I use APC caching so it is fairly common for a page to do no queries) then no database connection is opened. I never close connections; PHP does that for me and has never caused any problems doing that. I don't see it as sloppy programming, it is a documented feature that PHP closes resources such as database connections at the end of the script. But, as has been said, each to their own. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
Robert Cummings wrote: On Sat, 2006-04-01 at 20:48, Jasper Bryant-Greene wrote: Yeah, e.g. I have a database objects layer that means I only write SQL in classes, everything else is just calling object methods. I create the database object at the start of every script but that doesn't necessarily open the database connection. The database connection is opened when I make my first query. That way if a page does no queries (I use APC caching so it is fairly common for a page to do no queries) then no database connection is opened. I never close connections; PHP does that for me and has never caused any problems doing that. I don't see it as sloppy programming, it is a documented feature that PHP closes resources such as database connections at the end of the script. But, as has been said, each to their own. There's smart lazy programming, and sloppy lazy programming. I don't trust anything magical in PHP. Most of us are familiar with the magic quotes and global vars fiascos *LOL*. But hey, if you can squeeze a rewrite of an application out of a client for relying on dirty techniques, who am I to critique your forward thinking manipulative methods -- not to say that's your intent -- but I'd sure question your motives and judgement if it comes around ;) I very much doubt PHP will ever enforce the closing of resources such as database connections at the end of every script. That would be a needless BC break. Also, I do it this way because some projects that use my framework want persistent connections. If my framework closed connections automatically then that wouldn't be possible. Of course, it wouldn't exactly be a rewrite to make it close the connection at the end of every script before PHP did, if I'm proven wrong and it one day is necessary. I'd only need to change the database objects layer. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
Robert Cummings wrote: On Sat, 2006-04-01 at 21:39, Jasper Bryant-Greene wrote: Robert Cummings wrote: There's smart lazy programming, and sloppy lazy programming. I don't trust anything magical in PHP. Most of us are familiar with the magic quotes and global vars fiascos *LOL*. But hey, if you can squeeze a rewrite of an application out of a client for relying on dirty techniques, who am I to critique your forward thinking manipulative methods -- not to say that's your intent -- but I'd sure question your motives and judgement if it comes around ;) I very much doubt PHP will ever enforce the closing of resources such as database connections at the end of every script. That would be a needless BC break. I'm sure that was the thought on magic quotes and register globals also. If PHP didn't close connections at the end of scripts we'd either have just about every script in the world throwing errors when they finished, or lots of memory leaks. Neither is particularly favourable, so I don't think it will happen any time soon... Also, I do it this way because some projects that use my framework want persistent connections. If my framework closed connections automatically then that wouldn't be possible. Your database layer should handle whether a connection is really freed. Just because the developer calls the close() method on your DB object, doesn't mean you need to close the connection. But if they don't call a close() method, then in the future if you do need that functionality... it's not there. Of course, it wouldn't exactly be a rewrite to make it close the connection at the end of every script before PHP did, if I'm proven wrong and it one day is necessary. I'd only need to change the database objects layer. Wrong, you would just be doing the same thing PHP does... closing the connection at the end of the script. What happens if you need to open 20 connections to 20 different databases... are you going to keep them all open? I guess you would since it sounds like you don't have a facility to close them. I don't think what you're doing is incredibly obscene, I mean 90% of PHP developers are doing the same thing. 90% of the coding population can't be wrong... but one that same line of thought... when you open an image file or text file for reading or writing... do you close it? Or just leave it open for PHP to close at the end? I mean PHP will magically close all resources for you, there's obviously no need to close it... or maybe there are valid times when you need to close a resource yourself, I dunno, I feel like I'm out on a limb here ;) Yeah, I can see your point. Simple answer though: my framework isn't designed for connecting to 20 different databases :) It's designed for normal database-driven websites -- where there usually a maximum of two connections (master and slave), and often only one connection, open. I guess I'm just gambling the time-saving benefits of not having to call $db->close() or whatever all the time, against the slim possibility that I might one day have to write a new framework to deal with apps that do 20+ DB connections at once. The framework is fairly light anyway as it's built on top of PDO, so a rewrite is not a huge deal. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
John Nichel wrote: Jasper Bryant-Greene wrote: I never close connections; PHP does that for me and has never caused any problems doing that. I don't see it as sloppy programming, it is a documented feature that PHP closes resources such as database connections at the end of the script. It's extremely sloppy programming. You're assuming that a) PHP will continue to be a forgiving language when it comes to items like this and b) your script is going to exit normally. The reason this is a 'documented feature' is because PHP is trying to make up for sloppy programming. You shouldn't rely on the language to clean up your toys for you. If the script exits abnormally the connection is still closed. Test it. I'm happy to gamble on a) as because I have said in earlier posts I am very confident this behaviour will not change in the forseeable future. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL close connection, what's the purpose?
tedd wrote: chris said: Just out of interest, could you re-run the test using persistent connections? change mysql_connect to mysql_pconnect.. [snip] Thanks -- does the "persistent connection" thing hold the server up until released? How does that work? MySQL is threaded so will not be "held up" by any connection. Obviously the more connections the more of certain resources it will be using, but it doesn't block for every connection. The exception, of course, being if you have something going on at the MySQL protocol level such as LOCK TABLES or a transaction. That will hold up certain other queries. But that's at a whole other layer. -- Jasper Bryant-Greene General Manager Album Limited http://www.album.co.nz/ 0800 4 ALBUM [EMAIL PROTECTED] 021 708 334 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mktime() vs date()
hi, is mktime() actually faster than date() or any other date functions? tnx. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: SAFEMODE w/ PEAR
Ashley M. Kirchner wrote: >I'm having a small problem with SAFE MODE and PEAR that I'm unsure > how to solve: > >[error] PHP Warning: raiseerror(): SAFE MODE Restriction in effect. > The script whose uid is 524 is not allowed to access > /usr/lib/php/PEAR.php owned by uid 0 in /path/to/script/Lite.php on line > 470 > >How should that get solved? Everything in /usr/lib/php is owned by > root.root and just about everyone wants access to the PEAR library, but > SAFE MODE won't allow it? > You either need to chown /usr/lib/php to the script's UID (not recommended) or turn off Safe Mode. The whole point of Safe Mode is that scripts cannot access files which do not match their UID. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I create an Outlook calendar entry?
Daevid Vincent wrote: > There are some pretty crazy "Thread-Index:" and "UID:" things in there. > Do I have to generate them somehow? No. They are email headers relating to the tracking of replies and the internal tracking of emails on the mail server. It should be safe to leave them out, in fact the body of the message (from BEGIN:VCALENDAR to END:VCALENDAR) is likely to be all that you need. Google for a VCalendar spec. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: css/html expertise??
bruce wrote: > i'm playing around with css (classes/ids/etc...) does anybody here > have any experience with this or could answer a few questions?? Email me directly with your issues and I'll try to help you sort it out. Cheers, Jasper Bryant-Greene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: A Bug in string ' e
cchereTieShou wrote: > You can actually try to use this to verify the problem: > > echo ' e > What you get? I got > Quite confusing. Anyone think this is a bug or something I missed? Are you viewing this via a web server? It's probably returning content-type text/html, which means that you might need to htmlspecialchars() that string. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] including the result of one query in another query
Jochem Maas wrote: >> I have two databases, on for aeromodelistas (aeromodelling) and >> another for Códigos Postais (Postal Codes). I whant to do the > > what DB are you using? MySQL? > you can't select across multiple DBs in any RDMS that I know of ... > so it looks like either use 2 queries or merge the DBs? I think he means tables. And yes you can, at least in MySQL, and probably in others. If you're using a version of MySQL prior to 4.1, though, you can't do subqueries, which means that you'll need to reformulate your query with joins. Also DISTINCT isn't a function. The expression should be: SELECT DISTINCT query_expr ... not SELECT distinct(query_expr) ... Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A Bug in string ' e
Kevin L'Huillier wrote: > Could you copy the relevant code into a message? Seeing > pseudo-script is different from seeing what you are actually > doing. Sure, either set the content-type to text/plain (to see the raw string rather than have the browser interpret it as HTML), like this: or htmlspecialchars the string, like this: Or just view source in your browser to see the raw string. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A Bug in string ' e
Kevin L'Huillier wrote: > On 26/06/05, Jasper Bryant-Greene <[EMAIL PROTECTED]> wrote: > >>Kevin L'Huillier wrote: >> >>>Could you copy the relevant code into a message? >> >>Sure, either set the content-type to text/plain (to see the raw string >>rather than have the browser interpret it as HTML), like this: > > > Sorry, Jasper. I meant the original poster of this thread. No problem, Kevin. In future, though, please remember not to "Reply All" as getting the same email two or three times can be annoying! Cheers Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $mydata->StampDate
John Taylor-Johnston wrote: > I created my own counter. I have a varchar (10) field that resembles a > date: 2005-06-26. Now I would like to parse out $mydata->StampDate to > find how many hits per day I have had since "2003-08-23". Where do I start? > >while ($mydata = mysql_fetch_object($news)) >{ >} You can use strtotime() to convert your string date to a PHP date. and then calculate it from that. However, I'd strongly recommend using a real MySQL date field to store the date. There's no reason not to, and then you can use MySQL native functions to do a lot of the calculation. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: $mydata->StampDate
John Taylor-Johnston wrote: > I could just change the field type. But how do you calculate it? I don't > see much to inspire a start. I'm not a full-time coder either. More of a > tinkerer. I don't want someone to do it for me, but need to get my head > around how to do it. > http://ca3.php.net/manual/en/function.strtotime.php If you stick with a string data type, then I'd use the following to convert it to a UNIX timestamp (seconds since 1970-01-01) and find the number of days since 23 August 2003: $unix_timestamp = strtotime($mydata->StampDate); $timestamp_2003 = strtotime('2003-08-23'); $days_since_2003 = ($unix_timestamp - $timestamp_2003) / 60 / 60 / 24; $days_since_2003 now contains the number of days since 2003 for that date. You'd have to aggregate all your records to get the average hits per day. As I said, though, you should be using a MySQL date field. Have a look at the MySQL manual for the corresponding functions to the above -- there's probably a quicker way with MySQL too. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Breaking up data efficiently
Wee Keat wrote: > /* BEGIN DATA */ > > Melbourne, AU, 21-07-2005 14:00:00|Perth, AU, 21-07-2005 18:00:00|Perth, > AU, 25-07-2005 14:00:00|Melbourne, AU, 25-07-2005 18:00:00 > > /* END DATA */ > [snip] > /* BEGIN CODE */ > $itenary = explode('|', $booking->booking_flight_details); > > $size = count($itenary); > > for($i=0; $i < $size; $i++) { > list($path[$i]['location'], > $path[$i]['country'], > $path[$i]['datetime']) = explode(',', $itenary[$i]); > } > /* END CODE */ > > *Question*: Is the above the code an effective way to do it? Or is there > a better/faster way? It's pretty good, but I would've done: $itinerary = explode('|', $booking->booking_flight_details); foreach($itinerary as $item) { $item = explode(',', $item); $path[] = array( 'location' => $item[0], 'country' => $item[1], 'datetime' => $item[2] ); } That's really just a matter of preference though. Jasper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php