Re: [PHP] Trouble with switch statements
Use $_GET["select"] for the switch statement Some of the people on this list would even recommend you make another variable first, such as $userselect = $_GET["select"] and use $userselect as your switch statement, though I think it pointless. Or turn register_globals on in the php.ini file (not recommended) -Samuel | http://enetwizard.net -Original Message- From: Edward Kehoe [mailto:emkehoe@;learn.senecac.on.ca] Sent: Friday, October 25, 2002 1:47 PM To: [EMAIL PROTECTED] Subject: [PHP] Trouble with switch statements Ok...I just recently installed Apache1 and PHP 4.2.3 on my computer and I've configured everything. However, I can't seem to get my switch statements to accept variable values from the address bar. So if I type in: http://www.my-site.com/index.php?select=1 It displays the text in the default part of the switch statement. I also seem to get the following error message every time: Notice: Undefined variable: select in c:\apache\apache\htdocs\index.php on line 51 Here's the code for my switch statement as well: switch($select) { case 1: print "About Stuff Goes Here."; break; case 2: print "Music Goes Here."; break; default:print "Testing..."; break; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Trouble with switch statements
switch($_GET['select']){ case 1: .. -Peter > -Original Message- > From: Edward Kehoe [mailto:emkehoe@;learn.senecac.on.ca] > Sent: Friday, October 25, 2002 19:47 > To: [EMAIL PROTECTED] > Subject: [PHP] Trouble with switch statements > > > Ok...I just recently installed Apache1 and PHP 4.2.3 on my > computer and I've > configured everything. However, I can't seem to get my switch > statements to > accept variable values from the address bar. So if I type in: > > http://www.my-site.com/index.php?select=1 > > It displays the text in the default part of the switch > statement. I also > seem to get the following error message every time: > > Notice: Undefined variable: select in > c:\apache\apache\htdocs\index.php on > line 51 > > Here's the code for my switch statement as well: > > switch($select) > { > case 1: print "About Stuff Goes Here."; >break; > case 2: print "Music Goes Here."; >break; > default:print "Testing..."; >break; > } > > > > > -- > 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] Trouble with switch statements
Ok...I just recently installed Apache1 and PHP 4.2.3 on my computer and I've configured everything. However, I can't seem to get my switch statements to accept variable values from the address bar. So if I type in: http://www.my-site.com/index.php?select=1 It displays the text in the default part of the switch statement. I also seem to get the following error message every time: Notice: Undefined variable: select in c:\apache\apache\htdocs\index.php on line 51 Here's the code for my switch statement as well: switch($select) { case 1: print "About Stuff Goes Here."; break; case 2: print "Music Goes Here."; break; default:print "Testing..."; break; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mac OS X EI TEXTAREA Problem
I am setting a MySQL update page where a user is provided a HTML form to update with data auto poulated from a MySQL database via PHP. All the form element work except for TEXTAREA. No matter what encoding I use (htmlspecial, htmlentities etc) I get the browser displaying garbeld text. Example: MySQL data: Headquartered in ABC Building in Anytown, Any Province, ABC Inc. employs approximately 2,500 people and holds almost $9 billion in quality growth assets. A fully integrated oil and gas company, ABC ranks second in production and third in reserves relative to Canada's four other integrated oil and gas companies and is the fourth-largest downstream retailer. HTML TEXTAREA Source: Headquartered in ABC Building in Anytown, Any Province, ABC Inc. employs approximately 2,500 people and holds almost $9 billion in quality growth assets. A fully integrated oil and gas company, ABC ranks second in production and third in reserves relative to Canada's four other integrated oil and gas companies and is the fourth-largest downstream retailer. TEXTAREA Data: 5{d in ABC Building in Anytown, Any Province, ABC Inc. employs approximately 2,500 people and holds almost $9 billion in quality growth assets. A fully integrated oil and gas company, ABC ranks second in production and third in reserves relative to Canada's four other integrated oil and gas companies and is the fourth-largest downstream retailer. Or pd in ABC Building in Anytown, Any Province, ABC Inc. employs approximately 2,500 people and holds almost $9 billion in quality growth assets. A fully integrated oil and gas company, ABC ranks second in production and third in reserves relative to Canada's four other integrated oil and gas companies and is the fourth-largest downstream retailer. I can't get the same results in Netscape 7 Mac or either Windows versions. I will blame Microsoft unless there is some obscure encoding issue I can't find. :^) Thanks, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 27 Oct 2002 05:26:21 -0000 Issue 1668
php-general Digest 27 Oct 2002 05:26:21 - Issue 1668 Topics (messages 121529 through 121576): Re: passthru problems generating WAVs with mpg123 121529 by: Justin French Re: upload files 121530 by: Chad Cotton PHP Manual Book 121531 by: Stephen 121539 by: Jason Wong Re: mysql_fetch_row options 121532 by: Monty Re: parsing conundrum 121533 by: Monty Re: extract($_POST) 121534 by: Monty 121535 by: Monty 121546 by: John W. Holmes 121552 by: Monty 121555 by: John W. Holmes 121556 by: Monty 121558 by: John W. Holmes 121564 by: Monty 121567 by: John W. Holmes 121570 by: . Edwin Mail Delivery errors when posting here ??? 121536 by: Monty Problem with session and register_globals=off 121537 by: Alexandre 121543 by: John W. Holmes Problem wih Session and register_globals 121538 by: Jacques Marques Problem with Session and register_globals 121540 by: Jacques Marques Re: Best way to set global params for entire site?? 121541 by: Lance Lovette Re:
Re: [PHP] predifined functions
on 27/10/02 2:31 PM, Jason Wong ([EMAIL PROTECTED]) wrote: > On Sunday 27 October 2002 10:40, DaRk--ObJeCtS wrote: >> alright i wanna know where i could see the source of predifened functions >> like session_register. Thx. > > the manual? errr, no the SOURCE... download it from php.net... did around, do some multi-file search thingies... justin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] predifined functions
On Sunday 27 October 2002 10:40, DaRk--ObJeCtS wrote: > alright i wanna know where i could see the source of predifened functions > like session_register. Thx. the manual? -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* The years of peak mental activity are undoubtedly between the ages of four and eighteen. At four we know all the questions, at eighteen all the answers. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
On Saturday, October 26, 2002, at 09:45 PM, John W. Holmes wrote: Ok then without asp how do I get
[PHP] predifined functions
alright i wanna know where i could see the source of predifened functions like session_register. Thx. -- Dark |++| Darkobjects.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flash / PHP Question
Hello, I'm afraid that your question is more of a "How can I use Flash MX?" question. Maybe you should get a good book about Flash MX or just google for some more other tutorials... - E "Stephen" <[EMAIL PROTECTED]> wrote: > I'm tyring to follow a DevArticle tutorial on creating a online users > script in flash. Problem is, I can't find where the actions properties > are to enter things like this: > > loadVariablesNum("count.php?RND="+random(999), 0); > > Please help!! I'm using Flash MX, same as the tutorial. I've also > posted a message in the tutorial's forum place but no reply... > > Thanks, > Stephen Craton > http://www.melchior.us > http://php.melchior.us > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions Sessions. Lovely Sessions.
Ok. I've had to wrestle with some peculiar issues with my sessions... 1) If at any point, I give my session a name different than the default using session_name('XYZ'), my session won't be created. Is there a limit to the number of characters a session name can have? Capitalization? ANYTHING? 2) If at any point, I use the funcion session_set_cookie_params(), my cookie does not set! This is becoming frustrating... using php4.2.3 on apache1.3.26 on a FreeBSD machine. php.ini is the default. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract($_POST)
Or, You can use this: http://www.php.net/manual/en/function.is-numeric.php - E "John W. Holmes" <[EMAIL PROTECTED]> wrote: > > > Then make sure $id is a number. You can use is_int, or (int), or > > whatever. > > > > It appears that any numeric values passed via the URL (..?param=10001) > are > > automatically treated as strings. If I pass ?param=1001 to the > following > > script... > > So turn it into an integer. > ...[snip]... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question!
That's impossible to answer!! My guess is that the "few letters" you change affect the way the script runs, so it's probably causing an error. Without seeing *WHAT* you change, I can only guess. Justin on 27/10/02 10:31 AM, Trasca Ion-Catalin ([EMAIL PROTECTED]) wrote: > If I have a php file who calls another php file which change some letters on > the first file, why my php code on the first file won't work anymore? > I hope I was explicit enough in my question. > > -- > Trasca Ion-Catalin > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP]
> Ok then without asp how do I get
RE: [PHP] extract($_POST)
> > Bottom line is that you want to use addslashes() or magic_quotes_gpc() > > on any variable you're going to insert into a query string. If you're > > inserting a variable that should be a number, make sure it is one. > > If I have magic quotes turned on, do I still need to worry about using > addslashes? No, it's automatic. You may want to program in a check that sees if magic_quotes is on or off, though, and act accordingly. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Flash / PHP Question
I'm tyring to follow a DevArticle tutorial on creating a online users script in flash. Problem is, I can't find where the actions properties are to enter things like this: loadVariablesNum("count.php?RND="+random(999), 0); Please help!! I'm using Flash MX, same as the tutorial. I've also posted a message in the tutorial's forum place but no reply... Thanks, Stephen Craton http://www.melchior.us http://php.melchior.us
RE: [PHP]
Ok then without asp how do I get
Re: [PHP] extract($_POST)
John W. Holmes wrote: > > Bottom line is that you want to use addslashes() or magic_quotes_gpc() > on any variable you're going to insert into a query string. If you're > inserting a variable that should be a number, make sure it is one. If I have magic quotes turned on, do I still need to worry about using addslashes? Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question!
If I have a php file who calls another php file which change some letters on the first file, why my php code on the first file won't work anymore? I hope I was explicit enough in my question. -- Trasca Ion-Catalin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Referral Site...
Ken Kirtley wrote: > I'm new to PHP and so this may be something of a newbie question. My bad if > it is. I've spent a week now looking for information on capturing the > referral site with php so that I can store it with some session information. > If any of you have any idea how to accomplish this I would greatly > appreciate any information. You want the $_SERVER superglobal. Here's more info... http://www.php.net/manual/en/reserved.variables.php#reserved.variables.serve r -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Referral Site...
$HTTP_REFERER $_SERVER["HTTP_REFERER"] Samuel | http://enetwizard.net -Original Message- From: Ken Kirtley [mailto:kdkirtley@;earthlink.net] Sent: Saturday, October 26, 2002 5:47 PM To: [EMAIL PROTECTED] Subject: [PHP] Referral Site... I'm new to PHP and so this may be something of a newbie question. My bad if it is. I've spent a week now looking for information on capturing the referral site with php so that I can store it with some session information. If any of you have any idea how to accomplish this I would greatly appreciate any information. Thanks in advance...Ken -- 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] Referral Site...
I'm new to PHP and so this may be something of a newbie question. My bad if it is. I've spent a week now looking for information on capturing the referral site with php so that I can store it with some session information. If any of you have any idea how to accomplish this I would greatly appreciate any information. Thanks in advance...Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and databases
Or, more simply - set up an ODBC DSN on the Windows box to the MySQL database, and simply link the tables into Access. Best regards, Andrew Hill Director of Technology Evangelism - OpenLink Software Universal Data Access and the Virtuoso Universal Server http://www.openlinksw.com/virtuoso/whatis.htm On Friday, October 25, 2002, at 12:43 PM, Jay Blanchard wrote: [snip] Is there anyway to have php convert a database from mySQL to Access via a webpage? I have a couple of people here who use Access to do mail merging things with word and it would make my life a ton easier if I did not have to convert the db's everytime they want the info. If anyone has any thoughts on how to go about this it would be greatly appreciated. Thanks in advance. [/snip] Open and read the data via mysql_ ..() functions into an array. Then open an ODBC connection to the acce$$ database and insert the data from the array. Shouldn't be too hard. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] extract($_POST)
> > Then make sure $id is a number. You can use is_int, or (int), or > whatever. > > It appears that any numeric values passed via the URL (..?param=10001) are > automatically treated as strings. If I pass ?param=1001 to the following > script... So turn it into an integer. $param = (int)$_POST['param']; It'll be turned into an integer or anything after a string part will be chopped off. 10001 => 10001 1000f => 1000 f1000 => 0 Validating can be that simple. You may also want to check the range of the number. Again, validating is unique to your application. What do you expect the value to be? If the value is XXX, how does that affect my application? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] blogger with ODBC support?
hi, does anyone know of a blogger with ODBC support? cheers, jaxon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract($_POST)
John W. Holmes wrote: > Then make sure $id is a number. You can use is_int, or (int), or whatever. It appears that any numeric values passed via the URL (..?param=10001) are automatically treated as strings. If I pass ?param=1001 to the following script... $type = ''; if (is_string($param)) { $type = 'string'; } if (is_int($param)) { $type = 'integer'; } echo 'Type: '.$type; ... I get the following result: Type: string But, it should be integer because 10001 is meant to be a number. How does this work for $_GET values? Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] extract($_POST)
> I'm confused about when I should escape single or double quotes. Should > all > quotes be stored as \" or \' in a database as well? Escape both, just use addslashes. The key here is that if you are inserting a variable into a string (which is all a query is), then you want to make sure that the contents of that variable don't unexpectedly terminate the string. > Regarding your suggestion above, is this what I should do? ... > > $name = "John AND fname = 'Mary'"; > > $name = addslashes($name); > > // $name now holds: "John AND fname = \'Mary\'" > > This forces MySQL to read \' as a character rather than as the beginning > of > a variable value. So, in essence, this would produce a mySQL error instead > of executing the query, is that correct? It depends on what you're doing with $name. Remember, you're just creating a string that has to be logical when it's sent to MySQL SELECT * FROM table WHERE name = '$name' SELECT * FROM table WHERE name = "$name" Either way you do it, you want to make sure that the contents of $name don't have a quote that'll end the name string. If you have $name = "John AND fname = 'Mary'"; and you don't escape quotes, then you have a query like SELECT * FROM table WHERE name = 'John AND fname = 'Mary' SELECT * FROM table WHERE name = "John AND fname = 'Mary' Where the first one will cause an error and the second one will just not match any rows, more than likely. If you have $name = "John' AND fname='Mary"; and you don't escape quotes, you'll get SELECT * FROM table WHERE name = 'John' AND fname='Mary' SELECT * FROM table WHERE name = "John' AND fname='Mary" Where the first is a valid query and could return rows you didn't normally intend for it to return. The second will probably not match any rows again. Now, don't think that double quotes are any safer. You can change $name to use double quotes to manipulate the queries, too. Bottom line is that you want to use addslashes() or magic_quotes_gpc() on any variable you're going to insert into a query string. If you're inserting a variable that should be a number, make sure it is one. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting the "From: admin@site.com" to work
Add this to the header string... "Bcc: [EMAIL PROTECTED]\r\n"; Andre Dubuc wrote: Perhaps some kind guru can spare me some time. I've tried to get the "From: " field pre-filled for a registration/confirmation email that I send out. I've managed to get the "To: ' field working great, but no matter where I stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing wrong? Right now, the "From:' field is filled with my IP's address -- not exactly very cool to see! Here's the code I've used (POP3): $mail = $_SESSION['smail']; $fname = $_SESSION['sfname']; $sname = $_SESSION['ssname']; $_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">"; /* tried this -- it didn't work $reg_first = "Registration"; $reg_last = "[EMAIL PROTECTED]"; $_SESSION['from_name'] = "".$reg_first." <".$reg_last.">"; */ /* Begin Confirmation Required script */ other code /* Begin MAIL() */ $to = $_SESSION['name_mail']; $from = "[EMAIL PROTECTED]"; /* I tried this head-on-direct approach -- no go, either */ $subject = "Please Confirm Your Registration"; $message = "Thank you for registering as a {$_SESSION['level']} at Xsite.com To complete your registration, please click the 'Confirmation' URL below. https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}"; if(@mail($to, $from, $subject, $message)) *** If I remove the $from everything works but with my IP's 'From: ' Where should the $from variable go in the mail() function? Any hints or ideas gratefully appreciated, Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Getting the "From: admin@site.com" to work
How would you then build into the headers an 'invisible' BCC (blind carbon copy)? -Original Message- From: Monty <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Date: Saturday, October 26, 2002 3:53 PM Subject: [PHP] Re: Getting the "From: [EMAIL PROTECTED]" to work >Andre Dubuc wrote: > >> Perhaps some kind guru can spare me some time. I've tried to get the "From: >> " field pre-filled for a registration/confirmation email that I send out. > >To add to John's reply, here's how to do a multi-parameter Header. Also note >the \r\n at the end of each of these lines. If you don't do this, the header >won't be formatted properly. It took me some time to eventually figure this >out when I first did this because I was using just \n which doesn't work in >the header, but, does work in the body. > > $headers = "From: [EMAIL PROTECTED]\r\n" > ."Reply-To: [EMAIL PROTECTED]\r\n" > ."X-Mailer: PHP/4.0.2"; > >You can also add other mail headers such as 'Importance: High' to the >headers list. > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract($_POST)
John W. Holmes wrote: > Then make sure $name has all single quotes escaped within it. If all of > them are escaped, then it's just a string and can't do any harm. If they > aren't escaped, then the user can break out of your own SQL and put > their own. I'm confused about when I should escape single or double quotes. Should all quotes be stored as \" or \' in a database as well? Regarding your suggestion above, is this what I should do? ... $name = "John AND fname = 'Mary'"; $name = addslashes($name); // $name now holds: "John AND fname = \'Mary\'" This forces MySQL to read \' as a character rather than as the beginning of a variable value. So, in essence, this would produce a mySQL error instead of executing the query, is that correct? Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting the "From: admin@site.com" to work
You need to build your header and include that in your mail() call: $lc_headers = "From: $lc_from_name <$lc_from_email>\n"; $lc_headers .= "X-Sender: <$lc_sender>\n"; $lc_headers .= "X-Mailer: PHP\n"; // mailer $lc_headers .= "Return-Path: <$lc_return>\n"; // Return path for errors $lc_headers .= "Mime-Version: 1.0\n"; mail($lc_recipient, $lc_subject, $lc_message, $lc_headers); - Original Message - From: "Andre Dubuc" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, October 26, 2002 1:40 PM Subject: [PHP] Getting the "From: [EMAIL PROTECTED]" to work > Perhaps some kind guru can spare me some time. I've tried to get the "From: > " field pre-filled for a registration/confirmation email that I send out. > > I've managed to get the "To: ' field working great, but no matter where I > stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing > wrong? Right now, the "From:' field is filled with my IP's address -- not > exactly very cool to see! > > > Here's the code I've used (POP3): > > $mail = $_SESSION['smail']; > $fname = $_SESSION['sfname']; > $sname = $_SESSION['ssname']; > $_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">"; > > /* tried this -- it didn't work > > $reg_first = "Registration"; > $reg_last = "[EMAIL PROTECTED]"; > $_SESSION['from_name'] = "".$reg_first." <".$reg_last.">"; > */ > > /* Begin Confirmation Required script */ > > other code > > /* Begin MAIL() */ > > > $to = $_SESSION['name_mail']; > $from = "[EMAIL PROTECTED]"; /* I tried this head-on-direct approach -- no go, > either */ > $subject = "Please Confirm Your Registration"; > > $message = "Thank you for registering as a {$_SESSION['level']} at > Xsite.com > To complete your registration, please click the 'Confirmation' URL below. > https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}"; > > if(@mail($to, $from, $subject, $message)) > > *** > > If I remove the $from everything works but with my IP's 'From: ' > Where should the $from variable go in the mail() function? > > Any hints or ideas gratefully appreciated, > Tia, > Andre > > -- > 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: Getting the "From: admin@site.com" to work
Andre Dubuc wrote: > Perhaps some kind guru can spare me some time. I've tried to get the "From: > " field pre-filled for a registration/confirmation email that I send out. To add to John's reply, here's how to do a multi-parameter Header. Also note the \r\n at the end of each of these lines. If you don't do this, the header won't be formatted properly. It took me some time to eventually figure this out when I first did this because I was using just \n which doesn't work in the header, but, does work in the body. $headers = "From: [EMAIL PROTECTED]\r\n" ."Reply-To: [EMAIL PROTECTED]\r\n" ."X-Mailer: PHP/4.0.2"; You can also add other mail headers such as 'Importance: High' to the headers list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting the "From: admin@site.com" to work
Thanks John, I had the maual in front of me, but I didn't understand that you had to put the 'From:' stuff in a 'header'. That's why it wasn't working. I presumed (wrongly again) that 'headers' were optional, and I got sidetracked by the success of the "To:" field. Thanks for clearing that up. Regards, Andre On Saturday 26 October 2002 04:42 pm, John W. Holmes wrote: > [snip] > > > if(@mail($to, $from, $subject, $message)) > > Go back to the manual. The parameters for mail are > mail(to,subject,message,headers). > > You have to pass the From: address in the headers. > > $to = "[EMAIL PROTECTED]"; > $subject = "Your email"; > $message = "Your email is good"; > $headers = "From: [EMAIL PROTECTED]\r\n"; > > mail($to,$subject,$message,$headers); > > Read the manual on other headers you can send. > > ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting the "From: admin@site.com" to work
http://www.php.net/manual/en/function.mail.php >>if(@mail($to, $from, $subject, $message)) There is no 'from' field. This must be put in the headers. Andre Dubuc wrote: Perhaps some kind guru can spare me some time. I've tried to get the "From: " field pre-filled for a registration/confirmation email that I send out. I've managed to get the "To: ' field working great, but no matter where I stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing wrong? Right now, the "From:' field is filled with my IP's address -- not exactly very cool to see! Here's the code I've used (POP3): $mail = $_SESSION['smail']; $fname = $_SESSION['sfname']; $sname = $_SESSION['ssname']; $_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">"; /* tried this -- it didn't work $reg_first = "Registration"; $reg_last = "[EMAIL PROTECTED]"; $_SESSION['from_name'] = "".$reg_first." <".$reg_last.">"; */ /* Begin Confirmation Required script */ other code /* Begin MAIL() */ $to = $_SESSION['name_mail']; $from = "[EMAIL PROTECTED]"; /* I tried this head-on-direct approach -- no go, either */ $subject = "Please Confirm Your Registration"; $message = "Thank you for registering as a {$_SESSION['level']} at Xsite.com To complete your registration, please click the 'Confirmation' URL below. https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}"; if(@mail($to, $from, $subject, $message)) *** If I remove the $from everything works but with my IP's 'From: ' Where should the $from variable go in the mail() function? Any hints or ideas gratefully appreciated, Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Getting the "From: admin@site.com" to work
[snip] > if(@mail($to, $from, $subject, $message)) Go back to the manual. The parameters for mail are mail(to,subject,message,headers). You have to pass the From: address in the headers. $to = "[EMAIL PROTECTED]"; $subject = "Your email"; $message = "Your email is good"; $headers = "From: [EMAIL PROTECTED]\r\n"; mail($to,$subject,$message,$headers); Read the manual on other headers you can send. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] extract($_POST)
> > You can still use extract($_POST). > > It is as safe/vulernable as $_POST['isAdmin']. > > > > In either case, use only variables that you know are yours and be > certain > > these contain values which you believe to be safe. For instance, if you > expect > > a variable called $firstname to contain a name to be stored in a SQL > database, > > be certain it does not contain SQL commands which can damage your > database. > > > > Okay, I know I can use strip_tags() and/or htmlspecialchars() to strip out > or modify HTML and PHP code in a string, but, how does one do the same > with > MySQL code in a string to prevent tampering? You pass a string or an number to your query. You have to make sure the data you're passing is a string, or a number. If you're expecting a number, and use a query like: WHERE id = $id Then make sure $id is a number. You can use is_int, or (int), or whatever. If you're passing a string WHERE username = '$name' Then make sure $name has all single quotes escaped within it. If all of them are escaped, then it's just a string and can't do any harm. If they aren't escaped, then the user can break out of your own SQL and put their own. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting the "From: admin@site.com" to work
Perhaps some kind guru can spare me some time. I've tried to get the "From: " field pre-filled for a registration/confirmation email that I send out. I've managed to get the "To: ' field working great, but no matter where I stick the 'From:' code, it doesn't send the email. Any ideas what I'm doing wrong? Right now, the "From:' field is filled with my IP's address -- not exactly very cool to see! Here's the code I've used (POP3): $mail = $_SESSION['smail']; $fname = $_SESSION['sfname']; $sname = $_SESSION['ssname']; $_SESSION['name_mail'] = "".$fname." ".$sname." <".$mail.">"; /* tried this -- it didn't work $reg_first = "Registration"; $reg_last = "[EMAIL PROTECTED]"; $_SESSION['from_name'] = "".$reg_first." <".$reg_last.">"; */ /* Begin Confirmation Required script */ other code /* Begin MAIL() */ $to = $_SESSION['name_mail']; $from = "[EMAIL PROTECTED]"; /* I tried this head-on-direct approach -- no go, either */ $subject = "Please Confirm Your Registration"; $message = "Thank you for registering as a {$_SESSION['level']} at Xsite.com To complete your registration, please click the 'Confirmation' URL below. https://www.Xsite.com/all-confirm.php?unique_id={$_SESSION['unique_id']}"; if(@mail($to, $from, $subject, $message)) *** If I remove the $from everything works but with my IP's 'From: ' Where should the $from variable go in the mail() function? Any hints or ideas gratefully appreciated, Tia, Andre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
So if you have... and <% asp junk; m$ junk; %> it your server will parse both the php and asp code? Jason Porembski wrote: Yes it does. But I need the php to work in an ASP page =( - Original Message - From: "John Nichel" <[EMAIL PROTECTED]> To: "Jason Porembski" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, October 26, 2002 12:03 PM Subject: Re: [PHP]
RE: [PHP] Problem with session and register_globals=off
$counter is not related to the session at all with register_globals OFF. Use $HTTP_SESSION_VARS['count']++; ---John Holmes... > -Original Message- > From: Alexandre [mailto:alexandre@;cmsmedical.com.br] > Sent: Saturday, October 26, 2002 2:42 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Problem with session and register_globals=off > > Hello, > > When I try the code below and register_globals=On, its work fine, the > counter variable is incremented each time that I load the page, but, when > register_globals=Off, its does not work, the counter variable is save just > in first time and never more. > > // register a session variable >session_register('counter'); >$counter = $HTTP_SESSION_VARS["counter"]; >// increment and display the value of the counter >$counter++; >echo("You have visited this page $counter times! Don't you have >anything else to do, you bum?!"); > ?> > > How can I fix this? With out to turn register_globals=On. > > Thanks, > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP]
You can't have both. Either the script is parsed by PHP or it's parsed by ASP. ---John Holmes... > -Original Message- > From: Jason Porembski [mailto:jporembs@;optonline.net] > Sent: Friday, October 25, 2002 11:30 PM > To: [EMAIL PROTECTED] > Subject: [PHP]
RE: [PHP] Best way to set global params for entire site??
If you are not running PHP under a Windows platform the most efficient way to solve your problem is with a PHP extension I developed. It handles constants and provides a type of persistent variable too. It has been immensely useful for my projects. http://pwee.sourceforge.net/ Lance > -Original Message- > From: Monty [mailto:monty3@;hotmail.com] > Sent: Tuesday, October 22, 2002 3:27 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Best way to set global params for entire site?? > > > I'm building a site with PHP and most scripts need access to certain > site-wide global parameters, such as paths and default settings, > etc. What's > the best way to load this information so that it's globally > available to all > scripts? I have a func.php file that is included in all scripts - > do I just > load them every time for each script in there? Or is there a more > efficient > way of doing this with environment variables or some other way? > > Thanks!! > > > > -- > 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] Problem with Session and register_globals
Hello, When I try the code bellow with register_globals=On, it work was expected, the counter variable is incremented each time that I load the page, but, when I try with register_globals=Off, it doesn´t work, the counter variable is incremented just in the first time, the session variable is not update. How can I fix this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Manual Book
On Sunday 27 October 2002 02:45, Stephen wrote: > Hello, > > I was just wondering if the entire PHP manual at php.net was published into > a book or not. I was going to print it out once but it turned out to be > about 1000+ pages... It would be out of date as soon as it's published and before it even gets to the shops! -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Bradley's Bromide: If computers get too powerful, we can organize them into a committee -- that will do them in. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem wih Session and register_globals
Hello, When I try the code below and register_globals=On, its work fine, the counter variable is incremented each time that I load the page, but, when register_globals=Off, its does not work, the counter variable is save just in first time and never more. How can I fix this? With out to turn register_globals=On. Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with session and register_globals=off
Hello, When I try the code below and register_globals=On, its work fine, the counter variable is incremented each time that I load the page, but, when register_globals=Off, its does not work, the counter variable is save just in first time and never more. How can I fix this? With out to turn register_globals=On. Thanks, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mail Delivery errors when posting here ???
For some reason I get the following e-mail every time I make a post here recently and not sure why: --- This message was created automatically by mail delivery software (Exim). A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed: [EMAIL PROTECTED] SMTP error from remote mailer after MAIL FROM: <[EMAIL PROTECTED]> SIZE=6478: host yun.yagibdah.de [192.168.0.1]: 550 rejected: administrative prohibition --- This is followed by a copy of my posting to the newsgroup which does get posted. Not sure why it's being rejected and where this is coming from. Any clues?? Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract($_POST)
Rick Emery wrote: > You can still use extract($_POST). > It is as safe/vulernable as $_POST['isAdmin']. > > In either case, use only variables that you know are yours and be certain > these contain values which you believe to be safe. For instance, if you expect > a variable called $firstname to contain a name to be stored in a SQL database, > be certain it does not contain SQL commands which can damage your database. > Okay, I know I can use strip_tags() and/or htmlspecialchars() to strip out or modify HTML and PHP code in a string, but, how does one do the same with MySQL code in a string to prevent tampering? Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] extract($_POST)
> Well, one way you can avoid similar things to happen is, you can do > something like, say, create a user that can only SELECT. If the user can > only SELECT then it cannot DELETE. This is a great suggestion from Rick. I already use this method. I have several MySQL users set up for various functions: one that can only SELECT, which is the one I use the most, another that can SELECT, UPDATE and INSERT, and another that can do all of the following plus DELETE. Monty -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: parsing conundrum
I'm not attempting to solve this puzzle, but, regarding the output from print_r(), try this for nicely formatted output: echo ""; print_r($myarray); echo ""; Looks much better. Monty > From: [EMAIL PROTECTED] (Peter Harkins) > Newsgroups: php.general > Date: Sat, 26 Oct 2002 02:37:51 -0700 > To: [EMAIL PROTECTED] > Subject: parsing conundrum > > If you know what recursion is and like a challege, here's a puzzle > to keep you up nights. If not, you'll probably just want to mutter to > yourself "what a poor, unlucky bastard" and pass on by. > > I'm parsing some data files into a PHP array and am stumped. I'm at > a loss for how to do this without grinding through character by character. > That would work, but my subconcious is nagging at me that there's got to be > a more elegant way to do it that I'm just not seeing, so I'm going to > describe the problem and ask for help before I start grinding. > > The app I'm getting this from has 4 data types: int, string, array > and mapping (associative array). > > Ints and strings are pretty straightforward, but there's no way to > tell 0 from null int or null string. This is an annoying limitation of the > app that just has to be ignored and dealt with by whatever gets this data > from us. This (among other reasons) make me glad PHP is weakly-typed. > > Arrays are indexed from 0 and values can mix ints and strings > freely. > > To start, mappings are arrays indexed by ints or strings. Mappings > aren't just arrays, though, they have a "width" (which is really a nested > array that I'm pretty certain is an ugly historical artifact.) Width allows > multiple values for one key and must be the same for all values in a > mapping, though the values (both of keys and their values) don't have to be > of the same type. Mappings can also mix ints and strings. > > The tough part is that arrays and mappings can nest inside of each > other and the only characters quoted in strings are \, " and \n. This means > recursion must be used, but I just can't figure out a way to find the > boundaries of each element. Anyone with a clean way to do this (probably > with some kind of crazy regexp) will recieve my awe and gratitude. > > Here's an example file[1]: > > null_string 0 > some_string "Fourscore and seven years ago..." > unset_int 0 > an_int 42 > negative_int -12 > null_array ({ }) > null_mapping ([ ]) > easy_array ({9,22,"test",}) > easy_mapping (["string":3,"foo":"bar",[12]:"I am not a crook!",]) > medium_array ({"a string, containing a comma and a \"",23,}) > medium_mapping (["str\"ing":3;5;7, 9:"Read my lips.";11;13;,]) > hard_array ({"comma, string",({3,4,5,}),({"'\"str'",4,({3,4,({ }),}),}),}) > hard_mapping ([17:"str";15,"foo":([ ]);17,"b'l\\a\nh":19;([21:23,]),"tour de > force":({29,31});({([ ])}),]) > > You may notice the last one is pathological[2]. Yes, PHP will really > let you use " and \n in array keys. The real data do sometimes get about > this complex; consider this a compressed version. As a fun fact, I've > learned vim's % command doesn't work when there's an odd number of double > quotes between your parens/braces. > > Calling print_r on the array this generates would return: > > Array > ( > [null_string] => 0 > [some_string] => "Fourscore and seven years ago..." > [unset_int] => 0 > [an_int] => 42 > [negative_int] => -12 > [null_array] => Array > ( > ) > > [null_mapping] => Array > ( > ) > > [easy_array] => Array > ( > [0] => 9 > [1] => 22 > [0] => test > ) > > [easy_mapping] => Array > ( > [string] => 3 > [foo] => "bar" > [12] => "I am not a crook!" > ) > > [medium_array] => Array > ( > [0] => a string, containing a comma and a " > [1] => 23 > ) > > [medium_mapping] => Array > ( > [string] => Array > ( > [0] => 3 > [1] => 5 > [2] => 7 > ) > > [9] => Array > ( > [0] => Read my lips. > [1] => 11 > [2] => 13 > ) > > ) > > [hard_array] => Array > ( > [0] => comma, string > [1] => Array > ( > [0] => 3 > [1] => 4 > [2] => 5 > ) > > [2] => Array > ( > [0] => '"str' > [1] => 4 > [2] => Array > ( > [0] => 3 > [1] => 4 > [2] => Array > ( > ) > > ) > > ) > > ) > > [hard_mapping] => Array > ( > [17] => Array > ( > [0] => str > [1] => 15 > ) > > [foo] => Array > ( > [0] => Array > ( > ) > > [1] => 17 > ) > > [b'l\a\nh] => Array > ( > [0] => 19 > [1] => Array > ( > [21] => 23 > ) > > ) > > [tour de force] => Array > ( > [0] => Array > ( > [29] => 31 > ) > > [1] => Array > ( > [0] => Array > ( > ) > ) > > ) > > ) > > ) > > The truly eagle-eyed will note that print_r doesn't really escape \n > when outputting, which is ugly and should probably have a bug report filed > on it. I've ignored this behavior of print_r to produce more readable > output. > > Anyone who gets the 'tour de force' can contact me for the 'victory > lap' puzzle if it didn't occur to them while solving this one. It's equally > frustrating. > > [1] Brownie points to anyone who recognizes the app that outputs this data > format. Yep, I'm doing web integration. Feel f
[PHP] Re: mysql_fetch_row options
I use the following function to do this... function countRecords($query, $dbcon=0) { if ($dbcon==0) { $ dbcon = connDbase(); } $query = "SELECT COUNT(*) ".$query; $res = mysql_query($query, $ dbcon); // Query DB. return mysql_result($res, 0, "count(*)"); } Here's how it's used: $count = countRecords("FROM mydb WHERE id = 1001"); All I have to do is provide the query starting with FROM as the function creates the SELECT COUNT(*) part. Also, the optional second parameter is to pass the database connection resource ID to the function if I've already established one before calling this function. This prevents the function from having to establish a second DB connection for the count. If the second param is left empty then a DB connection will be made using another function: connDbase(). $count will contain the number of records that match the query and only requires me to type one line of code. Monty > From: [EMAIL PROTECTED] (James Taylor) > Newsgroups: php.general > Date: Sat, 26 Oct 2002 03:23:23 -0700 > To: <[EMAIL PROTECTED]> > Subject: mysql_fetch_row options > > There's got to be a better way to go about this: I am constantly doing mysql > queries where I am doing > a count(), so a sample query would be like this: "select count(*) from > database". I'm expecting only > ONE value back exactly, and that's the count results. However, to get this > data into a variable, i'm > having to write code like this: > > $result = mysql_query("select count(*) from database", $db); > $myrow = mysql_fetch_row($result); > $staticvar += $myrow[0]; > > $staticvar will never be an array, it's just a simple variable storing a > number. I *could* do it like this: > > $result = mysql_query("select * from database", $db); > $staticvar += mysql_num_rows($result); > > However, the mysql query will be much, much slower if I do it like this. > > Basically, what I'm asking, is how to do something like: > > $staticvar += mysql_fetch_row($result); > > I want to eliminate step two, and I don't want to involve any temporary > arrays when there's always just one > value. Any suggestions? Thanks a bunch! > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Manual Book
Hello, I was just wondering if the entire PHP manual at php.net was published into a book or not. I was going to print it out once but it turned out to be about 1000+ pages... Thanks, Stephen Craton http://www.melchior.us http://php.melchior.us
[PHP] Re: upload files
I just wrote a file upload script and all the information that I needed was here in the manual: http://www.php.net/manual/en/features.file-upload.php There were a couple of "common pitfalls" that it points out, which you should check. Make sure you've defined the various configuration variables 'correctly' some are: upload_files upload_tmp_dir upload_max_filesize and post_max_filesize also check your form to make sure you have an input defined for MAX_FILE_SIZE and that in the tag you have the proper encoding. My form used '' and this made a difference. Something worth checking. Chadly "Cyrille Andres" <[EMAIL PROTECTED]> wrote in message news:FA432D4D6C2EC1498940A59C494F1538035E2860@;stca207a.bus.sc.rolm.com... > > > > Hello everybody, > > > I want to allow the client to upload a text file on my web server, so I use > this code : > > > > > Uploaded files details > > printf("Name : %s ", $HTTP_POST_FILES["userfile"]["name"]); > printf("Temporary Name : %s ", > $HTTP_POST_FILES["userfile"]["tmp_name"]); > printf("Size : %s ", $HTTP_POST_FILES["userfile"]["size"]); > printf("Type : %s ", $HTTP_POST_FILES["userfile"]["type"]); > > if (copy > ($HTTP_POST_FILES["userfile"]["tmp_name"],"temp/".$HTTP_POST_FILES["userfile > "]["name"])) > { > printf("File successfully copied");} > else{ > printf("Error: failed to copy file");} > > > ?> > > > > > the $http_post_files doesn't return me anything, anybody would have a clue > ?? ( roughly speaking I am not able to retrieve the field the client try to > send me). > > Thanks a lot. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] passthru problems generating WAVs with mpg123
I'm SURE you've got a good reason, but why are you wanting to generate a WAV on demand? The loss in file quality occurs going from WAV > MP3, so then later going back to WAV would only result in a bigger file size, with ZERO benefit in audio quality. Just asking :) Justin on 26/10/02 4:53 PM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > I've written a little script for VoiceXML applications to generate a WAV > from an MP3 on demand: > > #file wavwrapper.php > header('Content-Type: audio/wav'); > $filename = $_GET['filename']; > > $mp3dir="/var/www/mp3s/"; > $playercmd="/usr/local/bin/mpg123 -m -w - -q -4 --8bit"; > passthru("$playercmd $mp3dir/$filename 2> /tmp/playererror"); > ?> > > > I request it as wavwrapper?filename=song.mp3, and the browser reads the > MIME type properly, prompts me to play or download the song. I download > it, and save it as a WAV file. However, Mozilla downloads about 1.5M of > data, saves it all to a file, and then displays the downloaded size as > 1k. And then when I try to play it back, it won't play; it's like an > empty file. Same thing happens if I try to play it directly. But if I > redirect the output of mpg123 from standard out (so it goes across the > web connection) to a file and then download the file, the file plays > just fine. I figure there's something to do with the way PHP dumps back > the binary data that just isn't working right, but I don't know what it > is. Anyone have any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
php-general Digest 26 Oct 2002 16:54:49 -0000 Issue 1667
php-general Digest 26 Oct 2002 16:54:49 - Issue 1667 Topics (messages 121513 through 121528): ftp_problem - ... php_network_getaddresses: getaddrinfo failed: ... 121513 by: vic 121514 by: John Nichel 121515 by: vic 121516 by: John Nichel 121517 by: vic 121518 by: vic Re: Couple of questions 121519 by: Jason Wong Re: ldap_add problem 121520 by: Stig Venaas parsing conundrum 121521 by: Peter Harkins mysql_fetch_row options 121522 by: James Taylor 121523 by: Tom Rogers 121524 by: Jason Wong Re: PHP Session register variable not always restored with contents 121525 by: Victor Soroka
[PHP] passthru problems generating WAVs with mpg123
I've written a little script for VoiceXML applications to generate a WAV from an MP3 on demand: #file wavwrapper.php header('Content-Type: audio/wav'); $filename = $_GET['filename']; $mp3dir="/var/www/mp3s/"; $playercmd="/usr/local/bin/mpg123 -m -w - -q -4 --8bit"; passthru("$playercmd $mp3dir/$filename 2> /tmp/playererror"); ?> I request it as wavwrapper?filename=song.mp3, and the browser reads the MIME type properly, prompts me to play or download the song. I download it, and save it as a WAV file. However, Mozilla downloads about 1.5M of data, saves it all to a file, and then displays the downloaded size as 1k. And then when I try to play it back, it won't play; it's like an empty file. Same thing happens if I try to play it directly. But if I redirect the output of mpg123 from standard out (so it goes across the web connection) to a file and then download the file, the file plays just fine. I figure there's something to do with the way PHP dumps back the binary data that just isn't working right, but I don't know what it is. Anyone have any ideas? -- Soren Harward [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]
Does it work when you do it like this Jason Porembski wrote: Hey folks. I am attempting to run PHP code with
[PHP]
Hey folks. I am attempting to run PHP code with
RE: [PHP] Re: PHP Session register variable not always restored with contents
On Thu, 24 Oct 2002 21:26:30 +, John W. Holmes wrote: > What is supposed to be in the session? Maybe these users are just > denying cookies? Maybe... But my php compiled with --use-trans-sid and use this feature. In the session i store account, access timestamp etc... P.S. And 10% of traffic ~2000 visitors. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fetch_row options
On Saturday 26 October 2002 18:23, James Taylor wrote: > There's got to be a better way to go about this: I am constantly doing > mysql queries where I am doing > a count(), so a sample query would be like this: "select count(*) from > database". I'm expecting only > ONE value back exactly, and that's the count results. However, to get this > data into a variable, i'm > having to write code like this: > > $result = mysql_query("select count(*) from database", $db); > $myrow = mysql_fetch_row($result); > $staticvar += $myrow[0]; > > $staticvar will never be an array, it's just a simple variable storing a > number. I *could* do it like this: > > $result = mysql_query("select * from database", $db); > $staticvar += mysql_num_rows($result); > > However, the mysql query will be much, much slower if I do it like this. > > Basically, what I'm asking, is how to do something like: > > $staticvar += mysql_fetch_row($result); > > I want to eliminate step two, and I don't want to involve any temporary > arrays when there's always just one > value. Any suggestions? Thanks a bunch! You can assign the directly into a variable using something like: list($count) = mysql_fetch_array($result); Not sure whether you can do a += into an existing variable though. Why don't you just stuff the above into a function instead? -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Runt packets */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fetch_row options
Hi, Saturday, October 26, 2002, 8:23:23 PM, you wrote: JT> There's got to be a better way to go about this: I am constantly doing mysql JT> queries where I am doing JT> a count(), so a sample query would be like this: "select count(*) from JT> database". I'm expecting only JT> ONE value back exactly, and that's the count results. However, to get this JT> data into a variable, i'm JT> having to write code like this: JT> $result = mysql_query("select count(*) from database", $db); JT> $myrow = mysql_fetch_row($result); JT> $staticvar += $myrow[0]; JT> $staticvar will never be an array, it's just a simple variable storing a JT> number. I *could* do it like this: JT> $result = mysql_query("select * from database", $db); JT> $staticvar += mysql_num_rows($result); JT> However, the mysql query will be much, much slower if I do it like this. JT> Basically, what I'm asking, is how to do something like: JT> $staticvar += mysql_fetch_row($result); JT> I want to eliminate step two, and I don't want to involve any temporary JT> arrays when there's always just one JT> value. Any suggestions? Thanks a bunch! (untested :) $result = mysql_query("select count(*) as cnt from database", $db); $staticvar += mysql_result($result,0,0); -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_fetch_row options
There's got to be a better way to go about this: I am constantly doing mysql queries where I am doing a count(), so a sample query would be like this: "select count(*) from database". I'm expecting only ONE value back exactly, and that's the count results. However, to get this data into a variable, i'm having to write code like this: $result = mysql_query("select count(*) from database", $db); $myrow = mysql_fetch_row($result); $staticvar += $myrow[0]; $staticvar will never be an array, it's just a simple variable storing a number. I *could* do it like this: $result = mysql_query("select * from database", $db); $staticvar += mysql_num_rows($result); However, the mysql query will be much, much slower if I do it like this. Basically, what I'm asking, is how to do something like: $staticvar += mysql_fetch_row($result); I want to eliminate step two, and I don't want to involve any temporary arrays when there's always just one value. Any suggestions? Thanks a bunch! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] parsing conundrum
If you know what recursion is and like a challege, here's a puzzle to keep you up nights. If not, you'll probably just want to mutter to yourself "what a poor, unlucky bastard" and pass on by. I'm parsing some data files into a PHP array and am stumped. I'm at a loss for how to do this without grinding through character by character. That would work, but my subconcious is nagging at me that there's got to be a more elegant way to do it that I'm just not seeing, so I'm going to describe the problem and ask for help before I start grinding. The app I'm getting this from has 4 data types: int, string, array and mapping (associative array). Ints and strings are pretty straightforward, but there's no way to tell 0 from null int or null string. This is an annoying limitation of the app that just has to be ignored and dealt with by whatever gets this data from us. This (among other reasons) make me glad PHP is weakly-typed. Arrays are indexed from 0 and values can mix ints and strings freely. To start, mappings are arrays indexed by ints or strings. Mappings aren't just arrays, though, they have a "width" (which is really a nested array that I'm pretty certain is an ugly historical artifact.) Width allows multiple values for one key and must be the same for all values in a mapping, though the values (both of keys and their values) don't have to be of the same type. Mappings can also mix ints and strings. The tough part is that arrays and mappings can nest inside of each other and the only characters quoted in strings are \, " and \n. This means recursion must be used, but I just can't figure out a way to find the boundaries of each element. Anyone with a clean way to do this (probably with some kind of crazy regexp) will recieve my awe and gratitude. Here's an example file[1]: null_string 0 some_string "Fourscore and seven years ago..." unset_int 0 an_int 42 negative_int -12 null_array ({ }) null_mapping ([ ]) easy_array ({9,22,"test",}) easy_mapping (["string":3,"foo":"bar",[12]:"I am not a crook!",]) medium_array ({"a string, containing a comma and a \"",23,}) medium_mapping (["str\"ing":3;5;7, 9:"Read my lips.";11;13;,]) hard_array ({"comma, string",({3,4,5,}),({"'\"str'",4,({3,4,({ }),}),}),}) hard_mapping ([17:"str";15,"foo":([ ]);17,"b'l\\a\nh":19;([21:23,]),"tour de force":({29,31});({([ ])}),]) You may notice the last one is pathological[2]. Yes, PHP will really let you use " and \n in array keys. The real data do sometimes get about this complex; consider this a compressed version. As a fun fact, I've learned vim's % command doesn't work when there's an odd number of double quotes between your parens/braces. Calling print_r on the array this generates would return: Array ( [null_string] => 0 [some_string] => "Fourscore and seven years ago..." [unset_int] => 0 [an_int] => 42 [negative_int] => -12 [null_array] => Array ( ) [null_mapping] => Array ( ) [easy_array] => Array ( [0] => 9 [1] => 22 [0] => test ) [easy_mapping] => Array ( [string] => 3 [foo] => "bar" [12] => "I am not a crook!" ) [medium_array] => Array ( [0] => a string, containing a comma and a " [1] => 23 ) [medium_mapping] => Array ( [string] => Array ( [0] => 3 [1] => 5 [2] => 7 ) [9] => Array ( [0] => Read my lips. [1] => 11 [2] => 13 ) ) [hard_array] => Array ( [0] => comma, string [1] => Array ( [0] => 3 [1] => 4 [2] => 5 ) [2] => Array ( [0] => '"str' [1] => 4 [2] => Array ( [0] => 3 [1] => 4 [2] => Array ( ) ) ) ) [hard_mapping] => Array ( [17] => Array ( [0] => str [1] => 15 ) [foo] => Array ( [0] => Array ( ) [1] => 17 ) [b'l\a\nh] => Array (
Re: [PHP] ldap_add problem
On Thu, Oct 24, 2002 at 04:37:56PM -0400, GC wrote: > Hi, I wrote a simple page that tries to enter a string into a LDAP server. > I get the following error: > > Warning: LDAP: add operation could not be completed. in > /var/www/html/user/adduser_p.php on line 65 > > Where in my log files can I go to look for more detailed info on that error, > I don't know if I have logging enabled for slapd. Thanks!! There are a number of things that could be wrong, but the most likely is access rights I suppose. The best way to solve this is indeed to turn on more logging in slapd if necessary. Please see slapd docs for how to do this. Stig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Couple of questions
On Friday 25 October 2002 02:04, Chris Boget wrote: > > 1) Does anyone know of a JS mailing list that actually has a good > > amount of traffic (receives more than 10 email messages a day)? > > Dunno google -> javascript weenie -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Pound for pound, the amoeba is the most vicious animal on earth. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php